From 46c8ba5d47ac1ff032229934e2816a54b674ab12 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Thu, 25 Jun 2020 14:34:45 +0000 Subject: [PATCH] Revert "Use double for cvar values. Fixes a number of bugs caused by atof precision loss" This reverts commit eed1ea81a1b9b9c04fad76b3f1bfeec6ea9c44db. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12733 d7cf8633-e32d-0410-b094-e92efae38249 --- cvar.c | 10 +++++----- cvar.h | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cvar.c b/cvar.c index aff7672a..905fa758 100644 --- a/cvar.c +++ b/cvar.c @@ -111,7 +111,7 @@ match: Cvar_VariableValue ============ */ -float Cvar_VariableValueOr(cvar_state_t *cvars, const char *var_name, double def, int neededflags) +float Cvar_VariableValueOr(cvar_state_t *cvars, const char *var_name, float def, int neededflags) { cvar_t *var; @@ -459,22 +459,22 @@ void Cvar_Set_NoCallback(cvar_t *var, const char *value) Cvar_SetValue ============ */ -void Cvar_SetValueQuick(cvar_t *var, double value) +void Cvar_SetValueQuick(cvar_t *var, float value) { char val[MAX_INPUTLINE]; - if ((double)((int)value) == value) + if ((float)((int)value) == value) dpsnprintf(val, sizeof(val), "%i", (int)value); else dpsnprintf(val, sizeof(val), "%f", value); Cvar_SetQuick(var, val); } -void Cvar_SetValue(cvar_state_t *cvars, const char *var_name, double value) +void Cvar_SetValue(cvar_state_t *cvars, const char *var_name, float value) { char val[MAX_INPUTLINE]; - if ((double)((int)value) == value) + if ((float)((int)value) == value) dpsnprintf(val, sizeof(val), "%i", (int)value); else dpsnprintf(val, sizeof(val), "%f", value); diff --git a/cvar.h b/cvar.h index aa36f626..e7234b17 100644 --- a/cvar.h +++ b/cvar.h @@ -124,8 +124,8 @@ typedef struct cvar_s const char *string; const char *description; int integer; - double value; - double vector[3]; + float value; + float vector[3]; const char *defstring; @@ -141,8 +141,8 @@ typedef struct cvar_s const char *initstring; const char *initdescription; int initinteger; - double initvalue; - double initvector[3]; + float initvalue; + float initvector[3]; const char *initdefstring; int globaldefindex[3]; @@ -193,12 +193,12 @@ 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, double value); +void Cvar_SetValue (cvar_state_t *cvars, const char *var_name, float value); void Cvar_SetQuick (cvar_t *var, const char *value); -void Cvar_SetValueQuick (cvar_t *var, double value); +void Cvar_SetValueQuick (cvar_t *var, float value); -float Cvar_VariableValueOr (cvar_state_t *cvars, const char *var_name, double def, int neededflags); +float Cvar_VariableValueOr (cvar_state_t *cvars, const char *var_name, float def, int neededflags); // returns def if not defined float Cvar_VariableValue (cvar_state_t *cvars, const char *var_name, int neededflags); -- 2.39.2