From 092fd2934e96352da25a082f86f099e5de4862c2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 29 Apr 2022 15:10:49 +0200 Subject: [PATCH] -preparations for adding command line args in IWAD selector The current macOS handler cheats by restarting the engine. To make this cross-platform and not defeat the debugger it cannot do that. --- src/d_main.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 516ac2b1f7..3fc5d2d134 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1917,17 +1917,21 @@ static void SetMapxxFlag() // //========================================================================== -static void D_DoomInit() +static void D_CoalesceFileTypes() { - // Check response files before coalescing file parameters. - M_FindResponseFile (); - // Combine different file parameters with their pre-switch bits. Args->CollectFiles("-deh", ".deh"); Args->CollectFiles("-bex", ".bex"); Args->CollectFiles("-exec", ".cfg"); Args->CollectFiles("-playdemo", ".lmp"); Args->CollectFiles("-file", NULL); // anything left goes after -file +} + +static void D_DoomInit() +{ + // Check response files before coalescing file parameters. + M_FindResponseFile (); + D_CoalesceFileTypes(); gamestate = GS_STARTUP; @@ -2978,6 +2982,13 @@ static FILE* D_GetHashFile() static int D_InitGame(const FIWADInfo* iwad_info, TArray allwads) { + // This is for when +logfile gets entered in the IWAD selector. The original one from the command line will not be present anymore when we get here. + FString logfile = Args->TakeValue("+logfile"); + if (logfile.IsNotEmpty()) + { + execLogfile(logfile); + } + gameinfo.gametype = iwad_info->gametype; gameinfo.flags = iwad_info->flags; gameinfo.nokeyboardcheats = iwad_info->nokeyboardcheats; @@ -3568,6 +3579,16 @@ static int D_DoomMain_Internal (void) { I_FatalError ("You cannot -file with the shareware version. Register!"); } + // If the user enters -file... in the IWAD selector we need to extend the file list here. + // -iwad will be ignored because we cannot deal with that without actually restarting the engine. + // all other commands with the exception of -errorlog and -config will be checked later. + // -errorlog is for batch checks so trying to handle it here is rather pointless. + // -config needs to be checked before and IWAD setup is done so adding it to the IWAD selector will just ignore it. + + pwads.Clear(); + D_CoalesceFileTypes(); // redo for additional parameters from the IWAD selector. + GetCmdLineFiles(pwads); // also redo for stuff from the IWAD selector. + allwads.Append(std::move(pwads)); lastIWAD = iwad;