From cc012e8ef7476c12eecc08ffe1a8c63be0e98f73 Mon Sep 17 00:00:00 2001 From: BotoX Date: Sun, 18 Dec 2016 02:08:25 +0100 Subject: [PATCH] All spawnpoints are CT spawnpoints now, spawnpoints will only be selected from CT spawnpoints. Only TerminateRound(GameCommencing) when both teams were empty. Fix crash on addoutput angle --- extension.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++- gamedata/CSSFixes.txt | 6 ++++++ smsdk_config.h | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/extension.cpp b/extension.cpp index b4cbbd8..6849d86 100644 --- a/extension.cpp +++ b/extension.cpp @@ -57,6 +57,20 @@ static struct SrcdsPatch "xxxxxxxxxxxxxx", (unsigned char *)"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90", 0, 0, 0 + }, + { + "_ZN9CCSPlayer19EntSelectSpawnPointEv", + (unsigned char *)"\x89\x1C\x24\xE8\x00\x00\x00\x00\x83\xF8\x03\x74\x4B", + "xxxx????xxxxx", + (unsigned char *)"\x89\x1C\x24\x90\x90\x90\x90\x90\x90\x90\x90\xEB\x4B", + 0, 0, 0 + }, + { + "_ZN12CCSGameRules18NeededPlayersCheckERb", + (unsigned char *)"\x74\x0E\x8B\x83\x80\x02\x00\x00\x85\xC0\x0F\x85\x9E\x00\x00\x00\xC7\x04\x24\xAC\xF7\x87\x00\xE8\xC2\x82\x91\x00", + "xxxxxxxxxxxxxxxx????????????", + (unsigned char *)"\x0F\x85\xA8\x00\x00\x00\x8B\x83\x80\x02\x00\x00\x85\xC0\x0F\x85\x9A\x00\x00\x00\x90\x90\x90\x90\x90\x90\x90\x90", + 0, 0, 0 } }; @@ -99,6 +113,7 @@ CDetour *detourFindUseEntity = NULL; CDetour *detourCTraceFilterSimple = NULL; CDetour *detourMultiWaitOver = NULL; CDetour *detourRunThinkFunctions = NULL; +CDetour *detourKeyValue = NULL; DETOUR_DECL_MEMBER1(InputTestActivator, void, inputdata_t *, inputdata) { @@ -110,7 +125,7 @@ DETOUR_DECL_MEMBER1(InputTestActivator, void, inputdata_t *, inputdata) DETOUR_DECL_MEMBER1(PostConstructor, void, const char *, szClassname) { - if(strncmp(szClassname, "info_player_", 12) == 0) + if(strncasecmp(szClassname, "info_player_", 12) == 0) { CBaseEntity *pEntity = (CBaseEntity *)this; @@ -118,11 +133,26 @@ DETOUR_DECL_MEMBER1(PostConstructor, void, const char *, szClassname) typedescription_t *td = gamehelpers->FindInDataMap(pMap, "m_iEFlags"); *(uint32 *)((intptr_t)pEntity + td->fieldOffset[TD_OFFSET_NORMAL]) |= (1<<9); // EFL_SERVER_ONLY + szClassname = "info_player_counterterrorist"; } DETOUR_MEMBER_CALL(PostConstructor)(szClassname); } +DETOUR_DECL_MEMBER2(KeyValue, bool, const char *, szKeyName, const char *, szValue) +{ + if(strcasecmp(szKeyName, "angle") == 0) + szKeyName = "angles"; + + else if(strcasecmp(szKeyName, "classname") == 0 && + strncasecmp(szValue, "info_player_", 12) == 0) + { + szValue = "info_player_counterterrorist"; + } + + return DETOUR_MEMBER_CALL(KeyValue)(szKeyName, szValue); +} + volatile bool gv_InFindUseEntity = false; DETOUR_DECL_MEMBER0(FindUseEntity, CBaseEntity *) { @@ -226,12 +256,21 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late) return false; } + detourKeyValue = DETOUR_CREATE_MEMBER(KeyValue, "CBaseEntity_KeyValue"); + if(detourKeyValue == NULL) + { + snprintf(error, maxlength, "Could not create detour for CBaseEntity_KeyValue"); + SDK_OnUnload(); + return false; + } + detourInputTestActivator->EnableDetour(); detourPostConstructor->EnableDetour(); detourFindUseEntity->EnableDetour(); detourCTraceFilterSimple->EnableDetour(); detourMultiWaitOver->EnableDetour(); detourRunThinkFunctions->EnableDetour(); + detourKeyValue->EnableDetour(); // Find VTable for CTraceFilterNoNPCsOrPlayer uintptr_t pCTraceFilterNoNPCsOrPlayer; @@ -333,6 +372,12 @@ void CSSFixes::SDK_OnUnload() detourRunThinkFunctions = NULL; } + if(detourKeyValue != NULL) + { + detourKeyValue->Destroy(); + detourKeyValue = NULL; + } + if(g_pOnRunThinkFunctions != NULL) { forwards->ReleaseForward(g_pOnRunThinkFunctions); diff --git a/gamedata/CSSFixes.txt b/gamedata/CSSFixes.txt index 1f215b4..4738d1b 100644 --- a/gamedata/CSSFixes.txt +++ b/gamedata/CSSFixes.txt @@ -45,6 +45,12 @@ "library" "server" "linux" "@_Z25Physics_RunThinkFunctionsb" } + + "CBaseEntity_KeyValue" + { + "library" "server" + "linux" "@_ZN11CBaseEntity8KeyValueEPKcS1_" + } } } } diff --git a/smsdk_config.h b/smsdk_config.h index 532a262..cb756eb 100644 --- a/smsdk_config.h +++ b/smsdk_config.h @@ -40,7 +40,7 @@ /* Basic information exposed publicly */ #define SMEXT_CONF_NAME "CSSFixes" #define SMEXT_CONF_DESCRIPTION "Patches bugs in the CSS server binary." -#define SMEXT_CONF_VERSION "1.3" +#define SMEXT_CONF_VERSION "1.4" #define SMEXT_CONF_AUTHOR "BotoX" #define SMEXT_CONF_URL "" #define SMEXT_CONF_LOGTAG "CSSFIXES"