This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
Con_Printf ("Cvar_Set: variable %s not found\n", var_name);
return;
}
+ if (var->flags & CVAR_READONLY)
+ {
+ Con_Printf ("Cvar_Set: %s is read-only\n", var_name);
+ return;
+ }
Cvar_SetQuick(var, value);
}
Cvar_SetValue
============
*/
-void Cvar_SetValueQuick (cvar_t *var, float value)
+void Cvar_SetValueQuick(cvar_t *var, float value)
{
- char val[32];
+ char val[256];
- // LordHavoc: changed from %f to %g to use shortest representation
- sprintf (val, "%g",value);
- Cvar_SetQuick (var, val);
+ if ((float)((int)value) == value)
+ sprintf(val, "%i", (int)value);
+ else
+ sprintf(val, "%f", value);
+ Cvar_SetQuick(var, val);
}
-void Cvar_SetValue (const char *var_name, float value)
+void Cvar_SetValue(const char *var_name, float value)
{
- char val[32];
+ char val[256];
- // LordHavoc: changed from %f to %g to use shortest representation
- sprintf (val, "%g",value);
- Cvar_Set (var_name, val);
+ if ((float)((int)value) == value)
+ sprintf(val, "%i", (int)value);
+ else
+ sprintf(val, "%f", value);
+ Cvar_Set(var_name, val);
}
/*
// perform a variable print or set
if (Cmd_Argc() == 1)
{
- Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
+ // only print if host_initialized (otherwise it could print twice if this is in a script)
+ if (host_initialized)
+ Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
return true;
}
with the archive flag set to true.
============
*/
-void Cvar_WriteVariables (QFile *f)
+void Cvar_WriteVariables (qfile_t *f)
{
cvar_t *var;
for (var = cvar_vars ; var ; var = var->next)
if (var->flags & CVAR_SAVE)
- Qprintf (f, "%s \"%s\"\n", var->name, var->string);
+ FS_Printf (f, "%s \"%s\"\n", var->name, var->string);
}