fixed a precision bug that caused SourceMod to stop working after excatly 72.8 hours
authorDavid Anderson <dvander@alliedmods.net>
Fri Nov 23 02:39:48 2007 +0000 (2007-11-23)
changeset 1714f1da232f6ca4
parent 1713 5cc4dd21d55e
child 1717 d22926b36087
fixed a precision bug that caused SourceMod to stop working after excatly 72.8 hours
core/TimerSys.cpp
core/TimerSys.h
     1.1 --- a/core/TimerSys.cpp	Fri Nov 23 01:13:13 2007 +0000
     1.2 +++ b/core/TimerSys.cpp	Fri Nov 23 02:39:48 2007 +0000
     1.3 @@ -48,16 +48,16 @@
     1.4  #endif
     1.5  
     1.6  TimerSystem g_Timers;
     1.7 -float g_fUniversalTime = 0.0f;
     1.8 +double g_fUniversalTime = 0.0f;
     1.9  float g_fGameStartTime = 0.0f;	/* Game game start time, non-universal */
    1.10 -float g_fTimerThink = 0.0f;		/* Timer's next think time */
    1.11 -const float *g_pUniversalTime = &g_fUniversalTime;
    1.12 +double g_fTimerThink = 0.0f;		/* Timer's next think time */
    1.13 +const double *g_pUniversalTime = &g_fUniversalTime;
    1.14  ConVar *mp_timelimit = NULL;
    1.15  int g_TimeLeftMode = 0;
    1.16  
    1.17  ConVar sm_time_adjustment("sm_time_adjustment", "0", 0, "Adjusts the server time in seconds");
    1.18  
    1.19 -inline float GetSimulatedTime()
    1.20 +inline double GetSimulatedTime()
    1.21  {
    1.22  	return g_fUniversalTime;
    1.23  }
    1.24 @@ -159,7 +159,7 @@
    1.25   * that a drastic jump in time will continue acting normally.  Users 
    1.26   * may not expect this, but... I think it is the best solution.
    1.27   */
    1.28 -inline float CalcNextThink(float last, float interval)
    1.29 +inline double CalcNextThink(double last, float interval)
    1.30  {
    1.31  	if (g_fUniversalTime - last - interval <= TIMER_MIN_ACCURACY)
    1.32  	{
    1.33 @@ -274,7 +274,7 @@
    1.34  	ITimer *pTimer;
    1.35  	TimerIter iter;
    1.36  
    1.37 -	float curtime = GetSimulatedTime();
    1.38 +	double curtime = GetSimulatedTime();
    1.39  	for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); )
    1.40  	{
    1.41  		pTimer = (*iter);
     2.1 --- a/core/TimerSys.h	Fri Nov 23 01:13:13 2007 +0000
     2.2 +++ b/core/TimerSys.h	Fri Nov 23 02:39:48 2007 +0000
     2.3 @@ -51,7 +51,7 @@
     2.4  	ITimedEvent *m_Listener;
     2.5  	void *m_pData;
     2.6  	float m_Interval;
     2.7 -	float m_ToExec;
     2.8 +	double m_ToExec;
     2.9  	int m_Flags;
    2.10  	bool m_InExec;
    2.11  	bool m_KillMe;
    2.12 @@ -103,7 +103,7 @@
    2.13  
    2.14  time_t GetAdjustedTime(time_t *buf = NULL);
    2.15  
    2.16 -extern const float *g_pUniversalTime;
    2.17 +extern const double *g_pUniversalTime;
    2.18  extern TimerSystem g_Timers;
    2.19  extern int g_TimeLeftMode;
    2.20