]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
host: Implement callback for host_framerate instead of checking it every frame
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 20 Jul 2020 17:35:01 +0000 (17:35 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 20 Jul 2020 17:35:01 +0000 (17:35 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12850 d7cf8633-e32d-0410-b094-e92efae38249

host.c

diff --git a/host.c b/host.c
index 674347739c874ae0dba72774f1b7cea3f9960495..dd48b2f0e0c1d09d3a54504ab5be24c48b7a9476 100644 (file)
--- a/host.c
+++ b/host.c
@@ -217,6 +217,12 @@ static void Host_Version_f(cmd_state_t *cmd)
        Con_Printf("Version: %s build %s\n", gamename, buildstring);
 }
 
+static void Host_Framerate_c(cvar_t *var)
+{
+       if (var->value < 0.00001 && var->value != 0)
+               Cvar_SetValueQuick(var, 0);
+}
+
 /*
 =======================
 Host_InitLocal
@@ -234,6 +240,7 @@ static void Host_InitLocal (void)
        Cmd_AddCommand(CMD_SHARED, "loadconfig", Host_LoadConfig_f, "reset everything and reload configs");
        Cvar_RegisterVariable (&cl_maxphysicsframesperserverframe);
        Cvar_RegisterVariable (&host_framerate);
+       Cvar_RegisterCallback (&host_framerate, Host_Framerate_c);
        Cvar_RegisterVariable (&host_speeds);
        Cvar_RegisterVariable (&host_maxwait);
 
@@ -379,9 +386,6 @@ double Host_Frame(double time)
        double sv_timer = 0;
        static double wait;
 
-       if (host_framerate.value < 0.00001 && host_framerate.value != 0)
-               Cvar_SetValueQuick(&host_framerate, 0);
-
        TaskQueue_Frame(false);
 
        // keep the random time dependent, but not when playing demos/benchmarking