From 45e98d80d943b6fc9e7e19efc7a7fa2627ae9c96 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 25 Apr 2002 20:08:18 +0000 Subject: [PATCH] redo the cvar vector reading code to produce more useful results --- libs/util/cvar.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/util/cvar.c b/libs/util/cvar.c index 584edb45f..06d6766a9 100644 --- a/libs/util/cvar.c +++ b/libs/util/cvar.c @@ -45,6 +45,7 @@ static const char rcsid[] = #include "QF/cmd.h" #include "QF/cvar.h" #include "QF/hash.h" +#include "QF/mathlib.h" #include "QF/qargs.h" #include "QF/sys.h" #include "QF/va.h" @@ -230,6 +231,7 @@ void Cvar_Set (cvar_t *var, const char *value) { int changed; + int vals; if (!var) return; @@ -245,7 +247,11 @@ Cvar_Set (cvar_t *var, const char *value) var->string = strdup (value); var->value = atof (var->string); var->int_val = atoi (var->string); - sscanf (var->string, "%f %f %f", &var->vec[0], &var->vec[1], &var->vec[2]); + VectorZero (var->vec); + vals = sscanf (var->string, "%f %f %f", + &var->vec[0], &var->vec[1], &var->vec[2]); + if (vals == 1) + var->vec[2] = var->vec[1] = var->vec[0]; if (changed && var->callback) var->callback (var);