mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 04:30:43 +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
|
||||
Sys_DoubleTime (void)
|
||||
{
|
||||
static qboolean first = true;
|
||||
#ifdef _WIN32
|
||||
static DWORD starttime;
|
||||
static qboolean first = true;
|
||||
DWORD now;
|
||||
|
||||
now = timeGetTime ();
|
||||
|
@ -195,15 +195,17 @@ Sys_DoubleTime (void)
|
|||
#else
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
double now;
|
||||
static double start_time;
|
||||
|
||||
gettimeofday (&tp, &tzp);
|
||||
now = tp.tv_sec + tp.tv_usec / 1e6;
|
||||
|
||||
if (!secbase) {
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec / 1000000.0;
|
||||
if (first) {
|
||||
first = false;
|
||||
start_time = now;
|
||||
}
|
||||
|
||||
return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
|
||||
return now - start_time;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue