Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.

Commit 2ea7dba

Browse files
authored
Merge pull request #52 from marqdevx/dev
Add `.color` and cs2 updates fix
2 parents cdcc740 + fb680a8 commit 2ea7dba

File tree

11 files changed

+96
-67
lines changed

11 files changed

+96
-67
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
![Build pass](https://github.com/marqdevx/mm-cs2-scrim/actions/workflows/compile-metamod-addon.yaml/badge.svg)
1+
![Build pass](https://github.com/marqdevx/mm-cs2-scrim/actions/workflows/compile-metamod-addon.yaml/badge.svg)
2+
![GitHub downloads](https://img.shields.io/github/downloads/marqdevx/mm-cs2-scrim/total.svg?style=flat-square&label=Downloads)
23

34
## IMPORTANT
45
This repository is based on https://github.com/Source2ZE/CS2Fixes/
@@ -47,6 +48,9 @@ The plugin has been developed with these ideas in mind:
4748
`.noflash`: toggle flash effect
4849
`.ct`, `.t`, `.spec`, `.side`: switch team side
4950

51+
* General commands
52+
`.color` : set your cl_color live, in case you have duplicated colors, usage: `.color 2`
53+
5054
* Leveraged from [CS2Fixes](https://github.com/Source2ZE/CS2Fixes/)
5155
`c_reload_admins`: console command to reload admins.cfg
5256
`.ban <player> <duration/0 (permanent)>`: ban a player
@@ -108,7 +112,7 @@ You can enable/disable the features of the plugin by changing the values at `<se
108112

109113
### Requirements
110114

111-
- [Metamod:Source](https://www.sourcemm.net/downloads.php/?branch=master) (build 1282 or higher)
115+
- [Metamod:Source](https://www.sourcemm.net/downloads.php/?branch=master) (build 1290 or higher)
112116
- [AMBuild](https://wiki.alliedmods.net/Ambuild)
113117

114118
## Credits

gamedata/cs2fixes.games.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@
243243
"CNavMesh_GetNearestNavArea"
244244
{
245245
"library" "server"
246-
"windows" "\x48\x89\x4C\x24\x08\x55\x53\x57\x41\x54\x41\x55\x41\x56"
247-
"linux" "\x55\x48\x89\xE5\x41\x57\x49\x89\xFF\x41\x56\x49\x89\xD6\x41\x55\x41\x54\x53"
246+
"windows" "\x48\x89\x5C\x24\x2A\x48\x89\x54\x24\x2A\x48\x89\x4C\x24\x2A\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xAC\x24\x2A\x2A\x2A\x2A"
247+
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x56\x41\x89\xCE\x41\x55\x49\x89\xFD\x41\x54\x48\x8D\x3D\x2A\x2A\x2A\x2A"
248248
}
249249
// Search "Changes's player's model", look for a function containing 'models/%s.vmdl'. Below V_snprintf is the one
250250
// This matches 2 functions on linux, however they're literally identical
@@ -340,8 +340,8 @@
340340
"CBaseEntity_EmitSoundFilter"
341341
{
342342
"library" "server"
343-
"windows" "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x41\x56\x48\x83\xEC\x30\x48\x8B\xF9"
344-
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x56\x49\x89\xD6\x41\x55\x41\x89\xF5\x41\x54\x49\x89\xFC\x53\x48\x83\xEC\x2A\x48"
343+
"windows" "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x48\x89\x7C\x24\x20\x41\x56\x48\x83\xEC\x30\x48\x8B\xEA"
344+
"linux" "\x55\x48\x89\xE5\x41\x56\x49\x89\xD6\x41\x55\x41\x89\xF5\x41\x54\x48\x8D\x35\x2A\x2A\x2A\x2A"
345345
}
346346

347347
// "CNetworkStringTable::AddString"
@@ -428,8 +428,8 @@
428428
// "tried to sprint to a non-client", there will be a check above like this: if ( a2 >= *(v5 + 632) ), note that this is a CUtlVector
429429
"CNetworkGameServer_ClientList"
430430
{
431-
"windows" "77"
432-
"linux" "79"
431+
"windows" "75"
432+
"linux" "77"
433433
}
434434

435435
// Called right before printing "Warning: Can't add nullptr string to table %s\n"

sdk

Submodule sdk updated 74 files

src/commands.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,18 @@ CON_COMMAND_CHAT(myuid, "test")
390390
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Your userid is %i, slot: %i, retrieved slot: %i", g_pEngineServer2->GetPlayerUserId(iPlayer).Get(), iPlayer, g_playerManager->GetSlotFromUserId(g_pEngineServer2->GetPlayerUserId(iPlayer).Get()));
391391
}
392392

393+
CON_COMMAND_CHAT(color, "Set player's hud color") {
394+
if (!player)
395+
return;
396+
397+
if (args.ArgC() < 2){
398+
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Usage .color <1-5>");
399+
return;
400+
}
401+
402+
player->m_iCompTeammateColor = atoi(args[1]) % 5;
403+
}
404+
393405
bool match_paused = false;
394406
bool ct_ready = true;
395407
bool t_ready = true;

src/cs2_sdk/entity/ccsplayercontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class CCSPlayerController : public CBasePlayerController
3333
SCHEMA_FIELD(CCSPlayerController_InGameMoneyServices*, m_pInGameMoneyServices)
3434
SCHEMA_FIELD(CCSPlayerController_ActionTrackingServices*, m_pActionTrackingServices)
3535
SCHEMA_FIELD(CUtlSymbolLarge, m_szClan)
36+
SCHEMA_FIELD(int32_t , m_iCompTeammateColor);
3637
SCHEMA_FIELD(bool, m_bPawnIsAlive);
3738
SCHEMA_FIELD(CHandle<CCSPlayerPawn>, m_hPlayerPawn);
3839

src/cs2_sdk/schema.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* =============================================================================
33
* CS2Fixes
4-
* Copyright (C) 2023 Source2ZE
4+
* Copyright (C) 2023-2024 Source2ZE
55
* =============================================================================
66
*
77
* This program is free software; you can redistribute it and/or modify it under
@@ -20,13 +20,12 @@
2020
#include "schema.h"
2121

2222
#include "../common.h"
23-
#include "cschemasystem.h"
23+
#include "schemasystem/schemasystem.h"
2424
#include "tier1/utlmap.h"
2525
#include "tier0/memdbgon.h"
2626
#include "plat.h"
2727
#include "entity/cbaseentity.h"
2828

29-
extern CSchemaSystem *g_pSchemaSystem2;
3029
extern CGlobalVars *gpGlobals;
3130

3231
using SchemaKeyValueMap_t = CUtlMap<uint32_t, SchemaKey>;
@@ -35,10 +34,10 @@ using SchemaTableMap_t = CUtlMap<uint32_t, SchemaKeyValueMap_t*>;
3534

3635
static bool IsFieldNetworked(SchemaClassFieldData_t& field)
3736
{
38-
for (int i = 0; i < field.m_metadata_size; i++)
37+
for (int i = 0; i < field.m_nStaticMetadataCount; i++)
3938
{
4039
static auto networkEnabled = hash_32_fnv1a_const("MNetworkEnable");
41-
if (networkEnabled == hash_32_fnv1a_const(field.m_metadata[i].m_name))
40+
if (networkEnabled == hash_32_fnv1a_const(field.m_pStaticMetadata[i].m_pszName))
4241
return true;
4342
}
4443

@@ -47,12 +46,12 @@ static bool IsFieldNetworked(SchemaClassFieldData_t& field)
4746

4847
static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* className, uint32_t classKey)
4948
{
50-
CSchemaSystemTypeScope* pType = g_pSchemaSystem2->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
49+
CSchemaSystemTypeScope* pType = g_pSchemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
5150

5251
if (!pType)
5352
return false;
5453

55-
SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass(className);
54+
SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass(className).Get();
5655

5756
if (!pClassInfo)
5857
{
@@ -63,8 +62,8 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* cla
6362
return false;
6463
}
6564

66-
short fieldsSize = pClassInfo->GetFieldsSize();
67-
SchemaClassFieldData_t* pFields = pClassInfo->GetFields();
65+
short fieldsSize = pClassInfo->m_nFieldCount;
66+
SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
6867

6968
SchemaKeyValueMap_t *keyValueMap = new SchemaKeyValueMap_t(0, 0, DefLessFunc(uint32_t));
7069
keyValueMap->EnsureCapacity(fieldsSize);
@@ -75,38 +74,38 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* cla
7574
SchemaClassFieldData_t& field = pFields[i];
7675

7776
#ifdef _DEBUG
78-
Message("%s::%s found at -> 0x%X - %llx\n", className, field.m_name, field.m_single_inheritance_offset, &field);
77+
Message("%s::%s found at -> 0x%X - %llx\n", className, field.m_pszName, field.m_nSingleInheritanceOffset, &field);
7978
#endif
8079

81-
keyValueMap->Insert(hash_32_fnv1a_const(field.m_name), {field.m_single_inheritance_offset, IsFieldNetworked(field)});
80+
keyValueMap->Insert(hash_32_fnv1a_const(field.m_pszName), {field.m_nSingleInheritanceOffset, IsFieldNetworked(field)});
8281
}
8382

8483
return true;
8584
}
8685

8786
int16_t schema::FindChainOffset(const char* className)
8887
{
89-
CSchemaSystemTypeScope* pType = g_pSchemaSystem2->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
88+
CSchemaSystemTypeScope* pType = g_pSchemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
9089

9190
if (!pType)
9291
return false;
9392

94-
SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className);
93+
SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className).Get();
9594

9695
do
9796
{
98-
SchemaClassFieldData_t* pFields = pClassInfo->GetFields();
99-
short fieldsSize = pClassInfo->GetFieldsSize();
97+
SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
98+
short fieldsSize = pClassInfo->m_nFieldCount;
10099
for (int i = 0; i < fieldsSize; ++i)
101100
{
102101
SchemaClassFieldData_t& field = pFields[i];
103102

104-
if (V_strcmp(field.m_name, "__m_pChainEntity") == 0)
103+
if (V_strcmp(field.m_pszName, "__m_pChainEntity") == 0)
105104
{
106-
return field.m_single_inheritance_offset;
105+
return field.m_nSingleInheritanceOffset;
107106
}
108107
}
109-
} while ((pClassInfo = pClassInfo->GetParent()) != nullptr);
108+
} while ((pClassInfo = pClassInfo->m_pBaseClasses ? pClassInfo->m_pBaseClasses->m_pClass : nullptr) != nullptr);
110109

111110
return 0;
112111
}
@@ -140,4 +139,4 @@ void SetStateChanged(Z_CBaseEntity* pEntity, int offset)
140139

141140
pEntity->m_lastNetworkChange = gpGlobals->curtime;
142141
pEntity->m_isSteadyState().ClearAll();
143-
};
142+
};

src/cs2_sdk/schema.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* =============================================================================
33
* CS2Fixes
4-
* Copyright (C) 2023 Source2ZE
4+
* Copyright (C) 2023-2024 Source2ZE
55
* =============================================================================
66
*
77
* This program is free software; you can redistribute it and/or modify it under
@@ -19,8 +19,6 @@
1919

2020
#pragma once
2121

22-
#include "stdint.h"
23-
2422
#ifdef _WIN32
2523
#pragma warning(push)
2624
#pragma warning(disable : 4005)

src/cs2fixes.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "icvar.h"
3434
#include "interface.h"
3535
#include "tier0/dbg.h"
36-
#include "cschemasystem.h"
36+
#include "schemasystem/schemasystem.h"
3737
#include "plat.h"
3838
#include "entitysystem.h"
3939
#include "engine/igameeventsystem.h"
@@ -53,9 +53,6 @@
5353
#include "entity/ccsplayercontroller.h"
5454
#include "entitylistener.h"
5555

56-
#define VPROF_ENABLED
57-
#include "tier0/vprof.h"
58-
5956
#include "tier0/memdbgon.h"
6057

6158
extern CUtlVector <CCSPlayerController*> coaches;
@@ -120,7 +117,6 @@ IGameEventManager2 *g_gameEventManager = nullptr;
120117
INetworkGameServer *g_pNetworkGameServer = nullptr;
121118
CGameEntitySystem *g_pEntitySystem = nullptr;
122119
CEntityListener *g_pEntityListener = nullptr;
123-
CSchemaSystem *g_pSchemaSystem2 = nullptr;
124120
CGlobalVars *gpGlobals = nullptr;
125121
CPlayerManager *g_playerManager = nullptr;
126122
IVEngineServer2 *g_pEngineServer2 = nullptr;
@@ -141,9 +137,9 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
141137
PLUGIN_SAVEVARS();
142138

143139
GET_V_IFACE_CURRENT(GetEngineFactory, g_pEngineServer2, IVEngineServer2, SOURCE2ENGINETOSERVER_INTERFACE_VERSION);
144-
GET_V_IFACE_CURRENT(GetEngineFactory, g_pGameResourceServiceServer, IGameResourceServiceServer, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
140+
GET_V_IFACE_CURRENT(GetEngineFactory, g_pGameResourceServiceServer, IGameResourceService, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
145141
GET_V_IFACE_CURRENT(GetEngineFactory, g_pCVar, ICvar, CVAR_INTERFACE_VERSION);
146-
GET_V_IFACE_CURRENT(GetEngineFactory, g_pSchemaSystem2, CSchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
142+
GET_V_IFACE_CURRENT(GetEngineFactory, g_pSchemaSystem, ISchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
147143
GET_V_IFACE_ANY(GetServerFactory, g_pSource2Server, ISource2Server, SOURCE2SERVER_INTERFACE_VERSION);
148144
GET_V_IFACE_ANY(GetServerFactory, g_pSource2ServerConfig, ISource2ServerConfig, SOURCE2SERVERCONFIG_INTERFACE_VERSION);
149145
GET_V_IFACE_ANY(GetServerFactory, g_pSource2GameEntities, ISource2GameEntities, SOURCE2GAMEENTITIES_INTERFACE_VERSION);
@@ -404,7 +400,7 @@ void CS2Fixes::Hook_StartupServer(const GameSessionConfiguration_t& config, ISou
404400

405401
// Run map cfg (if present)
406402
/*char cmd[MAX_PATH];
407-
V_snprintf(cmd, sizeof(cmd), "exec cs2fixes/maps/%s", gpGlobals->mapname);
403+
V_snprintf(cmd, sizeof(cmd), "exec cs2fixes/maps/%s", gpGlobals->mapname.ToCStr());
408404
g_pEngineServer2->ServerCommand(cmd);
409405
*/
410406

@@ -536,7 +532,7 @@ void CS2Fixes::Hook_ClientDisconnect( CPlayerSlot slot, ENetworkDisconnectionRea
536532

537533
void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick )
538534
{
539-
VPROF_ENTER_SCOPE(__FUNCTION__);
535+
540536
/**
541537
* simulating:
542538
* ***********
@@ -577,7 +573,6 @@ void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick
577573
}
578574
}
579575

580-
VPROF_EXIT_SCOPE();
581576
}
582577

583578
// Potentially might not work
@@ -616,7 +611,7 @@ const char *CS2Fixes::GetLicense()
616611

617612
const char *CS2Fixes::GetVersion()
618613
{
619-
return "1.1.2";
614+
return "1.1.3";
620615
}
621616

622617
const char *CS2Fixes::GetDate()

src/detours.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
#include "gameconfig.h"
3939

4040

41-
#define VPROF_ENABLED
42-
#include "tier0/vprof.h"
43-
4441
#include "tier0/memdbgon.h"
4542

4643
extern CGlobalVars *gpGlobals;

src/playermanager.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#include "ctimer.h"
2828
#include "ctime"
2929

30-
#define VPROF_ENABLED
31-
#include "tier0/vprof.h"
32-
3330
#include "tier0/memdbgon.h"
3431

3532

0 commit comments

Comments
 (0)