From 27d4f2d3d6555c4f4b0569e4edccf2dab571fddd Mon Sep 17 00:00:00 2001 From: Emanuele Disco Date: Wed, 10 Jul 2024 11:27:33 +0900 Subject: [PATCH] fix: RemoveArgs only remove the first occurence of an argument Make sure we remove all the occurence of the passed argument This fix profile loading not working correctly when there are two occurence of iwad, one passed through command line and another from the profile commandline.txt if the cvar cmdlineprofile is set before starting the game (cherry picked from commit b3654feaf4afcc01b3bf4064c04528cb6bee59c8) --- src/common/utility/m_argv.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/common/utility/m_argv.cpp b/src/common/utility/m_argv.cpp index b9b05c3e9b8..9e63f56daa5 100644 --- a/src/common/utility/m_argv.cpp +++ b/src/common/utility/m_argv.cpp @@ -262,16 +262,21 @@ FString FArgs::TakeValue(const char *check) void FArgs::RemoveArgs(const char *check) { - int i = CheckParm(check); - - if (i > 0 && i < (int)Argv.Size() - 1) + int i = 0; + do { - do + i = CheckParm(check); + + if (i > 0 && i < (int)Argv.Size() - 1) { - RemoveArg(i); + do + { + RemoveArg(i); + } + while (Argv[i][0] != '+' && Argv[i][0] != '-' && i < (int)Argv.Size() - 1); } - while (Argv[i][0] != '+' && Argv[i][0] != '-' && i < (int)Argv.Size() - 1); } + while (i > 0); } //===========================================================================