Retry setting unknown cvars after CVARINFOs are processed.

- Fixed: Using +set cvarname and +cvarname on the command line would not
  work if cvarname was defined in CVARINFO. This should be the proper way to fix
  it. Rather than move all command line execution after loading CVARINFO,
  keep command line execution before wads are loaded. If an attempt is
  made to set an unknown cvar or to run an unknown command (which could
  potentially be shorthand for setting an unknown cvar), save it and try
  running it again after all CVARINFOs have been handled.
This commit is contained in:
Randy Heit 2014-12-26 17:21:57 -06:00
parent f00c8e1943
commit 4017a6d864
3 changed files with 48 additions and 6 deletions

View file

@ -185,6 +185,9 @@ static const char *KeyConfCommands[] =
"clearplayerclasses"
};
static TArray<FString> StoredStartupSets;
static bool RunningStoredStartups;
// CODE --------------------------------------------------------------------
IMPLEMENT_CLASS (DWaitingCommand)
@ -537,6 +540,18 @@ void ResetButtonStates ()
}
}
void C_ExecStoredSets()
{
assert(!RunningStoredStartups);
RunningStoredStartups = true;
for (unsigned i = 0; i < StoredStartupSets.Size(); ++i)
{
C_DoCommand(StoredStartupSets[i]);
}
StoredStartupSets.Clear();
RunningStoredStartups = false;
}
void C_DoCommand (const char *cmd, int keynum)
{
FConsoleCommand *com;
@ -612,7 +627,22 @@ void C_DoCommand (const char *cmd, int keynum)
if ( (com = FindNameInHashTable (Commands, beg, len)) )
{
if (gamestate != GS_STARTUP || ParsingKeyConf ||
if (gamestate == GS_STARTUP && !RunningStoredStartups &&
len == 3 && strnicmp(beg, "set", 3) == 0)
{
// Save setting of unknown cvars for later, in case a loaded wad has a
// CVARINFO that defines it.
FCommandLine args(beg);
if (args.argc() > 1 && FindCVar(args[1], NULL) == NULL)
{
StoredStartupSets.Push(beg);
}
else
{
com->Run(args, players[consoleplayer].mo, keynum);
}
}
else if (gamestate != GS_STARTUP || ParsingKeyConf ||
(len == 3 && strnicmp (beg, "set", 3) == 0) ||
(len == 7 && strnicmp (beg, "logfile", 7) == 0) ||
(len == 9 && strnicmp (beg, "unbindall", 9) == 0) ||
@ -657,6 +687,13 @@ void C_DoCommand (const char *cmd, int keynum)
}
else
{ // We don't know how to handle this command
if (gamestate == GS_STARTUP && !RunningStoredStartups)
{
// Save it for later, in case a CVARINFO defines it.
StoredStartupSets.Push(beg);
}
else
{
char cmdname[64];
size_t minlen = MIN<size_t> (len, 63);
@ -666,6 +703,7 @@ void C_DoCommand (const char *cmd, int keynum)
}
}
}
}
void AddCommandString (char *cmd, int keynum)
{

View file

@ -42,6 +42,7 @@ class APlayerPawn;
extern bool CheckCheatmode (bool printmsg = true);
void C_ExecCmdLineParams ();
void C_ExecStoredSets();
// Add commands to the console as if they were typed in. Can handle wait
// and semicolon-separated commands. This function may modify the source

View file

@ -2290,6 +2290,9 @@ void D_DoomMain (void)
// Now that wads are loaded, define mod-specific cvars.
ParseCVarInfo();
// Try setting previously unknown cvars again, as a CVARINFO may have made them known.
C_ExecStoredSets();
// [RH] Initialize localizable strings.
GStrings.LoadStrings (false);