From f015a1b339c8ecb53e6d9b4e9347e2d13d739837 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Mon, 3 Nov 2025 18:48:48 -0700 Subject: [PATCH] Apply expected lexicographical sort to initial and new mod addition list. (#5904) --- soh/soh/Enhancements/mod_menu.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/mod_menu.cpp b/soh/soh/Enhancements/mod_menu.cpp index 9e3fda114..e60eee7e9 100644 --- a/soh/soh/Enhancements/mod_menu.cpp +++ b/soh/soh/Enhancements/mod_menu.cpp @@ -55,6 +55,7 @@ void SetEnabledModsCVarValue() { } CVarSetString(CVAR_ENABLED_MODS_NAME, s.c_str()); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); } void AfterModChange() { @@ -128,8 +129,9 @@ void UpdateModFiles(bool init = false, bool reset = false) { disabledModFiles.clear(); unsupportedFiles.clear(); filePaths.clear(); - std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName); bool changed = false; + std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName); + std::map tempMods; if (modsPath.length() > 0 && std::filesystem::exists(modsPath)) { std::vector enabledFiles; if (std::filesystem::is_directory(modsPath)) { @@ -147,11 +149,17 @@ void UpdateModFiles(bool init = false, bool reset = false) { bool enabled = std::find(enabledModFiles.begin(), enabledModFiles.end(), filename) != enabledModFiles.end(); if (!enabled) { - enabledModFiles.push_back(filename); - changed = true; + tempMods.emplace(p.path().lexically_normal().generic_string(), filename); } filePaths.emplace(filename, p.path()); } + if (tempMods.size() > 0) { + changed = true; + for (auto [path, name] : tempMods) { + enabledModFiles.push_back(name); + } + tempMods.clear(); + } if (init) { std::vector enabledTemp(enabledModFiles); for (std::string mod : enabledTemp) { @@ -159,13 +167,14 @@ void UpdateModFiles(bool init = false, bool reset = false) { GetArchiveManager()->AddArchive(filePaths.at(mod).generic_string()); } else { enabledModFiles.erase(std::find(enabledModFiles.begin(), enabledModFiles.end(), mod)); + changed = true; } } } } - } - if (changed) { - SetEnabledModsCVarValue(); + if (changed) { + SetEnabledModsCVarValue(); + } } }