From: divverent Date: Thu, 18 Aug 2011 13:02:52 +0000 (+0000) Subject: sys_usenoclockbutbenchmark: use double for the timer, X-Git-Tag: xonotic-v0.6.0~163^2~267 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d1e0fe0cc93cac5ef1849ade897e3a3707a19040;p=xonotic%2Fdarkplaces.git sys_usenoclockbutbenchmark: use double for the timer, to run for more than 1h:11m simulated time git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11285 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/sys_shared.c b/sys_shared.c index 298de87d..bb6ce36b 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -263,7 +263,7 @@ static cvar_t sys_usequeryperformancecounter = {CVAR_SAVE, "sys_usequeryperforma static cvar_t sys_useclockgettime = {CVAR_SAVE, "sys_useclockgettime", "0", "use POSIX clock_gettime function (which has issues if the system clock speed is far off, as it can't get fixed by NTP) for timing rather than gettimeofday (which has issues if the system time is stepped by ntpdate, or apparently on some Xen installations)"}; #endif -static unsigned long benchmark_time; +static double benchmark_time; // actually always contains an integer amount of milliseconds, will eventually "overflow" void Sys_Init_Commands (void) { @@ -291,8 +291,11 @@ double Sys_DoubleTime(void) double newtime; if(sys_usenoclockbutbenchmark.integer) { + double old_benchmark_time = benchmark_time; benchmark_time += 1; - return ((double) benchmark_time) / 1e6; + if(benchmark_time == old_benchmark_time) + Sys_Error("sys_usenoclockbutbenchmark cannot run any longer, sorry"); + return benchmark_time * 0.000001; } // first all the OPTIONAL timers @@ -417,7 +420,13 @@ void Sys_Sleep(int microseconds) double t = 0; if(sys_usenoclockbutbenchmark.integer) { - benchmark_time += microseconds; + if(microseconds) + { + double old_benchmark_time = benchmark_time; + benchmark_time += microseconds; + if(benchmark_time == old_benchmark_time) + Sys_Error("sys_usenoclockbutbenchmark cannot run any longer, sorry"); + } return; } if(sys_debugsleep.integer)