Add forwards for Physics_RunThinkFunctions

This commit is contained in:
BotoX 2016-12-16 23:45:05 +01:00
parent 04b749e985
commit 7f56360ee9
4 changed files with 93 additions and 6 deletions

View File

@ -90,11 +90,15 @@ SMEXT_LINK(&g_Interface);
IGameConfig *g_pGameConf = NULL;
IForward *g_pOnRunThinkFunctions = NULL;
IForward *g_pOnRunThinkFunctionsPost = NULL;
CDetour *detourInputTestActivator = NULL;
CDetour *detourPostConstructor = NULL;
CDetour *detourFindUseEntity = NULL;
CDetour *detourCTraceFilterSimple = NULL;
CDetour *detourMultiWaitOver = NULL;
CDetour *detourRunThinkFunctions = NULL;
DETOUR_DECL_MEMBER1(InputTestActivator, void, inputdata_t *, inputdata)
{
@ -150,6 +154,17 @@ DETOUR_DECL_MEMBER0(MultiWaitOver, void)
DETOUR_MEMBER_CALL(MultiWaitOver)();
}
DETOUR_DECL_STATIC1(RunThinkFunctions, void, bool, simulating)
{
g_pOnRunThinkFunctions->PushCell(simulating);
g_pOnRunThinkFunctions->Execute();
DETOUR_STATIC_CALL(RunThinkFunctions)(simulating);
g_pOnRunThinkFunctionsPost->PushCell(simulating);
g_pOnRunThinkFunctionsPost->Execute();
}
bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
char conf_error[255] = "";
@ -167,41 +182,56 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
if(detourInputTestActivator == NULL)
{
snprintf(error, maxlength, "Could not create detour for CBaseFilter_InputTestActivator");
SDK_OnUnload();
return false;
}
detourInputTestActivator->EnableDetour();
detourPostConstructor = DETOUR_CREATE_MEMBER(PostConstructor, "CBaseEntity_PostConstructor");
if(detourPostConstructor == NULL)
{
snprintf(error, maxlength, "Could not create detour for CBaseEntity_PostConstructor");
SDK_OnUnload();
return false;
}
detourPostConstructor->EnableDetour();
detourFindUseEntity = DETOUR_CREATE_MEMBER(FindUseEntity, "CBasePlayer_FindUseEntity");
if(detourFindUseEntity == NULL)
{
snprintf(error, maxlength, "Could not create detour for CBasePlayer_FindUseEntity");
SDK_OnUnload();
return false;
}
detourFindUseEntity->EnableDetour();
detourCTraceFilterSimple = DETOUR_CREATE_MEMBER(CTraceFilterSimple, "CTraceFilterSimple_CTraceFilterSimple");
if(detourCTraceFilterSimple == NULL)
{
snprintf(error, maxlength, "Could not create detour for CTraceFilterSimple_CTraceFilterSimple");
SDK_OnUnload();
return false;
}
detourCTraceFilterSimple->EnableDetour();
detourMultiWaitOver = DETOUR_CREATE_MEMBER(MultiWaitOver, "CTriggerMultiple_MultiWaitOver");
if(detourMultiWaitOver == NULL)
{
snprintf(error, maxlength, "Could not create detour for CTriggerMultiple_MultiWaitOver");
SDK_OnUnload();
return false;
}
detourRunThinkFunctions = DETOUR_CREATE_STATIC(RunThinkFunctions, "Physics_RunThinkFunctions");
if(detourRunThinkFunctions == NULL)
{
snprintf(error, maxlength, "Could not create detour for Physics_RunThinkFunctions");
SDK_OnUnload();
return false;
}
detourInputTestActivator->EnableDetour();
detourPostConstructor->EnableDetour();
detourFindUseEntity->EnableDetour();
detourCTraceFilterSimple->EnableDetour();
detourMultiWaitOver->EnableDetour();
detourRunThinkFunctions->EnableDetour();
// Find VTable for CTraceFilterNoNPCsOrPlayer
uintptr_t pCTraceFilterNoNPCsOrPlayer;
@ -218,6 +248,7 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
if(!pServerSo)
{
snprintf(error, maxlength, "Could not dlopen server_srv.so");
SDK_OnUnload();
return false;
}
@ -258,6 +289,9 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
dlclose(pServerSo);
g_pOnRunThinkFunctions = forwards->CreateForward("OnRunThinkFunctions", ET_Ignore, 1, NULL, Param_Cell);
g_pOnRunThinkFunctionsPost = forwards->CreateForward("OnRunThinkFunctionsPost", ET_Ignore, 1, NULL, Param_Cell);
return true;
}
@ -293,6 +327,24 @@ void CSSFixes::SDK_OnUnload()
detourMultiWaitOver = NULL;
}
if(detourRunThinkFunctions != NULL)
{
detourRunThinkFunctions->Destroy();
detourRunThinkFunctions = NULL;
}
if(g_pOnRunThinkFunctions != NULL)
{
forwards->ReleaseForward(g_pOnRunThinkFunctions);
g_pOnRunThinkFunctions = NULL;
}
if(g_pOnRunThinkFunctionsPost != NULL)
{
forwards->ReleaseForward(g_pOnRunThinkFunctionsPost);
g_pOnRunThinkFunctionsPost = NULL;
}
gameconfs->CloseGameConfigFile(g_pGameConf);
// Revert all applied patches

View File

@ -39,6 +39,12 @@
"library" "server"
"linux" "@_ZN16CTriggerMultiple13MultiWaitOverEv"
}
"Physics_RunThinkFunctions"
{
"library" "server"
"linux" "@_Z25Physics_RunThinkFunctionsb"
}
}
}
}

29
include/CSSFixes.inc Normal file
View File

@ -0,0 +1,29 @@
#if defined _cssfixes_included
#endinput
#endif
#define _cssfixes_included
forward void OnRunThinkFunctions(bool simulating);
forward void OnRunThinkFunctionsPost(bool simulating);
public Extension:__ext_CSSFixes =
{
name = "CSSFixes",
file = "CSSFixes.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public __ext_CSSFixes_SetNTVOptional()
{
}
#endif

View File

@ -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.2"
#define SMEXT_CONF_VERSION "1.3"
#define SMEXT_CONF_AUTHOR "BotoX"
#define SMEXT_CONF_URL ""
#define SMEXT_CONF_LOGTAG "CSSFIXES"
@ -59,7 +59,7 @@
#define SMEXT_CONF_METAMOD
/** Enable interfaces you want to use here by uncommenting lines */
//#define SMEXT_ENABLE_FORWARDSYS
#define SMEXT_ENABLE_FORWARDSYS
//#define SMEXT_ENABLE_HANDLESYS
//#define SMEXT_ENABLE_PLAYERHELPERS
//#define SMEXT_ENABLE_DBMANAGER