From 281791ed9ca9a7f48f45b47b77729088bc7efbc5 Mon Sep 17 00:00:00 2001 From: marqdevx Date: Fri, 12 Apr 2024 02:12:54 +0200 Subject: [PATCH 1/7] Bump version --- src/cs2fixes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cs2fixes.cpp b/src/cs2fixes.cpp index 8d34617d..aa94ef62 100644 --- a/src/cs2fixes.cpp +++ b/src/cs2fixes.cpp @@ -616,7 +616,7 @@ const char *CS2Fixes::GetLicense() const char *CS2Fixes::GetVersion() { - return "1.1.2"; + return "1.1.3"; } const char *CS2Fixes::GetDate() From 49899f379b224d1fae9dc766051ce105d5ecdc67 Mon Sep 17 00:00:00 2001 From: marqdevx Date: Mon, 15 Apr 2024 23:32:22 +0200 Subject: [PATCH 2/7] Add downloads tracker --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1dc711e0..d226db3f 100644 --- a/README.md +++ b/README.md @@ -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/ From f783a165a34c4086231d2d39f7124a360137c8e7 Mon Sep 17 00:00:00 2001 From: marqdevx Date: Sat, 16 Mar 2024 23:45:58 +0100 Subject: [PATCH 3/7] Add `.color` --- src/commands.cpp | 12 ++++++++++++ src/cs2_sdk/entity/ccsplayercontroller.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/commands.cpp b/src/commands.cpp index ec2470c3..42d07940 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -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; diff --git a/src/cs2_sdk/entity/ccsplayercontroller.h b/src/cs2_sdk/entity/ccsplayercontroller.h index 8f71f256..b3e18036 100644 --- a/src/cs2_sdk/entity/ccsplayercontroller.h +++ b/src/cs2_sdk/entity/ccsplayercontroller.h @@ -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, m_hPlayerPawn); From 2f50a9121b83e5e0f9ed08c28bab046fbc410d19 Mon Sep 17 00:00:00 2001 From: marqdevx Date: Fri, 3 May 2024 13:33:53 +0200 Subject: [PATCH 4/7] Update sdk and update crash --- sdk | 2 +- src/cs2_sdk/schema.cpp | 37 ++++++++++++------------ src/cs2_sdk/schema.h | 4 +-- src/cs2fixes.cpp | 15 ++++------ src/detours.cpp | 3 -- src/playermanager.cpp | 3 -- src/recipientfilters.h | 64 +++++++++++++++++++++++++++++------------- 7 files changed, 70 insertions(+), 58 deletions(-) diff --git a/sdk b/sdk index 43bfe744..3fc8d0fa 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 43bfe744a1af968664f5712e5b1290d48eee42b8 +Subproject commit 3fc8d0faf647829d293a7d1928539a2f1f0d2b90 diff --git a/src/cs2_sdk/schema.cpp b/src/cs2_sdk/schema.cpp index b004aad2..72f60f79 100644 --- a/src/cs2_sdk/schema.cpp +++ b/src/cs2_sdk/schema.cpp @@ -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 @@ -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; @@ -35,10 +34,10 @@ using SchemaTableMap_t = CUtlMap; 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; } @@ -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) { @@ -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); @@ -75,10 +74,10 @@ 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; @@ -86,27 +85,27 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* cla 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; } @@ -140,4 +139,4 @@ void SetStateChanged(Z_CBaseEntity* pEntity, int offset) pEntity->m_lastNetworkChange = gpGlobals->curtime; pEntity->m_isSteadyState().ClearAll(); -}; +}; \ No newline at end of file diff --git a/src/cs2_sdk/schema.h b/src/cs2_sdk/schema.h index dd5a2a47..c25af2e0 100644 --- a/src/cs2_sdk/schema.h +++ b/src/cs2_sdk/schema.h @@ -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 @@ -19,8 +19,6 @@ #pragma once -#include "stdint.h" - #ifdef _WIN32 #pragma warning(push) #pragma warning(disable : 4005) diff --git a/src/cs2fixes.cpp b/src/cs2fixes.cpp index aa94ef62..6412bc34 100644 --- a/src/cs2fixes.cpp +++ b/src/cs2fixes.cpp @@ -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" @@ -53,9 +53,6 @@ #include "entity/ccsplayercontroller.h" #include "entitylistener.h" -#define VPROF_ENABLED -#include "tier0/vprof.h" - #include "tier0/memdbgon.h" extern CUtlVector coaches; @@ -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; @@ -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); @@ -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); */ @@ -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: * *********** @@ -577,7 +573,6 @@ void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick } } - VPROF_EXIT_SCOPE(); } // Potentially might not work diff --git a/src/detours.cpp b/src/detours.cpp index fd1ba0cb..843bcdf1 100644 --- a/src/detours.cpp +++ b/src/detours.cpp @@ -38,9 +38,6 @@ #include "gameconfig.h" -#define VPROF_ENABLED -#include "tier0/vprof.h" - #include "tier0/memdbgon.h" extern CGlobalVars *gpGlobals; diff --git a/src/playermanager.cpp b/src/playermanager.cpp index c9113032..4dece9f3 100644 --- a/src/playermanager.cpp +++ b/src/playermanager.cpp @@ -27,9 +27,6 @@ #include "ctimer.h" #include "ctime" -#define VPROF_ENABLED -#include "tier0/vprof.h" - #include "tier0/memdbgon.h" diff --git a/src/recipientfilters.h b/src/recipientfilters.h index a0165a3c..b3ba9b85 100644 --- a/src/recipientfilters.h +++ b/src/recipientfilters.h @@ -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 @@ -19,35 +19,41 @@ #pragma once #include "irecipientfilter.h" +#include "playermanager.h" +// Simple filter for when only 1 recipient is needed class CSingleRecipientFilter : public IRecipientFilter { public: - CSingleRecipientFilter(int iRecipient, bool bReliable = true, bool bInitMessage = false) : - m_iRecipient(iRecipient), m_bReliable(bReliable), m_bInitMessage(bInitMessage) {} + CSingleRecipientFilter(CPlayerSlot iRecipient, NetChannelBufType_t nBufType = BUF_RELIABLE, bool bInitMessage = false) : + m_iRecipient(iRecipient), m_nBufType(nBufType), m_bInitMessage(bInitMessage) {} ~CSingleRecipientFilter() override {} - bool IsReliable(void) const override { return m_bReliable; } - + NetChannelBufType_t GetNetworkBufType(void) const override { return m_nBufType; } bool IsInitMessage(void) const override { return m_bInitMessage; } - int GetRecipientCount(void) const override { return 1; } - - CPlayerSlot GetRecipientIndex(int slot) const override { return CPlayerSlot(m_iRecipient); } + CPlayerSlot GetRecipientIndex(int slot) const override { return m_iRecipient; } private: - bool m_bReliable; + CPlayerSlot m_iRecipient; + NetChannelBufType_t m_nBufType; bool m_bInitMessage; - int m_iRecipient; }; -class CCopyRecipientFilter : public IRecipientFilter + +class CRecipientFilter : public IRecipientFilter { public: - CCopyRecipientFilter(IRecipientFilter *source, int iExcept) + CRecipientFilter() { - m_bReliable = source->IsReliable(); + m_nBufType = BUF_RELIABLE; + m_bInitMessage = false; + } + + CRecipientFilter(IRecipientFilter *source, int iExcept = -1) + { + m_nBufType = source->GetNetworkBufType(); m_bInitMessage = source->IsInitMessage(); m_Recipients.RemoveAll(); @@ -58,12 +64,10 @@ class CCopyRecipientFilter : public IRecipientFilter } } - ~CCopyRecipientFilter() override {} - - bool IsReliable(void) const override { return m_bReliable; } + ~CRecipientFilter() override {} + NetChannelBufType_t GetNetworkBufType(void) const override { return m_nBufType; } bool IsInitMessage(void) const override { return m_bInitMessage; } - int GetRecipientCount(void) const override { return m_Recipients.Count(); } CPlayerSlot GetRecipientIndex(int slot) const override @@ -74,8 +78,30 @@ class CCopyRecipientFilter : public IRecipientFilter return m_Recipients[slot]; } + void AddAllPlayers(void) + { + m_Recipients.RemoveAll(); + + for (int i = 0; i < MAXPLAYERS; i++) + { + if (!g_playerManager->GetPlayer(i)) + continue; + + AddRecipient(i); + } + } + + void AddRecipient(CPlayerSlot slot) + { + // Don't add if it already exists + if (m_Recipients.Find(slot) != m_Recipients.InvalidIndex()) + return; + + m_Recipients.AddToTail(slot); + } + private: - bool m_bReliable; + NetChannelBufType_t m_nBufType; bool m_bInitMessage; - CUtlVectorFixed m_Recipients; + CUtlVectorFixed m_Recipients; }; \ No newline at end of file From 34c66c29fbbcbedb0b3eed6be4c8285577be7c08 Mon Sep 17 00:00:00 2001 From: marqdevx Date: Fri, 3 May 2024 13:34:05 +0200 Subject: [PATCH 5/7] Update offsets --- gamedata/cs2fixes.games.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gamedata/cs2fixes.games.txt b/gamedata/cs2fixes.games.txt index 1611a05b..7d27ffc8 100644 --- a/gamedata/cs2fixes.games.txt +++ b/gamedata/cs2fixes.games.txt @@ -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 @@ -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" @@ -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" From 302814002879779803b24ab1a6daedcbaf43f1ae Mon Sep 17 00:00:00 2001 From: marqdevx Date: Fri, 3 May 2024 13:39:04 +0200 Subject: [PATCH 6/7] Add .color info --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d226db3f..aac61b71 100644 --- a/README.md +++ b/README.md @@ -48,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 `: ban a player From fb680a8f0c4ebe1f1b3cf188c27b14edf8a313f6 Mon Sep 17 00:00:00 2001 From: marqdevx Date: Fri, 3 May 2024 13:46:25 +0200 Subject: [PATCH 7/7] Update minimum metamod version requirement --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aac61b71..95dddc4f 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ You can enable/disable the features of the plugin by changing the values at `