From f9309c83d28d955a478fd804374ebfade2b34453 Mon Sep 17 00:00:00 2001 From: Nick Hastings <nshastings@gmail.com> Date: Sat, 23 Oct 2021 12:16:48 -0400 Subject: [PATCH] Don't cache replay_enable value when evaling whether to use FileExists hook. Speculative fix for #1581 --- extensions/sdktools/hooks.cpp | 9 ++++----- extensions/sdktools/hooks.h | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/extensions/sdktools/hooks.cpp b/extensions/sdktools/hooks.cpp index 49f62fc6..ddfa2919 100644 --- a/extensions/sdktools/hooks.cpp +++ b/extensions/sdktools/hooks.cpp @@ -65,6 +65,9 @@ SH_DECL_HOOK2_void(INetChannel, ProcessPacket, SH_NOATTRIB, 0, struct netpacket_ SourceHook::CallClass<IBaseFileSystem> *basefilesystemPatch = NULL; CHookManager::CHookManager() +#if SOURCE_ENGINE == SE_TF2 + : replay_enabled("replay_enabled", false) +#endif { m_usercmdsFwd = NULL; m_usercmdsPostFwd = NULL; @@ -188,10 +191,6 @@ void CHookManager::Shutdown() void CHookManager::OnMapStart() { m_bFSTranHookWarned = false; -#if SOURCE_ENGINE == SE_TF2 - static ConVarRef replay_enable("replay_enable"); - m_bReplayEnabled = replay_enable.GetBool(); -#endif } void CHookManager::OnClientConnect(int client) @@ -410,7 +409,7 @@ void CHookManager::NetChannelHook(int client) /* Initial Hook */ #if SOURCE_ENGINE == SE_TF2 - if (m_bReplayEnabled) + if (replay_enabled.GetBool()) { if (!m_bFSTranHookWarned) { diff --git a/extensions/sdktools/hooks.h b/extensions/sdktools/hooks.h index 3854405d..b46e3666 100644 --- a/extensions/sdktools/hooks.h +++ b/extensions/sdktools/hooks.h @@ -89,7 +89,9 @@ private: #endif INetChannel *m_pActiveNetChannel; bool m_bFSTranHookWarned = false; - bool m_bReplayEnabled = false; +#if SOURCE_ENGINE == SE_TF2 + ConVarRef replay_enabled; +#endif }; extern CHookManager g_Hooks;