From: cloudwalk Date: Fri, 16 Oct 2020 22:46:01 +0000 (+0000) Subject: cvar: Remove the Cvar_Set_NoCallback hack and make it a part of the callbacks where... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=add200ca17e19a0a85eed9cc78721aa1ae74215b;p=xonotic%2Fdarkplaces.git cvar: Remove the Cvar_Set_NoCallback hack and make it a part of the callbacks where it was used instead git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13014 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_cmd.c b/cl_cmd.c index 862f992f..37ecbaa4 100644 --- a/cl_cmd.c +++ b/cl_cmd.c @@ -223,27 +223,43 @@ CL_Color_f */ cvar_t cl_color = {CF_CLIENT | CF_ARCHIVE, "_cl_color", "0", "internal storage cvar for current player colors (changed by color command)"}; -// Ignore the callbacks so this two-to-three way synchronization doesn't cause an infinite loop. +// HACK: Ignore the callbacks so this two-to-three way synchronization doesn't cause an infinite loop. static void CL_Color_c(cvar_t *var) { char vabuf[1024]; - - Cvar_Set_NoCallback(&cl_topcolor, va(vabuf, sizeof(vabuf), "%i", ((var->integer >> 4) & 15))); - Cvar_Set_NoCallback(&cl_bottomcolor, va(vabuf, sizeof(vabuf), "%i", (var->integer & 15))); + void (*callback_save)(cvar_t *); + + callback_save = cl_topcolor.callback; + cl_topcolor.callback = NULL; + Cvar_SetQuick(&cl_topcolor, va(vabuf, sizeof(vabuf), "%i", ((var->integer >> 4) & 15))); + cl_topcolor.callback = callback_save; + + callback_save = cl_bottomcolor.callback; + cl_bottomcolor.callback = NULL; + Cvar_SetQuick(&cl_bottomcolor, va(vabuf, sizeof(vabuf), "%i", (var->integer & 15))); + cl_bottomcolor.callback = callback_save; } static void CL_Topcolor_c(cvar_t *var) { char vabuf[1024]; - - Cvar_Set_NoCallback(&cl_color, va(vabuf, sizeof(vabuf), "%i", var->integer*16 + cl_bottomcolor.integer)); + void (*callback_save)(cvar_t *); + + callback_save = cl_color.callback; + cl_color.callback = NULL; + Cvar_SetQuick(&cl_color, va(vabuf, sizeof(vabuf), "%i", var->integer*16 + cl_bottomcolor.integer)); + cl_color.callback = callback_save; } static void CL_Bottomcolor_c(cvar_t *var) { char vabuf[1024]; + void (*callback_save)(cvar_t *); - Cvar_Set_NoCallback(&cl_color, va(vabuf, sizeof(vabuf), "%i", cl_topcolor.integer*16 + var->integer)); + callback_save = cl_color.callback; + cl_color.callback = NULL; + Cvar_SetQuick(&cl_color, va(vabuf, sizeof(vabuf), "%i", cl_topcolor.integer*16 + var->integer)); + cl_color.callback = callback_save; } static void CL_Color_f(cmd_state_t *cmd) diff --git a/cvar.c b/cvar.c index 6bac3263..4adee745 100644 --- a/cvar.c +++ b/cvar.c @@ -443,14 +443,6 @@ void Cvar_Set(cvar_state_t *cvars, const char *var_name, const char *value) Cvar_SetQuick(var, value); } -void Cvar_Set_NoCallback(cvar_t *var, const char *value) -{ - void (*callback_save)(cvar_t *) = var->callback; - var->callback = NULL; - Cvar_SetQuick_Internal(var, value); - var->callback = callback_save; -} - /* ============ Cvar_SetValue diff --git a/cvar.h b/cvar.h index 67115fc9..1b01fc78 100644 --- a/cvar.h +++ b/cvar.h @@ -125,7 +125,6 @@ qbool Cvar_Readonly (cvar_t *var, const char *cmd_name); /// equivelant to " " typed at the console void Cvar_Set (cvar_state_t *cvars, const char *var_name, const char *value); -void Cvar_Set_NoCallback (cvar_t *var, const char *value); /// expands value to a string and calls Cvar_Set void Cvar_SetValue (cvar_state_t *cvars, const char *var_name, float value);