add console command to reset a CVAR to default value

Rationale:
1. Now to reset a CVAR to default, the user doesn't need to remember the default value.
2. If a modder wants to reset a CVAR via menu command, they don't need to keep menudef and cvarinfo in sync.
This commit is contained in:
Alexander Kromm 2020-10-15 00:30:24 +07:00 committed by Christoph Oelckers
parent cfbf115c4b
commit 18a8fafd7d

View file

@ -1497,6 +1497,22 @@ CCMD (unset)
}
}
CCMD (reset)
{
if (argv.argc() != 2)
{
Printf ("usage: reset <variable>\n");
}
else
{
FBaseCVar *var = FindCVar (argv[1], NULL);
if (var == NULL)
var = new FStringCVar (argv[1], NULL, CVAR_AUTO | CVAR_UNSETTABLE | cvar_defflags);
var->ResetToDefault();
}
}
CCMD (get)
{
FBaseCVar *var, *prev;