From 6e82b529dceb0bf5f4277fa6fd499dc4f720d2ca Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Mon, 13 Jul 2020 16:00:11 +0000 Subject: [PATCH] host: Use new global host.sleeptime instead of svs variable outside server code This, again, moves server code out of common code. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12801 d7cf8633-e32d-0410-b094-e92efae38249 --- host.c | 12 +++++++----- quakedef.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/host.c b/host.c index 18d98629..94618145 100644 --- a/host.c +++ b/host.c @@ -412,6 +412,7 @@ void Host_Main(void) Host_Init(); host.realtime = 0; + host.sleeptime = 0; host.dirtytime = Sys_DirtyTime(); while(host.state != host_shutdown) @@ -445,6 +446,7 @@ void Host_Main(void) if (!svs.threaded) { + svs.perf_acc_sleeptime = host.sleeptime; svs.perf_acc_realtime += time; // Look for clients who have spawned @@ -457,7 +459,7 @@ void Host_Main(void) { // don't accumulate time for the first 10 seconds of a match // so things can settle - svs.perf_acc_realtime = svs.perf_acc_sleeptime = svs.perf_acc_lost = svs.perf_acc_offset = svs.perf_acc_offset_squared = svs.perf_acc_offset_max = svs.perf_acc_offset_samples = 0; + svs.perf_acc_realtime = svs.perf_acc_sleeptime = svs.perf_acc_lost = svs.perf_acc_offset = svs.perf_acc_offset_squared = svs.perf_acc_offset_max = svs.perf_acc_offset_samples = host.sleeptime = 0; } else if(svs.perf_acc_realtime > 5) { @@ -472,7 +474,7 @@ void Host_Main(void) if(svs.perf_lost > 0 && developer_extra.integer) if(playing) // only complain if anyone is looking Con_DPrintf("Server can't keep up: %s\n", Host_TimingReport(vabuf, sizeof(vabuf))); - svs.perf_acc_realtime = svs.perf_acc_sleeptime = svs.perf_acc_lost = svs.perf_acc_offset = svs.perf_acc_offset_squared = svs.perf_acc_offset_max = svs.perf_acc_offset_samples = 0; + svs.perf_acc_realtime = svs.perf_acc_sleeptime = svs.perf_acc_lost = svs.perf_acc_offset = svs.perf_acc_offset_squared = svs.perf_acc_offset_max = svs.perf_acc_offset_samples = host.sleeptime = 0; } } @@ -541,9 +543,9 @@ void Host_Main(void) else Sys_Sleep((int)wait); delta = Sys_DirtyTime() - time0; - if (delta < 0 || delta >= 1800) delta = 0; - if (!svs.threaded) - svs.perf_acc_sleeptime += delta; + if (delta < 0 || delta >= 1800) + delta = 0; + host.sleeptime += delta; // R_TimeReport("sleep"); continue; } diff --git a/quakedef.h b/quakedef.h index 3aefc060..3547b384 100644 --- a/quakedef.h +++ b/quakedef.h @@ -534,6 +534,7 @@ typedef struct host_s int framecount; // incremented every frame, never reset (checked by Host_Error and Host_SaveConfig_f) double realtime; // the accumulated mainloop time since application started (with filtering), without any slowmo or clamping double dirtytime; // the main loop wall time for this frame, equal to Sys_DirtyTime() at the start of this host frame + double sleeptime; // time spent sleeping overall qboolean restless; // don't sleep qboolean paused; // global paused state, pauses both client and server } host_t; -- 2.39.2