From 4b55e7ad14d8471cdbb57ce44c5ccb42763d5d1b Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 8 Aug 2025 02:49:15 -0400 Subject: [PATCH] Reverse iteration order of ValidateIWADs Scenario: - Using `-iwad` to explicitly use an IWAD outside of your search paths - You have other, older versions hiding in your search paths - You then change your IWADINFO's BannerColors, cue confusion Because `IdentifyVersion` does search paths then -iwad, and `ValidateIWADs` iterates them in normal order, the file that gets to determine the IWAD startup settings is whatever file is found on the system instead of the file specifically requested. --- src/d_iwad.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index f4cdf724e..03cfa6b42 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -543,8 +543,16 @@ void FIWadManager::ValidateIWADs() { TArray returns; unsigned originalsize = mIWadInfos.Size(); - for (auto &p : mFoundWads) + + // Iterating normally will give CheckIWADInfo name conflicts priority to + // whatever file is found first, rather than the file that the user + // specifically requests with -iwad, because IdentifyVersion appends + // the -iwad file to the end of the list. (And it's annoying to change + // to be the other way around.) + for (int i = mFoundWads.SSize() - 1; i >= 0; i--) { + auto &p = mFoundWads[i]; + int index; auto x = strrchr(p.mFullPath.GetChars(), '.'); if (x != nullptr && (!stricmp(x, ".iwad") || !stricmp(x, ".ipk3") || !stricmp(x, ".ipk7")))