Merge branch 'cvar-zstring-fix' into 'next'

Unset zstring if a preset value is used

Closes #487

See merge request STJr/SRB2!1479
This commit is contained in:
LJ Sonic 2021-04-26 05:55:14 -04:00
commit 83a80106b1
1 changed files with 4 additions and 7 deletions

View File

@ -1441,6 +1441,10 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
return;
}
// free the old value string
Z_Free(var->zstring);
var->zstring = NULL;
var->value = var->PossibleValue[i].value;
var->string = var->PossibleValue[i].strvalue;
goto finish;
@ -1503,14 +1507,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
found:
if (client && execversion_enabled)
{
if (var->revert.allocated)
{
Z_Free(var->revert.v.string);
var->revert.allocated = false; // the below value is not allocated in zone memory, don't try to free it!
}
var->revert.v.const_munge = var->PossibleValue[i].strvalue;
return;
}