Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tick timers every tick instead of arbitrarily on 100ms thinks, adding a significantly higher amount of precision #2014

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions core/TimerSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -238,7 +236,7 @@ void TimerSystem::GameFrame(bool simulating)
{
RunFrame();

g_fTimerThink = CalcNextThink(g_fTimerThink, TIMER_MIN_ACCURACY);
g_fTimerThink = CalcNextThink(g_fTimerThink, gpGlobals->interval_per_tick);
}

RunFrameHooks(simulating);
Expand Down