]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
host: Simplify wait timer calculation, removing client/server code from common code
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 72b588eb39e3dc1e4d48c5930e3edc9a70ee2574..92537f39369e82e843a1542a24f1b6a5523ad916 100644 (file)
--- a/host.c
+++ b/host.c
@@ -23,12 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <time.h>
 #include "libcurl.h"
-#include "cdaudio.h"
-#include "cl_video.h"
-#include "progsvm.h"
-#include "csprogs.h"
-#include "sv_demo.h"
-#include "snd_main.h"
 #include "taskqueue.h"
 #include "utf8lib.h"
 
@@ -369,12 +363,10 @@ double Host_Frame(double time)
        Mem_CheckSentinelsGlobal();
 
        // if the accumulators haven't become positive yet, wait a while
-       if (cls.state == ca_dedicated)
-               wait = sv_timer * -1000000.0; // dedicated
-       else if (!sv.active || svs.threaded)
-               wait = cl_timer * -1000000.0; // connected to server, main menu, or server is on different thread
+       if(!sv_timer || !cl_timer)
+               wait = min(cl_timer, sv_timer) * -1000000.0;
        else
-               wait = max(cl_timer, sv_timer) * -1000000.0; // listen server or singleplayer
+               wait = max(cl_timer, sv_timer) * -1000000.0;
 
        if (!host.restless && wait >= 1)
                return wait;
@@ -395,7 +387,8 @@ static inline void Host_Sleep(double time)
                time = 1; // because we cast to int
 
        time0 = Sys_DirtyTime();
-       if (sv_checkforpacketsduringsleep.integer && !sys_usenoclockbutbenchmark.integer && !svs.threaded) {
+       if (sv_checkforpacketsduringsleep.integer && !sys_usenoclockbutbenchmark.integer && !svs.threaded)
+       {
                NetConn_SleepMicroseconds((int)time);
                if (cls.state != ca_dedicated)
                        NetConn_ClientFrame(); // helps server browser get good ping values