]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Implement cvar callback for slowmo
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 4 Jun 2020 15:39:39 +0000 (15:39 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 4 Jun 2020 15:39:39 +0000 (15:39 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12635 d7cf8633-e32d-0410-b094-e92efae38249

cvar.c
host.c
sv_main.c

diff --git a/cvar.c b/cvar.c
index be6ed386f08405660bdf053b7884830703a965fe..0b039e7f9754675ea802069689fe2891083eb40e 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -357,7 +357,7 @@ static void Cvar_SetQuick_Internal (cvar_t *var, const char *value)
                return;
 
        memcpy(new_value,value,MAX_INPUTLINE);
-       
+
        // Call the function stored in the cvar for bounds checking, cleanup, etc
        if (var->callback)
                var->callback(new_value);
diff --git a/host.c b/host.c
index ae985c505426bc28c613ea6f21a82cd118258822..95b1025f1225c3e489f4f5ec1ea01f60db694ae2 100644 (file)
--- a/host.c
+++ b/host.c
@@ -747,8 +747,6 @@ void Host_Main(void)
                        }
                }
 
-               if (slowmo.value < 0.00001 && slowmo.value != 0)
-                       Cvar_SetValueQuick(&slowmo, 0);
                if (host_framerate.value < 0.00001 && host_framerate.value != 0)
                        Cvar_SetValueQuick(&host_framerate, 0);
 
index 1f8d87f0d3719f09559dec45eb1695605abb703d..0a0dd9820c36aa8639a822d6c1ebafd1f31bcd67 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -413,7 +413,14 @@ prvm_required_field_t sv_reqglobals[] =
 #undef PRVM_DECLARE_function
 };
 
+static void SV_Slowmo_c(char *string)
+{
+       double value;
+       value = atof(string);
 
+       if(value < 0.00001 && value != 0)
+               string[0] = '0', string[1] = 0;
+}
 
 //============================================================================
 
@@ -467,6 +474,7 @@ void SV_Init (void)
        Cvar_RegisterVariable (&samelevel);
        Cvar_RegisterVariable (&skill);
        Cvar_RegisterVariable (&slowmo);
+       Cvar_RegisterCallback (&slowmo, SV_Slowmo_c);
        Cvar_RegisterVariable (&sv_accelerate);
        Cvar_RegisterVariable (&sv_aim);
        Cvar_RegisterVariable (&sv_airaccel_qw);