mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
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:
parent
0a3c6f3786
commit
465963a1a5
3 changed files with 23 additions and 34 deletions
|
@ -784,6 +784,6 @@ void SCR_BeginLoadingPlaque(void);
|
||||||
|
|
||||||
void SV_Init(void);
|
void SV_Init(void);
|
||||||
void SV_Shutdown(char *finalmsg, qboolean reconnect);
|
void SV_Shutdown(char *finalmsg, qboolean reconnect);
|
||||||
void SV_Frame();
|
void SV_Frame(int msec);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -327,8 +327,11 @@ Qcommon_Frame(int msec)
|
||||||
// Time since last misc. frame in microsec.
|
// Time since last misc. frame in microsec.
|
||||||
static int miscdelta = 100000;
|
static int miscdelta = 100000;
|
||||||
|
|
||||||
// Accumulated time since last (packet|render|misc|time) frame.
|
// Accumulated time since last client run.
|
||||||
static int timedelta = 1001;
|
static int clienttimedelta = 0;
|
||||||
|
|
||||||
|
// Accumulated time since last server run.
|
||||||
|
static int servertimedelta = 0;
|
||||||
|
|
||||||
/* A packetframe runs the server and the client,
|
/* A packetframe runs the server and the client,
|
||||||
but not the renderer. The minimal interval of
|
but not the renderer. The minimal interval of
|
||||||
|
@ -348,12 +351,6 @@ Qcommon_Frame(int msec)
|
||||||
An interval of 100.000 microseconds is enough. */
|
An interval of 100.000 microseconds is enough. */
|
||||||
qboolean miscframe = true;
|
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
|
/* In case of ERR_DROP we're jumping here. Don't know
|
||||||
if that' really save but it seems to work. So leave
|
if that' really save but it seems to work. So leave
|
||||||
|
@ -441,7 +438,8 @@ Qcommon_Frame(int msec)
|
||||||
packetdelta += msec;
|
packetdelta += msec;
|
||||||
renderdelta += msec;
|
renderdelta += msec;
|
||||||
miscdelta += msec;
|
miscdelta += msec;
|
||||||
timedelta += msec;
|
clienttimedelta += msec;
|
||||||
|
servertimedelta += msec;
|
||||||
|
|
||||||
if (cl_async->value)
|
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 (s) {
|
||||||
if (timeframe) {
|
Cbuf_AddText(va("%s\n", s));
|
||||||
do {
|
}
|
||||||
s = Sys_ConsoleInput();
|
} while (s);
|
||||||
|
|
||||||
if (s) {
|
Cbuf_Execute();
|
||||||
Cbuf_AddText(va("%s\n", s));
|
|
||||||
}
|
|
||||||
} while (s);
|
|
||||||
|
|
||||||
Cbuf_Execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef DEDICATED_ONLY
|
#ifndef DEDICATED_ONLY
|
||||||
|
@ -504,7 +495,8 @@ Qcommon_Frame(int msec)
|
||||||
|
|
||||||
// Run the serverframe.
|
// Run the serverframe.
|
||||||
if (packetframe) {
|
if (packetframe) {
|
||||||
SV_Frame();
|
SV_Frame(servertimedelta);
|
||||||
|
servertimedelta = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -516,9 +508,10 @@ Qcommon_Frame(int msec)
|
||||||
|
|
||||||
|
|
||||||
// Run the client frame.
|
// Run the client frame.
|
||||||
if (packetframe || renderframe || miscframe || timeframe) {
|
if (packetframe || renderframe || miscframe) {
|
||||||
CL_Frame(packetdelta, renderdelta, miscdelta, timedelta,
|
CL_Frame(packetdelta, renderdelta, miscdelta, clienttimedelta,
|
||||||
packetframe, renderframe, miscframe);
|
packetframe, renderframe, miscframe);
|
||||||
|
clienttimedelta = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -552,10 +545,6 @@ Qcommon_Frame(int msec)
|
||||||
if (miscframe) {
|
if (miscframe) {
|
||||||
miscdelta = 0;
|
miscdelta = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeframe) {
|
|
||||||
timedelta = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -376,7 +376,7 @@ SV_RunGameFrame(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SV_Frame()
|
SV_Frame(int msec)
|
||||||
{
|
{
|
||||||
#ifndef DEDICATED_ONLY
|
#ifndef DEDICATED_ONLY
|
||||||
time_before_game = time_after_game = 0;
|
time_before_game = time_after_game = 0;
|
||||||
|
@ -388,7 +388,7 @@ SV_Frame()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
svs.realtime = curtime;
|
svs.realtime += msec / 1000;
|
||||||
|
|
||||||
/* keep the random time dependent */
|
/* keep the random time dependent */
|
||||||
randk();
|
randk();
|
||||||
|
|
Loading…
Reference in a new issue