Skip to content

Commit

Permalink
Implement platform agnostic mod load order (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez authored Nov 26, 2024
1 parent 851c708 commit 268d123
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions mm/2s2h/BenPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 };

OTRGlobals::OTRGlobals() {
std::vector<std::string> archiveFiles;
std::vector<std::string> patchFiles;
std::string mmPathO2R = Ship::Context::LocateFileAcrossAppDirs("mm.o2r", appShortName);
std::string mmPathZIP = Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName);
if (std::filesystem::exists(mmPathO2R)) {
Expand All @@ -136,16 +137,27 @@ OTRGlobals::OTRGlobals() {
if (std::filesystem::is_directory(patchesPath)) {
for (const auto& p : std::filesystem::recursive_directory_iterator(patchesPath)) {
if (StringHelper::IEquals(p.path().extension().string(), ".o2r")) {
archiveFiles.push_back(p.path().generic_string());
patchFiles.push_back(p.path().generic_string());
} else if (StringHelper::IEquals(p.path().extension().string(), ".zip")) {
archiveFiles.push_back(p.path().generic_string());
patchFiles.push_back(p.path().generic_string());
} else if (StringHelper::IEquals(p.path().extension().string(), ".otr")) {
archiveFiles.push_back(p.path().generic_string());
patchFiles.push_back(p.path().generic_string());
}
}
}
}

// Sort all patch files from the mods directory lexigraphically to guarantee sort order across all platforms
std::sort(patchFiles.begin(), patchFiles.end(), [](const std::string& a, const std::string& b) {
// Sort based on file name alone, excluding file extension, so that order is not impacted by archive format
const std::string aFileName = a.substr(0, a.find_last_of("."));
const std::string bFileName = b.substr(0, b.find_last_of("."));
return std::lexicographical_compare(aFileName.begin(), aFileName.end(), bFileName.begin(), bFileName.end(),
[](char c1, char c2) { return std::tolower(c1) < std::tolower(c2); });
});

archiveFiles.insert(archiveFiles.end(), patchFiles.begin(), patchFiles.end());

std::unordered_set<uint32_t> validHashes = { MM_NTSC_US_10, MM_NTSC_US_GC };

// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
Expand Down

0 comments on commit 268d123

Please sign in to comment.