From 203ba72bec0358b73c4ca379b0e4da07a7352e02 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Thu, 4 Jun 2020 15:39:39 +0000 Subject: [PATCH] Implement cvar callback for slowmo git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12635 d7cf8633-e32d-0410-b094-e92efae38249 --- cvar.c | 2 +- host.c | 2 -- sv_main.c | 8 ++++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cvar.c b/cvar.c index be6ed386..0b039e7f 100644 --- 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 ae985c50..95b1025f 100644 --- 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); diff --git a/sv_main.c b/sv_main.c index 1f8d87f0..0a0dd982 100644 --- 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); -- 2.39.2