mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-07 00:11:39 +00:00
make the start calculation a little more accurate
This commit is contained in:
parent
ec16ffaa65
commit
67368ffc5d
1 changed files with 8 additions and 6 deletions
|
@ -172,9 +172,9 @@ Sys_Printf (const char *fmt, ...)
|
||||||
double
|
double
|
||||||
Sys_DoubleTime (void)
|
Sys_DoubleTime (void)
|
||||||
{
|
{
|
||||||
|
static qboolean first = true;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static DWORD starttime;
|
static DWORD starttime;
|
||||||
static qboolean first = true;
|
|
||||||
DWORD now;
|
DWORD now;
|
||||||
|
|
||||||
now = timeGetTime ();
|
now = timeGetTime ();
|
||||||
|
@ -195,15 +195,17 @@ Sys_DoubleTime (void)
|
||||||
#else
|
#else
|
||||||
struct timeval tp;
|
struct timeval tp;
|
||||||
struct timezone tzp;
|
struct timezone tzp;
|
||||||
static int secbase;
|
double now;
|
||||||
|
static double start_time;
|
||||||
|
|
||||||
gettimeofday (&tp, &tzp);
|
gettimeofday (&tp, &tzp);
|
||||||
|
now = tp.tv_sec + tp.tv_usec / 1e6;
|
||||||
|
|
||||||
if (!secbase) {
|
if (first) {
|
||||||
secbase = tp.tv_sec;
|
first = false;
|
||||||
return tp.tv_usec / 1000000.0;
|
start_time = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
|
return now - start_time;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue