Refactor curtime to be set at one defined point.

Until now the curtime variable was set at every call Sys_*seconds().
That's a little bit unfortunate because calls to that functions are
scattered around the code. Instead set it once every frame in
Qcommon_Frame().
This commit is contained in:
Yamagi Burmeister 2017-09-07 16:28:31 +02:00
parent 5fa6fa9175
commit 42dfd3dbdd
3 changed files with 15 additions and 12 deletions

View file

@ -52,7 +52,6 @@
#include "header/unix.h"
unsigned sys_frame_time;
int curtime;
static void *game_library;
static char findbase[MAX_OSPATH];
@ -103,16 +102,13 @@ Sys_Microseconds(void)
--sec;
}
curtime = (int)((sec*1000000ll + nsec/1000ll) / 1000ll);
return sec*1000000ll + nsec/1000ll;
}
int
Sys_Milliseconds(void)
{
curtime = (int)(Sys_Microseconds()/1000ll);
return curtime;
return (int)(Sys_Microseconds()/1000ll);
}
void

View file

@ -41,7 +41,6 @@
#define MAX_NUM_ARGVS 128
int curtime;
int starttime;
qboolean ActiveApp;
qboolean Minimized;
@ -430,19 +429,16 @@ Sys_Microseconds(void)
if (!uSecbase)
{
uSecbase = microseconds - 1001;
uSecbase = microseconds / 1000ll;
}
curtime = (int)((microseconds - uSecbase) / 1000ll);
return microseconds - uSecbase;
}
int
Sys_Milliseconds(void)
{
curtime = (int)(Sys_Microseconds()/1000ll);
return curtime;
return (int)(Sys_Microseconds()/1000ll);
}
void

View file

@ -35,7 +35,6 @@ cvar_t *fixedtime;
cvar_t *cl_maxfps;
cvar_t *dedicated;
extern cvar_t *logfile_active;
extern jmp_buf abortframe; /* an ERR_DROP occured, exit the entire frame */
extern zhead_t z_chain;
@ -62,6 +61,9 @@ int time_after_game;
int time_before_ref;
int time_after_ref;
// Used in the network- and input pathes.
int curtime;
#ifndef DEDICATED_ONLY
void Key_Init(void);
void SCR_EndLoadingPlaque(void);
@ -300,6 +302,10 @@ Qcommon_Frame(int msec)
}
// Save global time for network- und input code.
curtime = Sys_Milliseconds();
// Calculate target packet- and renderframerate.
if (R_IsVSyncActive())
{
@ -470,6 +476,11 @@ Qcommon_Frame(int msec)
}
// Save global time for network- und input code.
curtime = Sys_Milliseconds();
// Target framerate.
pfps = (int)cl_maxfps->value;