]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
sys_win: Remove pointless cls.state sets since we're calling Sys_Error immediately...
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 92537f39369e82e843a1542a24f1b6a5523ad916..268c1467ee2ba715baa6e62c900da2ec411b353b 100644 (file)
--- a/host.c
+++ b/host.c
@@ -167,6 +167,21 @@ static void Host_Framerate_c(cvar_t *var)
                Cvar_SetValueQuick(var, 0);
 }
 
+// TODO: Find a better home for this.
+static void SendCvar_f(cmd_state_t *cmd)
+{
+       if(cmd->source == src_local && host.hook.SV_SendCvar)
+       {
+               host.hook.SV_SendCvar(cmd);
+               return;
+       }
+       if(cmd->source == src_client && host.hook.CL_SendCvar)
+       {
+               host.hook.CL_SendCvar(cmd);
+               return;
+       }
+}
+
 /*
 =======================
 Host_InitLocal
@@ -182,6 +197,7 @@ static void Host_InitLocal (void)
        Cmd_AddCommand(CF_SHARED, "version", Host_Version_f, "print engine version");
        Cmd_AddCommand(CF_SHARED, "saveconfig", Host_SaveConfig_f, "save settings to config.cfg (or a specified filename) immediately (also automatic when quitting)");
        Cmd_AddCommand(CF_SHARED, "loadconfig", Host_LoadConfig_f, "reset everything and reload configs");
+       Cmd_AddCommand(CF_SHARED, "sendcvar", SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
        Cvar_RegisterVariable (&cl_maxphysicsframesperserverframe);
        Cvar_RegisterVariable (&host_framerate);
        Cvar_RegisterCallback (&host_framerate, Host_Framerate_c);
@@ -363,10 +379,12 @@ double Host_Frame(double time)
        Mem_CheckSentinelsGlobal();
 
        // if the accumulators haven't become positive yet, wait a while
-       if(!sv_timer || !cl_timer)
-               wait = min(cl_timer, sv_timer) * -1000000.0;
+       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
        else
-               wait = max(cl_timer, sv_timer) * -1000000.0;
+               wait = max(cl_timer, sv_timer) * -1000000.0; // listen server or singleplayer
 
        if (!host.restless && wait >= 1)
                return wait;
@@ -387,8 +405,7 @@ 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