Fix TF2_OnIsHolidayActive forward not getting called after map change (#1752)
* Fix TF2_IsHolidayActive forward not getting called after map change * Rename function to Unhook
This commit is contained in:
parent
a877a4475b
commit
a1ad9e1acf
@ -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)
|
||||
|
@ -57,7 +57,7 @@ private:
|
||||
bool IsHookEnabled() const { return m_iHookID != 0; }
|
||||
void *GetGameRules();
|
||||
void HookIfNecessary();
|
||||
void UnhookIfNecessary();
|
||||
void Unhook();
|
||||
|
||||
private:
|
||||
int m_iHookID;
|
||||
|
Loading…
Reference in New Issue
Block a user