From 2e697c6427f3ea8f26f98640ae93147d1fa9d6df Mon Sep 17 00:00:00 2001 From: stephanie sappho lenzo Date: Mon, 3 Jul 2023 04:33:34 -0400 Subject: [PATCH 1/2] Run timers every tick instead of arbitrarily on 100ms thinks, adding a significantly higher amount of precision --- core/TimerSys.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/TimerSys.cpp b/core/TimerSys.cpp index 2084b153e1..8a2987f86d 100644 --- a/core/TimerSys.cpp +++ b/core/TimerSys.cpp @@ -234,13 +234,15 @@ void TimerSystem::GameFrame(bool simulating) m_fLastTickedTime = gpGlobals->curtime; m_bHasMapTickedYet = true; + RunFrame(); +/* if (g_fUniversalTime >= g_fTimerThink) { RunFrame(); g_fTimerThink = CalcNextThink(g_fTimerThink, TIMER_MIN_ACCURACY); } - +*/ RunFrameHooks(simulating); if (m_pOnGameFrame->GetFunctionCount()) From 01f6cb35c26c6aad62c252aa23c891ff1b77459c Mon Sep 17 00:00:00 2001 From: stephanie sappho lenzo Date: Wed, 26 Jul 2023 05:52:25 -0400 Subject: [PATCH 2/2] undo force push --- core/TimerSys.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/TimerSys.cpp b/core/TimerSys.cpp index 8a2987f86d..771ba9ca17 100644 --- a/core/TimerSys.cpp +++ b/core/TimerSys.cpp @@ -36,8 +36,6 @@ #include "ConVarManager.h" #include "logic_bridge.h" -#define TIMER_MIN_ACCURACY 0.1 - TimerSystem g_Timers; double g_fUniversalTime = 0.0f; float g_fGameStartTime = 0.0f; /* Game game start time, non-universal */ @@ -146,7 +144,7 @@ class DefaultMapTimer : */ inline double CalcNextThink(double last, float interval) { - if (g_fUniversalTime - last - interval <= TIMER_MIN_ACCURACY) + if (g_fUniversalTime - last - interval <= gpGlobals->interval_per_tick) { return last + interval; } @@ -234,15 +232,13 @@ void TimerSystem::GameFrame(bool simulating) m_fLastTickedTime = gpGlobals->curtime; m_bHasMapTickedYet = true; - RunFrame(); -/* if (g_fUniversalTime >= g_fTimerThink) { RunFrame(); - g_fTimerThink = CalcNextThink(g_fTimerThink, TIMER_MIN_ACCURACY); + g_fTimerThink = CalcNextThink(g_fTimerThink, gpGlobals->interval_per_tick); } -*/ + RunFrameHooks(simulating); if (m_pOnGameFrame->GetFunctionCount())