From b36738affb3f8adcda414b7097aad596c4795a29 Mon Sep 17 00:00:00 2001 From: huoji Date: Tue, 10 Oct 2023 20:10:42 +0800 Subject: [PATCH] fix up server crash --- csgo2/hooks.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/csgo2/hooks.cpp b/csgo2/hooks.cpp index 04f685d..6950912 100644 --- a/csgo2/hooks.cpp +++ b/csgo2/hooks.cpp @@ -56,22 +56,29 @@ void __fastcall hook_GameFrame(void* rcx, bool simulating, bool bFirstTick, * true | game is ticking * false | game is not ticking */ - if (simulating && global::HasTicked) { - global::m_flUniversalTime += - global::GlobalVars->curtime - global::m_flLastTickedTime; - } else { - global::m_flUniversalTime += global::GlobalVars->interval_per_tick; + if (global::GlobalVars == nullptr) { + global::GlobalVars = GetGameGlobals(); } + if (global::GlobalVars != nullptr) { + if (simulating && global::HasTicked) { + global::m_flUniversalTime += + global::GlobalVars->curtime - global::m_flLastTickedTime; + } + else { + global::m_flUniversalTime += global::GlobalVars->interval_per_tick; + } - global::m_flLastTickedTime = global::GlobalVars->curtime; - global::HasTicked = true; + global::m_flLastTickedTime = global::GlobalVars->curtime; + global::HasTicked = true; - if (global::EntitySystem == nullptr) { - global::EntitySystem = CGameEntitySystem::GetInstance(); + if (global::EntitySystem == nullptr) { + global::EntitySystem = CGameEntitySystem::GetInstance(); + } + + GameTimer::ExcuteTimers(); + GameTickRunTime::ExcuteTickFunctions(); } - - GameTimer::ExcuteTimers(); - GameTickRunTime::ExcuteTickFunctions(); + return origin_GameFrame(rcx, simulating, bFirstTick, bLastTick); } void __fastcall hook_StartServer(void* rcx,