Apply expected lexicographical sort to initial and new mod addition list. (#5904)
This commit is contained in:
@@ -55,6 +55,7 @@ void SetEnabledModsCVarValue() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CVarSetString(CVAR_ENABLED_MODS_NAME, s.c_str());
|
CVarSetString(CVAR_ENABLED_MODS_NAME, s.c_str());
|
||||||
|
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AfterModChange() {
|
void AfterModChange() {
|
||||||
@@ -128,8 +129,9 @@ void UpdateModFiles(bool init = false, bool reset = false) {
|
|||||||
disabledModFiles.clear();
|
disabledModFiles.clear();
|
||||||
unsupportedFiles.clear();
|
unsupportedFiles.clear();
|
||||||
filePaths.clear();
|
filePaths.clear();
|
||||||
std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName);
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName);
|
||||||
|
std::map<std::string, std::string> tempMods;
|
||||||
if (modsPath.length() > 0 && std::filesystem::exists(modsPath)) {
|
if (modsPath.length() > 0 && std::filesystem::exists(modsPath)) {
|
||||||
std::vector<std::filesystem::path> enabledFiles;
|
std::vector<std::filesystem::path> enabledFiles;
|
||||||
if (std::filesystem::is_directory(modsPath)) {
|
if (std::filesystem::is_directory(modsPath)) {
|
||||||
@@ -147,11 +149,17 @@ void UpdateModFiles(bool init = false, bool reset = false) {
|
|||||||
bool enabled =
|
bool enabled =
|
||||||
std::find(enabledModFiles.begin(), enabledModFiles.end(), filename) != enabledModFiles.end();
|
std::find(enabledModFiles.begin(), enabledModFiles.end(), filename) != enabledModFiles.end();
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
enabledModFiles.push_back(filename);
|
tempMods.emplace(p.path().lexically_normal().generic_string(), filename);
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
filePaths.emplace(filename, p.path());
|
filePaths.emplace(filename, p.path());
|
||||||
}
|
}
|
||||||
|
if (tempMods.size() > 0) {
|
||||||
|
changed = true;
|
||||||
|
for (auto [path, name] : tempMods) {
|
||||||
|
enabledModFiles.push_back(name);
|
||||||
|
}
|
||||||
|
tempMods.clear();
|
||||||
|
}
|
||||||
if (init) {
|
if (init) {
|
||||||
std::vector<std::string> enabledTemp(enabledModFiles);
|
std::vector<std::string> enabledTemp(enabledModFiles);
|
||||||
for (std::string mod : enabledTemp) {
|
for (std::string mod : enabledTemp) {
|
||||||
@@ -159,13 +167,14 @@ void UpdateModFiles(bool init = false, bool reset = false) {
|
|||||||
GetArchiveManager()->AddArchive(filePaths.at(mod).generic_string());
|
GetArchiveManager()->AddArchive(filePaths.at(mod).generic_string());
|
||||||
} else {
|
} else {
|
||||||
enabledModFiles.erase(std::find(enabledModFiles.begin(), enabledModFiles.end(), mod));
|
enabledModFiles.erase(std::find(enabledModFiles.begin(), enabledModFiles.end(), mod));
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (changed) {
|
||||||
if (changed) {
|
SetEnabledModsCVarValue();
|
||||||
SetEnabledModsCVarValue();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user