]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
fix a bug that broke cl_maxphysicsframesperserverframe
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 88eed4bde5161cff7c3be4c527c15d4ad895397a..729e998d2fa52652d8159b166629a280e8ff70c0 100644 (file)
--- a/host.c
+++ b/host.c
@@ -94,6 +94,9 @@ aborts the current host frame and goes on with the next one
 */
 void Host_AbortCurrentFrame(void)
 {
+       // in case we were previously nice, make us mean again
+       Sys_MakeProcessMean();
+
        longjmp (host_abortframe, 1);
 }
 
@@ -758,7 +761,7 @@ void Host_Main(void)
                        // process console commands
 //                     R_TimeReport("preconsole");
                        CL_VM_PreventInformationLeaks();
-                       Cbuf_Execute();
+                       Cbuf_Frame();
 //                     R_TimeReport("console");
                }
 
@@ -834,20 +837,15 @@ void Host_Main(void)
                                advancetime = sv_timer;
                        else if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
                        {
-                               // synchronize to the client frametime, but no less than 10ms and no more than sys_ticrate
-                               advancetime = bound(0.01, cl_timer, sys_ticrate.value);
-                               framelimit = cl_maxphysicsframesperserverframe.integer;
-                               aborttime = realtime + 0.1;
+                               // synchronize to the client frametime, but no less than 10ms and no more than 100ms
+                               advancetime = bound(0.01, cl_timer, 0.1);
                        }
                        else
                        {
                                advancetime = sys_ticrate.value;
                                // listen servers can run multiple server frames per client frame
-                               if (cls.state == ca_connected)
-                               {
-                                       framelimit = cl_maxphysicsframesperserverframe.integer;
-                                       aborttime = realtime + 0.1;
-                               }
+                               framelimit = cl_maxphysicsframesperserverframe.integer;
+                               aborttime = Sys_DirtyTime() + 0.1;
                        }
                        if(slowmo.value > 0 && slowmo.value < 1)
                                advancetime = min(advancetime, 0.1 / slowmo.value);
@@ -856,7 +854,7 @@ void Host_Main(void)
 
                        if(advancetime > 0)
                        {
-                               offset = Sys_DirtyTime() - realtime;if (offset < 0 || offset >= 1800) offset = 0;
+                               offset = Sys_DirtyTime() - dirtytime;if (offset < 0 || offset >= 1800) offset = 0;
                                offset += sv_timer;
                                ++svs.perf_acc_offset_samples;
                                svs.perf_acc_offset += offset;
@@ -1161,6 +1159,9 @@ static void Host_Init (void)
        dpsnprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
        Con_Printf("%s\n", engineversion);
 
+       // initialize process nice level
+       Sys_InitProcessNice();
+
        // initialize ixtable
        Mathlib_Init();
 
@@ -1312,6 +1313,10 @@ void Host_Shutdown(void)
        // be quiet while shutting down
        S_StopAllSounds();
 
+       // end the server thread
+       if (svs.threaded)
+               SV_StopThread();
+
        // disconnect client from server if active
        CL_Disconnect();
 
@@ -1320,10 +1325,6 @@ void Host_Shutdown(void)
        Host_ShutdownServer ();
        SV_UnlockThreadMutex();
 
-       // end the server thread
-       if (svs.threaded)
-               SV_StopThread();
-
        // Shutdown menu
        if(MR_Shutdown)
                MR_Shutdown();