Replace the UTIL_DecalTrace memory patches with a detour to make it easier to maintain
This commit is contained in:
+26
-28
@@ -290,34 +290,6 @@ static struct SrcdsPatch
|
||||
"x?xx",
|
||||
(unsigned char *)"\x90\x90\x8B\x09",
|
||||
"bin/dedicated_srv.so"
|
||||
},
|
||||
// 17: void CBaseGrenade::Explode( trace_t *pTrace, int bitsDamageType ) NOP out UTIL_DecalTrace( pTrace, "Scorch" ); to stop grenades from causing
|
||||
// "Too many indices for index buffer. Tell a programmer". Grenades cause decals on too many faces for the client to handle.
|
||||
{
|
||||
"_ZN12CBaseGrenade7ExplodeEP10CGameTracei",
|
||||
(unsigned char *)"\xE8\xEA\x8E\x21\x00",
|
||||
"xxxxx",
|
||||
(unsigned char *)"\x90\x90\x90\x90\x90",
|
||||
"cstrike/bin/server_srv.so"
|
||||
},
|
||||
|
||||
// 18: void CPlantedC4::Explode( trace_t *pTrace, int bitsDamageType ) NOP out UTIL_DecalTrace( pTrace, "Scorch" ); same reason as 17.
|
||||
{
|
||||
"_ZN10CPlantedC47ExplodeEP10CGameTracei",
|
||||
(unsigned char *)"\xE8\x72\xBE\xEB\xFF",
|
||||
"xxxxx",
|
||||
(unsigned char *)"\x90\x90\x90\x90\x90",
|
||||
"cstrike/bin/server_srv.so"
|
||||
},
|
||||
// 19: void CEnvExplosion::InputExplode( inputdata_t &inputdata ) NOP out UTIL_DecalTrace( &tr, "Scorch" ); same reason as 17.
|
||||
{
|
||||
"_ZN13CEnvExplosion12InputExplodeER11inputdata_t",
|
||||
(unsigned char *)"\xE8\xEA\x2A\x1A\x00",
|
||||
"xxxxx",
|
||||
(unsigned char *)"\x90\x90\x90\x90\x90",
|
||||
"cstrike/bin/server_srv.so",
|
||||
0x800,
|
||||
1
|
||||
}
|
||||
};
|
||||
|
||||
@@ -370,6 +342,8 @@ CDetour *g_pDetour_CTraceFilterSimple = NULL;
|
||||
CDetour *g_pDetour_KeyValue = NULL;
|
||||
CDetour *g_pDetour_FireBullets = NULL;
|
||||
CDetour *g_pDetour_SwingOrStab = NULL;
|
||||
CDetour *g_pDetour_UTIL_DecalTrace = NULL;
|
||||
|
||||
int g_SH_SkipTwoEntitiesShouldHitEntity = 0;
|
||||
int g_SH_SimpleShouldHitEntity = 0;
|
||||
|
||||
@@ -575,6 +549,15 @@ DETOUR_DECL_MEMBER3(DETOUR_CTraceFilterSimple, void, const IHandleEntity *, pass
|
||||
*(uintptr_t *)this = g_CTraceFilterNoNPCsOrPlayer;
|
||||
}
|
||||
|
||||
DETOUR_DECL_STATIC2(DETOUR_UTIL_DecalTrace, void, void *, pTrace, char *, decalName)
|
||||
{
|
||||
// to stop grenades from causing "Too many indices for index buffer. Tell a programmer". Grenades cause decals on too many faces for the client to handle.
|
||||
if (strcmp(decalName, "Scorch") == 0)
|
||||
return;
|
||||
|
||||
DETOUR_STATIC_CALL(DETOUR_UTIL_DecalTrace)(pTrace, decalName);
|
||||
}
|
||||
|
||||
/* Make bullets ignore teammates */
|
||||
char *g_pPhysboxToClientMap = NULL;
|
||||
bool g_InFireBullets = false;
|
||||
@@ -801,6 +784,14 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
return false;
|
||||
}
|
||||
|
||||
g_pDetour_UTIL_DecalTrace = DETOUR_CREATE_STATIC(DETOUR_UTIL_DecalTrace, "UTIL_DecalTrace");
|
||||
if (g_pDetour_UTIL_DecalTrace == NULL)
|
||||
{
|
||||
snprintf(error, maxlength, "Could not create detour for UTIL_DecalTrace");
|
||||
SDK_OnUnload();
|
||||
return false;
|
||||
}
|
||||
|
||||
g_pDetour_InputTestActivator->EnableDetour();
|
||||
g_pDetour_PostConstructor->EnableDetour();
|
||||
g_pDetour_CreateEntityByName->EnableDetour();
|
||||
@@ -810,6 +801,7 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
g_pDetour_KeyValue->EnableDetour();
|
||||
g_pDetour_FireBullets->EnableDetour();
|
||||
g_pDetour_SwingOrStab->EnableDetour();
|
||||
g_pDetour_UTIL_DecalTrace->EnableDetour();
|
||||
|
||||
// Find VTable for CTraceFilterSkipTwoEntities
|
||||
uintptr_t pCTraceFilterSkipTwoEntities;
|
||||
@@ -1012,6 +1004,12 @@ void CSSFixes::SDK_OnUnload()
|
||||
g_pDetour_SwingOrStab = NULL;
|
||||
}
|
||||
|
||||
if (g_pDetour_UTIL_DecalTrace != NULL)
|
||||
{
|
||||
g_pDetour_UTIL_DecalTrace->Destroy();
|
||||
g_pDetour_UTIL_DecalTrace = NULL;
|
||||
}
|
||||
|
||||
if(g_SH_SkipTwoEntitiesShouldHitEntity)
|
||||
SH_REMOVE_HOOK_ID(g_SH_SkipTwoEntitiesShouldHitEntity);
|
||||
|
||||
|
||||
@@ -81,6 +81,12 @@
|
||||
"library" "server"
|
||||
"linux" "@_ZN6CKnife11SwingOrStabEb"
|
||||
}
|
||||
|
||||
"UTIL_DecalTrace"
|
||||
{
|
||||
"library" "server"
|
||||
"linux" "@_Z15UTIL_DecalTraceP10CGameTracePKc"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user