fix up server crash

This commit is contained in:
huoji
2023-10-10 20:10:42 +08:00
parent d55d0f515b
commit b36738affb

View File

@@ -56,22 +56,29 @@ void __fastcall hook_GameFrame(void* rcx, bool simulating, bool bFirstTick,
* true | game is ticking * true | game is ticking
* false | game is not ticking * false | game is not ticking
*/ */
if (simulating && global::HasTicked) { if (global::GlobalVars == nullptr) {
global::m_flUniversalTime += global::GlobalVars = GetGameGlobals();
global::GlobalVars->curtime - global::m_flLastTickedTime;
} else {
global::m_flUniversalTime += global::GlobalVars->interval_per_tick;
} }
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::m_flLastTickedTime = global::GlobalVars->curtime;
global::HasTicked = true; global::HasTicked = true;
if (global::EntitySystem == nullptr) { if (global::EntitySystem == nullptr) {
global::EntitySystem = CGameEntitySystem::GetInstance(); global::EntitySystem = CGameEntitySystem::GetInstance();
}
GameTimer::ExcuteTimers();
GameTickRunTime::ExcuteTickFunctions();
} }
GameTimer::ExcuteTimers();
GameTickRunTime::ExcuteTickFunctions();
return origin_GameFrame(rcx, simulating, bFirstTick, bLastTick); return origin_GameFrame(rcx, simulating, bFirstTick, bLastTick);
} }
void __fastcall hook_StartServer(void* rcx, void __fastcall hook_StartServer(void* rcx,