]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
cl_main: Slight refactor
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 0c4da3c9aa75611ad8624866268b46779bd8f030..5c50ba791499266d80394d0f7392da7faf990fa0 100644 (file)
--- a/host.c
+++ b/host.c
@@ -301,26 +301,6 @@ void Host_LoadConfig_f(cmd_state_t *cmd)
 
 //============================================================================
 
-/*
-===================
-Host_GetConsoleCommands
-
-Add them exactly as if they had been typed at the console
-===================
-*/
-static void Host_GetConsoleCommands (void)
-{
-       char *line;
-
-       while ((line = Sys_ConsoleInput()))
-       {
-               if (cls.state == ca_dedicated)
-                       Cbuf_AddText(cmd_server, line);
-               else
-                       Cbuf_AddText(cmd_client, line);
-       }
-}
-
 /*
 ==================
 Host_TimeReport
@@ -343,9 +323,7 @@ Runs all active servers
 static void Host_Init(void);
 double Host_Frame(double time)
 {
-       double cl_timer = 0;
-       double sv_timer = 0;
-       static double wait;
+       double cl_wait, sv_wait;
 
        TaskQueue_Frame(false);
 
@@ -357,39 +335,31 @@ double Host_Frame(double time)
 
        Log_DestBuffer_Flush();
 
-       Curl_Run();
-
-       // check for commands typed to the host
-       Host_GetConsoleCommands();
+       // Run any downloads
+       Curl_Frame();
 
        // process console commands
-//             R_TimeReport("preconsole");
-
        Cbuf_Frame(host.cbuf);
 
-//             R_TimeReport("console");
-
-       //Con_Printf("%6.0f %6.0f\n", cl_timer * 1000000.0, sv_timer * 1000000.0);
-
        R_TimeReport("---");
 
-       sv_timer = SV_Frame(time);
-       cl_timer = CL_Frame(time);
+       sv_wait = SV_Frame(time);
+       cl_wait = CL_Frame(time);
+
+//     Con_Printf("%6.0f %6.0f\n", cl_wait * 1000000.0, sv_wait * 1000000.0);
 
        Mem_CheckSentinelsGlobal();
 
+       if(host.restless)
+               return 0;
+
        // if the accumulators haven't become positive yet, wait a while
        if (cls.state == ca_dedicated)
-               wait = sv_timer * -1000000.0; // dedicated
+               return sv_wait * -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
+               return cl_wait * -1000000.0; // connected to server, main menu, or server is on different thread
        else
-               wait = max(cl_timer, sv_timer) * -1000000.0; // listen server or singleplayer
-
-       if (!host.restless && wait >= 1)
-               return wait;
-       else
-               return 0;
+               return max(cl_wait, sv_wait) * -1000000.0; // listen server or singleplayer
 }
 
 static inline void Host_Sleep(double time)
@@ -466,7 +436,7 @@ void Host_Main(void)
                sleeptime = Host_Frame(time);
                oldtime = newtime;
 
-               if (sleeptime)
+               if (sleeptime >= 1)
                {
                        Host_Sleep(sleeptime);
                        continue;