diff --git a/source/core/gameconfigfile.cpp b/source/core/gameconfigfile.cpp index baa8ac907..115c737be 100644 --- a/source/core/gameconfigfile.cpp +++ b/source/core/gameconfigfile.cpp @@ -503,6 +503,21 @@ CCMD (whereisini) FGameConfigFile* GameConfig; static FString GameName; +//========================================================================== +// +// D_MultiExec +// +//========================================================================== + +FExecList *D_MultiExec (FArgs *list, FExecList *exec) +{ + for (int i = 0; i < list->NumArgs(); ++i) + { + exec = C_ParseExecFile(list->GetArg(i), exec); + } + return exec; +} + void G_LoadConfig() { GameConfig = new FGameConfigFile(); @@ -513,6 +528,30 @@ void G_ReadConfig(const char* game) { GameConfig->DoGameSetup(game); GameConfig->DoKeySetup(game); + + // Process automatically executed files + FExecList *exec; + FArgs *execFiles = new FArgs; + GameConfig->AddAutoexec(execFiles, game); + exec = D_MultiExec(execFiles, NULL); + delete execFiles; + + // Process .cfg files at the start of the command line. + execFiles = Args->GatherFiles ("-exec"); + exec = D_MultiExec(execFiles, exec); + delete execFiles; + + // [RH] process all + commands on the command line + exec = C_ParseCmdLineParams(exec); + + // Actually exec command line commands and exec files. + if (exec != NULL) + { + exec->ExecCommands(); + delete exec; + exec = NULL; + } + FBaseCVar::EnableCallbacks(); GameName = game; } diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index dc0983bec..d843bf1d1 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -867,9 +867,6 @@ int RunGame() I_FatalError("There was a problem initializing the Build engine: %s\n", engineerrstr); } - auto exec = C_ParseCmdLineParams(nullptr); - if (exec) exec->ExecCommands(); - SetupGameButtons(); gameinfo.mBackButton = "engine/graphics/m_back.png"; gi->app_init();