Reconnect the server to the global timing.

Having the server in an own timing zone seems to simplify things but
introduces slight timing discrepancies. The most visible effect is that
the game runs a little bit too fast, especially in the first cl_maxfps
frames.

Therefor: Remove timeframes, they're unnecessary. Track the time since
the last (client|server) frame instead and pass it to the client and
server when it's called.
This commit is contained in:
Yamagi Burmeister 2017-09-06 14:38:00 +02:00
parent 0a3c6f3786
commit 465963a1a5
3 changed files with 23 additions and 34 deletions

View file

@ -784,6 +784,6 @@ void SCR_BeginLoadingPlaque(void);
void SV_Init(void);
void SV_Shutdown(char *finalmsg, qboolean reconnect);
void SV_Frame();
void SV_Frame(int msec);
#endif

View file

@ -327,8 +327,11 @@ Qcommon_Frame(int msec)
// Time since last misc. frame in microsec.
static int miscdelta = 100000;
// Accumulated time since last (packet|render|misc|time) frame.
static int timedelta = 1001;
// Accumulated time since last client run.
static int clienttimedelta = 0;
// Accumulated time since last server run.
static int servertimedelta = 0;
/* A packetframe runs the server and the client,
but not the renderer. The minimal interval of
@ -348,12 +351,6 @@ Qcommon_Frame(int msec)
An interval of 100.000 microseconds is enough. */
qboolean miscframe = true;
/* Timeframes are empty frames. We need to call the
client at regular intervals to forward several
internal timers, even if there's nothing to do.
This is also necessary to speed up loading times. */
qboolean timeframe = true;
/* In case of ERR_DROP we're jumping here. Don't know
if that' really save but it seems to work. So leave
@ -441,7 +438,8 @@ Qcommon_Frame(int msec)
packetdelta += msec;
renderdelta += msec;
miscdelta += msec;
timedelta += msec;
clienttimedelta += msec;
servertimedelta += msec;
if (cl_async->value)
{
@ -474,24 +472,17 @@ Qcommon_Frame(int msec)
}
}
if (timedelta < 1001)
{
timeframe = false;
}
// Dedicated server terminal console.
do {
s = Sys_ConsoleInput();
// No need to run the terminal console too often.
if (timeframe) {
do {
s = Sys_ConsoleInput();
if (s) {
Cbuf_AddText(va("%s\n", s));
}
} while (s);
if (s) {
Cbuf_AddText(va("%s\n", s));
}
} while (s);
Cbuf_Execute();
}
Cbuf_Execute();
#ifndef DEDICATED_ONLY
@ -504,7 +495,8 @@ Qcommon_Frame(int msec)
// Run the serverframe.
if (packetframe) {
SV_Frame();
SV_Frame(servertimedelta);
servertimedelta = 0;
}
@ -516,9 +508,10 @@ Qcommon_Frame(int msec)
// Run the client frame.
if (packetframe || renderframe || miscframe || timeframe) {
CL_Frame(packetdelta, renderdelta, miscdelta, timedelta,
if (packetframe || renderframe || miscframe) {
CL_Frame(packetdelta, renderdelta, miscdelta, clienttimedelta,
packetframe, renderframe, miscframe);
clienttimedelta = 0;
}
@ -552,10 +545,6 @@ Qcommon_Frame(int msec)
if (miscframe) {
miscdelta = 0;
}
if (timeframe) {
timedelta = 0;
}
}
void

View file

@ -376,7 +376,7 @@ SV_RunGameFrame(void)
}
void
SV_Frame()
SV_Frame(int msec)
{
#ifndef DEDICATED_ONLY
time_before_game = time_after_game = 0;
@ -388,7 +388,7 @@ SV_Frame()
return;
}
svs.realtime = curtime;
svs.realtime += msec / 1000;
/* keep the random time dependent */
randk();