Cleanly remove all hooks on extension unload

Allows to e.g. reload sdktools during runtime without crashing. Useful for fast development cycles.
This commit is contained in:
Peace-Maker
2020-12-16 15:52:48 +01:00
committed by peace-maker
parent e59fd9de96
commit ba8753836e
8 changed files with 109 additions and 14 deletions
+22
View File
@@ -167,6 +167,28 @@ void TF2Tools::SDK_OnUnload()
SH_REMOVE_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_STATIC(OnServerActivate), true);
g_HolidayManager.OnSDKUnload();
m_GameEventManager->RemoveListener(this);
if (m_CritDetoursEnabled)
{
g_CritManager.Disable();
m_CritDetoursEnabled = false;
}
if (m_CondChecksEnabled)
{
g_CondMgr.Shutdown();
m_CondChecksEnabled = false;
}
if (m_RulesDetoursEnabled)
{
RemoveRulesDetours();
m_RulesDetoursEnabled = false;
}
if (m_TeleportDetourEnabled)
{
RemoveTeleporterDetour();
m_TeleportDetourEnabled = false;
}
g_RegNatives.UnregisterAll();
gameconfs->CloseGameConfigFile(g_pGameConf);