diff --git a/extensions/tf2/holiday.cpp b/extensions/tf2/holiday.cpp index 714858cf..282b5ea9 100644 --- a/extensions/tf2/holiday.cpp +++ b/extensions/tf2/holiday.cpp @@ -55,7 +55,7 @@ void HolidayManager::OnSDKLoad(bool bLate) void HolidayManager::OnSDKUnload() { - UnhookIfNecessary(); + Unhook(); SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &HolidayManager::Hook_LevelShutdown), false); plsys->RemovePluginsListener(this); @@ -72,7 +72,7 @@ void HolidayManager::OnServerActivated() void HolidayManager::Hook_LevelShutdown() { // GameRules is going away momentarily. Unhook before it does. - UnhookIfNecessary(); + Unhook(); m_bInMap = false; } @@ -112,16 +112,12 @@ void HolidayManager::HookIfNecessary() m_iHookID = SH_ADD_MANUALHOOK(IsHolidayActive, pGameRules, SH_MEMBER(this, &HolidayManager::Hook_IsHolidayActive), false); } -void HolidayManager::UnhookIfNecessary() +void HolidayManager::Unhook() { // Not hooked if (!m_iHookID) return; - // We're still wanted - if (m_isHolidayForward->GetFunctionCount() > 0) - return; - SH_REMOVE_HOOK_ID(m_iHookID); m_iHookID = 0; } @@ -165,7 +161,11 @@ void HolidayManager::OnPluginLoaded(IPlugin *plugin) void HolidayManager::OnPluginUnloaded(IPlugin *plugin) { - UnhookIfNecessary(); + // We're still wanted + if (m_isHolidayForward->GetFunctionCount() > 0) + return; + + Unhook(); } bool HolidayManager::Hook_IsHolidayActive(int holiday) diff --git a/extensions/tf2/holiday.h b/extensions/tf2/holiday.h index 7457b7d6..f0e357dc 100644 --- a/extensions/tf2/holiday.h +++ b/extensions/tf2/holiday.h @@ -57,7 +57,7 @@ private: bool IsHookEnabled() const { return m_iHookID != 0; } void *GetGameRules(); void HookIfNecessary(); - void UnhookIfNecessary(); + void Unhook(); private: int m_iHookID;