From f40e52ab34e183f54749a50d20698dfec59dabbc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 May 2021 22:56:53 +0200 Subject: [PATCH] - fixed issues with validation of command line specified main game GRP file name. --- source/core/gamecontrol.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 362df73ad..df5afb241 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -659,13 +659,16 @@ static TArray SetupGame() { for (auto& str : game) { + int g = 0; for (auto& grp : groups) { if (grp.FileInfo.gameid.CompareNoCase(str) == 0) { userConfig.gamegrp = grp.FileName; + groupno = g; goto foundit; } + g++; } } } @@ -673,16 +676,18 @@ static TArray SetupGame() // If the user has specified a file name, let's see if we know it. // - if (userConfig.gamegrp.Len()) + if (groupno == -1 && userConfig.gamegrp.Len()) { - FString gamegrplower = "/" + userConfig.gamegrp.MakeLower(); + FString gamegrplower = userConfig.gamegrp.MakeLower(); + if (gamegrplower[1] != ':' || gamegrplower[2] != '/') gamegrplower.Insert(0, "/"); int g = 0; for (auto& grp : groups) { auto grplower = grp.FileName.MakeLower(); - grplower.Substitute("\\", "/"); - if (grplower.LastIndexOf(gamegrplower) == grplower.Len() - gamegrplower.Len()) + FixPathSeperator(grplower); + int pos = grplower.LastIndexOf(gamegrplower); + if (pos >= 0 && pos == grplower.Len() - gamegrplower.Len()) { groupno = g; break;