diff --git a/core/sourcemm_api.cpp b/core/sourcemm_api.cpp index 2980ab61..fedd22e8 100644 --- a/core/sourcemm_api.cpp +++ b/core/sourcemm_api.cpp @@ -24,6 +24,7 @@ ISmmPluginManager *g_pMMPlugins = NULL; CGlobalVars *gpGlobals = NULL; ICvar *icvar = NULL; IGameEventManager2 *gameevents = NULL; +CallClass *enginePatch = NULL; PLUGIN_EXPOSE(SourceMod, g_SourceMod_Core); diff --git a/core/sourcemm_api.h b/core/sourcemm_api.h index 10a2d346..5acbfbe7 100644 --- a/core/sourcemm_api.h +++ b/core/sourcemm_api.h @@ -51,6 +51,9 @@ extern ICvar *icvar; extern ISmmPluginManager *g_pMMPlugins; extern CGlobalVars *gpGlobals; extern IGameEventManager2 *gameevents; +extern SourceHook::CallClass *enginePatch; + +#define ENGINE_CALL(func) SH_CALL(enginePatch, &IVEngineServer::func) PLUGIN_GLOBALVARS(); diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index f25222fe..375844f8 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -156,6 +156,8 @@ void SourceModBase::StartSourceMod(bool late) SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false); SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, this, &SourceModBase::GameFrame, false); + enginePatch = SH_GET_CALLCLASS(engine); + /* Notify! */ SMGlobalClass *pBase = SMGlobalClass::head; while (pBase) @@ -314,6 +316,12 @@ void SourceModBase::CloseSourceMod() pBase = pBase->m_pGlobalClassNext; } + if (enginePatch) + { + SH_RELEASE_CALLCLASS(enginePatch); + enginePatch = NULL; + } + SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false); SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false); SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, this, &SourceModBase::GameFrame, false);