Give the cvars generated from float+vector autocvars prettier default/initial values.

This commit is contained in:
Shpoike 2023-07-10 03:10:30 +01:00
parent c0efc3bc9a
commit 8b08262ffb

View file

@ -8276,7 +8276,18 @@ void PR_EnableExtensions(ddef_t *pr_globaldefs)
if (!strncmp(n, "autocvar_", 9)) if (!strncmp(n, "autocvar_", 9))
{ {
//really crappy approach //really crappy approach
cvar_t *var = Cvar_Create(n + 9, PR_UglyValueString (qcvm->globaldefs[i].type, (eval_t*)(qcvm->globals + qcvm->globaldefs[i].ofs))); const char *def;
cvar_t *var;
switch(qcvm->globaldefs[i].type&~DEF_SAVEGLOBAL)
{
case ev_float: def = va("%g", ((eval_t*)(qcvm->globals + qcvm->globaldefs[i].ofs))->_float); break; //just to be a bit prettier. autocvars should not depend on denormals etc.
case ev_ext_double: def = va("%g", ((eval_t*)(qcvm->globals + qcvm->globaldefs[i].ofs))->_double); break;
case ev_vector: def = va("%g %g %g", ((eval_t*)(qcvm->globals + qcvm->globaldefs[i].ofs))->vector[0], ((eval_t*)(qcvm->globals + qcvm->globaldefs[i].ofs))->vector[1], ((eval_t*)(qcvm->globals + qcvm->globaldefs[i].ofs))->vector[2]); break;
default: //go generic
def = PR_UglyValueString (qcvm->globaldefs[i].type, (eval_t*)(qcvm->globals + qcvm->globaldefs[i].ofs));
break;
}
var = Cvar_Create(n + 9, def);
numautocvars++; numautocvars++;
if (!var) if (!var)
continue; //name conflicts with a command? continue; //name conflicts with a command?