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

Add .color and cs2 updates fix #52

Merged
merged 7 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![Build pass](https://github.com/marqdevx/mm-cs2-scrim/actions/workflows/compile-metamod-addon.yaml/badge.svg)
![Build pass](https://github.com/marqdevx/mm-cs2-scrim/actions/workflows/compile-metamod-addon.yaml/badge.svg)
![GitHub downloads](https://img.shields.io/github/downloads/marqdevx/mm-cs2-scrim/total.svg?style=flat-square&label=Downloads)

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

* General commands
`.color` : set your cl_color live, in case you have duplicated colors, usage: `.color 2`

* Leveraged from [CS2Fixes](https://github.com/Source2ZE/CS2Fixes/)
`c_reload_admins`: console command to reload admins.cfg
`.ban <player> <duration/0 (permanent)>`: ban a player
Expand Down Expand Up @@ -108,7 +112,7 @@ You can enable/disable the features of the plugin by changing the values at `<se

### Requirements

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

## Credits
Expand Down
12 changes: 6 additions & 6 deletions gamedata/cs2fixes.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@
"CNavMesh_GetNearestNavArea"
{
"library" "server"
"windows" "\x48\x89\x4C\x24\x08\x55\x53\x57\x41\x54\x41\x55\x41\x56"
"linux" "\x55\x48\x89\xE5\x41\x57\x49\x89\xFF\x41\x56\x49\x89\xD6\x41\x55\x41\x54\x53"
"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"
"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"
}
// Search "Changes's player's model", look for a function containing 'models/%s.vmdl'. Below V_snprintf is the one
// This matches 2 functions on linux, however they're literally identical
Expand Down Expand Up @@ -340,8 +340,8 @@
"CBaseEntity_EmitSoundFilter"
{
"library" "server"
"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"
"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"
"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"
"linux" "\x55\x48\x89\xE5\x41\x56\x49\x89\xD6\x41\x55\x41\x89\xF5\x41\x54\x48\x8D\x35\x2A\x2A\x2A\x2A"
}

// "CNetworkStringTable::AddString"
Expand Down Expand Up @@ -428,8 +428,8 @@
// "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
"CNetworkGameServer_ClientList"
{
"windows" "77"
"linux" "79"
"windows" "75"
"linux" "77"
}

// Called right before printing "Warning: Can't add nullptr string to table %s\n"
Expand Down
2 changes: 1 addition & 1 deletion sdk
Submodule sdk updated 74 files
+8 −0 entity2/entitykeyvalues.cpp
+1 −0 game/shared/cs/cs_usercmd.proto
+2 −0 game/shared/cstrike15/cstrike15_gcmessages.proto
+2 −2 game/shared/igamesystem.h
+355 −392 interfaces/interfaces.cpp
+ lib/linux64/interfaces.a
+ lib/linux64/tier1.a
+ lib/public/win64/interfaces.lib
+ lib/public/win64/tier1.lib
+0 −14 linux_sdk/Makefile.tier1
+17 −17 public/const.h
+14 −7 public/eiface.h
+3 −2 public/engine/igameeventsystem.h
+7 −1 public/entity2/entityclass.h
+4 −3 public/entity2/entitycomponent.h
+12 −9 public/entity2/entityinstance.h
+5 −0 public/entity2/entitykeyvalues.h
+2 −2 public/ihltv.h
+67 −56 public/inetchannel.h
+19 −11 public/inetchannelinfo.h
+166 −241 public/interfaces/interfaces.h
+3 −2 public/irecipientfilter.h
+1 −1 public/ireplay.h
+107 −12 public/iserver.h
+21 −23 public/networkstringtabledefs.h
+2 −1 public/networksystem/inetworkmessages.h
+221 −0 public/schemasystem/schemasystem.h
+427 −0 public/schemasystem/schematypes.h
+2 −2 public/tier0/logging.h
+12 −9 public/tier0/memalloc.h
+308 −251 public/tier0/threadtools.h
+1,004 −808 public/tier0/tslist.h
+4 −2 public/tier1/UtlStringMap.h
+33 −31 public/tier1/bitbuf.h
+4 −2 public/tier1/bufferstring.h
+3 −3 public/tier1/cbyteswap.h
+3 −2 public/tier1/characterset.h
+18 −5 public/tier1/checksum_crc.h
+8 −6 public/tier1/checksum_md5.h
+0 −300 public/tier1/datamanager.h
+11 −7 public/tier1/diff.h
+10 −4 public/tier1/generichash.h
+2 −2 public/tier1/memblockallocator.h
+74 −119 public/tier1/mempool.h
+24 −149 public/tier1/memstack.h
+58 −39 public/tier1/netadr.h
+22 −20 public/tier1/stringpool.h
+11 −12 public/tier1/uniqueid.h
+12 −1 public/tier1/utldict.h
+1 −1 public/tier1/utlhashtable.h
+125 −102 public/tier1/utlleanvector.h
+73 −90 public/tier1/utlsymbol.h
+4 −12 public/tier1/utlsymbollarge.h
+74 −76 public/tier1/utltshash.h
+19 −19 public/variant.h
+0 −331 tier1/NetAdr.cpp
+0 −8 tier1/bitbuf.cpp
+0 −90 tier1/cbyteswap.cpp
+0 −41 tier1/characterset.cpp
+0 −180 tier1/checksum_crc.cpp
+0 −271 tier1/checksum_md5.cpp
+0 −406 tier1/datamanager.cpp
+0 −547 tier1/diff.cpp
+61 −63 tier1/generichash.cpp
+1 −4 tier1/keyvalues3.cpp
+0 −316 tier1/mempool.cpp
+0 −300 tier1/memstack.cpp
+0 −278 tier1/processor_detect.cpp
+0 −63 tier1/processor_detect_linux.cpp
+0 −350 tier1/stringpool.cpp
+1 −18 tier1/tier1.vcxproj
+0 −36 tier1/tier1.vcxproj.filters
+0 −94 tier1/undiff.cpp
+0 −177 tier1/uniqueid.cpp
12 changes: 12 additions & 0 deletions src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,18 @@ CON_COMMAND_CHAT(myuid, "test")
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()));
}

CON_COMMAND_CHAT(color, "Set player's hud color") {
if (!player)
return;

if (args.ArgC() < 2){
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Usage .color <1-5>");
return;
}

player->m_iCompTeammateColor = atoi(args[1]) % 5;
}

bool match_paused = false;
bool ct_ready = true;
bool t_ready = true;
Expand Down
1 change: 1 addition & 0 deletions src/cs2_sdk/entity/ccsplayercontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class CCSPlayerController : public CBasePlayerController
SCHEMA_FIELD(CCSPlayerController_InGameMoneyServices*, m_pInGameMoneyServices)
SCHEMA_FIELD(CCSPlayerController_ActionTrackingServices*, m_pActionTrackingServices)
SCHEMA_FIELD(CUtlSymbolLarge, m_szClan)
SCHEMA_FIELD(int32_t , m_iCompTeammateColor);
SCHEMA_FIELD(bool, m_bPawnIsAlive);
SCHEMA_FIELD(CHandle<CCSPlayerPawn>, m_hPlayerPawn);

Expand Down
37 changes: 18 additions & 19 deletions src/cs2_sdk/schema.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* =============================================================================
* CS2Fixes
* Copyright (C) 2023 Source2ZE
* Copyright (C) 2023-2024 Source2ZE
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
Expand All @@ -20,13 +20,12 @@
#include "schema.h"

#include "../common.h"
#include "cschemasystem.h"
#include "schemasystem/schemasystem.h"
#include "tier1/utlmap.h"
#include "tier0/memdbgon.h"
#include "plat.h"
#include "entity/cbaseentity.h"

extern CSchemaSystem *g_pSchemaSystem2;
extern CGlobalVars *gpGlobals;

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

static bool IsFieldNetworked(SchemaClassFieldData_t& field)
{
for (int i = 0; i < field.m_metadata_size; i++)
for (int i = 0; i < field.m_nStaticMetadataCount; i++)
{
static auto networkEnabled = hash_32_fnv1a_const("MNetworkEnable");
if (networkEnabled == hash_32_fnv1a_const(field.m_metadata[i].m_name))
if (networkEnabled == hash_32_fnv1a_const(field.m_pStaticMetadata[i].m_pszName))
return true;
}

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

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

if (!pType)
return false;

SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass(className);
SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass(className).Get();

if (!pClassInfo)
{
Expand All @@ -63,8 +62,8 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* cla
return false;
}

short fieldsSize = pClassInfo->GetFieldsSize();
SchemaClassFieldData_t* pFields = pClassInfo->GetFields();
short fieldsSize = pClassInfo->m_nFieldCount;
SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;

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

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

keyValueMap->Insert(hash_32_fnv1a_const(field.m_name), {field.m_single_inheritance_offset, IsFieldNetworked(field)});
keyValueMap->Insert(hash_32_fnv1a_const(field.m_pszName), {field.m_nSingleInheritanceOffset, IsFieldNetworked(field)});
}

return true;
}

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

if (!pType)
return false;

SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className);
SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className).Get();

do
{
SchemaClassFieldData_t* pFields = pClassInfo->GetFields();
short fieldsSize = pClassInfo->GetFieldsSize();
SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
short fieldsSize = pClassInfo->m_nFieldCount;
for (int i = 0; i < fieldsSize; ++i)
{
SchemaClassFieldData_t& field = pFields[i];

if (V_strcmp(field.m_name, "__m_pChainEntity") == 0)
if (V_strcmp(field.m_pszName, "__m_pChainEntity") == 0)
{
return field.m_single_inheritance_offset;
return field.m_nSingleInheritanceOffset;
}
}
} while ((pClassInfo = pClassInfo->GetParent()) != nullptr);
} while ((pClassInfo = pClassInfo->m_pBaseClasses ? pClassInfo->m_pBaseClasses->m_pClass : nullptr) != nullptr);

return 0;
}
Expand Down Expand Up @@ -140,4 +139,4 @@ void SetStateChanged(Z_CBaseEntity* pEntity, int offset)

pEntity->m_lastNetworkChange = gpGlobals->curtime;
pEntity->m_isSteadyState().ClearAll();
};
};
4 changes: 1 addition & 3 deletions src/cs2_sdk/schema.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* =============================================================================
* CS2Fixes
* Copyright (C) 2023 Source2ZE
* Copyright (C) 2023-2024 Source2ZE
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
Expand All @@ -19,8 +19,6 @@

#pragma once

#include "stdint.h"

#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 4005)
Expand Down
17 changes: 6 additions & 11 deletions src/cs2fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "icvar.h"
#include "interface.h"
#include "tier0/dbg.h"
#include "cschemasystem.h"
#include "schemasystem/schemasystem.h"
#include "plat.h"
#include "entitysystem.h"
#include "engine/igameeventsystem.h"
Expand All @@ -53,9 +53,6 @@
#include "entity/ccsplayercontroller.h"
#include "entitylistener.h"

#define VPROF_ENABLED
#include "tier0/vprof.h"

#include "tier0/memdbgon.h"

extern CUtlVector <CCSPlayerController*> coaches;
Expand Down Expand Up @@ -120,7 +117,6 @@ IGameEventManager2 *g_gameEventManager = nullptr;
INetworkGameServer *g_pNetworkGameServer = nullptr;
CGameEntitySystem *g_pEntitySystem = nullptr;
CEntityListener *g_pEntityListener = nullptr;
CSchemaSystem *g_pSchemaSystem2 = nullptr;
CGlobalVars *gpGlobals = nullptr;
CPlayerManager *g_playerManager = nullptr;
IVEngineServer2 *g_pEngineServer2 = nullptr;
Expand All @@ -141,9 +137,9 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
PLUGIN_SAVEVARS();

GET_V_IFACE_CURRENT(GetEngineFactory, g_pEngineServer2, IVEngineServer2, SOURCE2ENGINETOSERVER_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pGameResourceServiceServer, IGameResourceServiceServer, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pGameResourceServiceServer, IGameResourceService, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pCVar, ICvar, CVAR_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pSchemaSystem2, CSchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
GET_V_IFACE_CURRENT(GetEngineFactory, g_pSchemaSystem, ISchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
GET_V_IFACE_ANY(GetServerFactory, g_pSource2Server, ISource2Server, SOURCE2SERVER_INTERFACE_VERSION);
GET_V_IFACE_ANY(GetServerFactory, g_pSource2ServerConfig, ISource2ServerConfig, SOURCE2SERVERCONFIG_INTERFACE_VERSION);
GET_V_IFACE_ANY(GetServerFactory, g_pSource2GameEntities, ISource2GameEntities, SOURCE2GAMEENTITIES_INTERFACE_VERSION);
Expand Down Expand Up @@ -404,7 +400,7 @@ void CS2Fixes::Hook_StartupServer(const GameSessionConfiguration_t& config, ISou

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

Expand Down Expand Up @@ -536,7 +532,7 @@ void CS2Fixes::Hook_ClientDisconnect( CPlayerSlot slot, ENetworkDisconnectionRea

void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick )
{
VPROF_ENTER_SCOPE(__FUNCTION__);

/**
* simulating:
* ***********
Expand Down Expand Up @@ -577,7 +573,6 @@ void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick
}
}

VPROF_EXIT_SCOPE();
}

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

const char *CS2Fixes::GetVersion()
{
return "1.1.2";
return "1.1.3";
}

const char *CS2Fixes::GetDate()
Expand Down
3 changes: 0 additions & 3 deletions src/detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
#include "gameconfig.h"


#define VPROF_ENABLED
#include "tier0/vprof.h"

#include "tier0/memdbgon.h"

extern CGlobalVars *gpGlobals;
Expand Down
3 changes: 0 additions & 3 deletions src/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
#include "ctimer.h"
#include "ctime"

#define VPROF_ENABLED
#include "tier0/vprof.h"

#include "tier0/memdbgon.h"


Expand Down
Loading