]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
host: Use new global host.sleeptime instead of svs variable outside server code
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 13 Jul 2020 16:00:11 +0000 (16:00 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 13 Jul 2020 16:00:11 +0000 (16:00 +0000)
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
quakedef.h

diff --git a/host.c b/host.c
index 18d986299358c85c1e26a06a92dff455c09bb214..9461814595f74152ae94c56cd3f1f758da50fff3 100644 (file)
--- 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;
                }
index 3aefc0601459924d400300f61dbeece87a50eeca..3547b384d7eba6d1891e3b6544131b8a72424fdb 100644 (file)
@@ -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;