aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Raes <contact@remyraes.com>2023-09-15 00:31:37 +0200
committerGitHub <noreply@github.com>2023-09-15 00:31:37 +0200
commite51d345a20db6dc59154678da2fa864d16f8100d (patch)
tree050a08ac6b435c842abb08c6310643005f8a76be
parenta27368df36fc47e67cfe0876ae4d75de066efded (diff)
downloadNorthstarLauncher-e51d345a20db6dc59154678da2fa864d16f8100d.tar.gz
NorthstarLauncher-e51d345a20db6dc59154678da2fa864d16f8100d.zip
feat: Enforce Thunderstore format for remote mods (#535)
* feat: enforce Thunderstore format for remote mods * refactor: remove remote mods directory from "classic" mod loading --------- Co-authored-by: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>
-rw-r--r--NorthstarDLL/mods/modmanager.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/NorthstarDLL/mods/modmanager.cpp b/NorthstarDLL/mods/modmanager.cpp
index 044ec6d4..1ca51ad7 100644
--- a/NorthstarDLL/mods/modmanager.cpp
+++ b/NorthstarDLL/mods/modmanager.cpp
@@ -612,32 +612,35 @@ void ModManager::LoadMods()
// get mod directories
std::filesystem::directory_iterator classicModsDir = fs::directory_iterator(GetModFolderPath());
std::filesystem::directory_iterator remoteModsDir = fs::directory_iterator(GetRemoteModFolderPath());
+ std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath());
- for (std::filesystem::directory_iterator modIterator : {classicModsDir, remoteModsDir})
- for (fs::directory_entry dir : modIterator)
- if (fs::exists(dir.path() / "mod.json"))
- modDirs.push_back(dir.path());
+ for (fs::directory_entry dir : classicModsDir)
+ if (fs::exists(dir.path() / "mod.json"))
+ modDirs.push_back(dir.path());
- // Special case for Thunderstore mods dir
- std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath());
+ // Special case for Thunderstore and remote mods directories
// Set up regex for `AUTHOR-MOD-VERSION` pattern
std::regex pattern(R"(.*\\([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)-(\d+\.\d+\.\d+))");
- for (fs::directory_entry dir : thunderstoreModsDir)
+
+ for (fs::directory_iterator dirIterator : {thunderstoreModsDir, remoteModsDir})
{
- fs::path modsDir = dir.path() / "mods"; // Check for mods folder in the Thunderstore mod
- // Use regex to match `AUTHOR-MOD-VERSION` pattern
- if (!std::regex_match(dir.path().string(), pattern))
- {
- spdlog::warn("The following directory did not match 'AUTHOR-MOD-VERSION': {}", dir.path().string());
- continue; // skip loading mod that doesn't match
- }
- if (fs::exists(modsDir) && fs::is_directory(modsDir))
+ for (fs::directory_entry dir : dirIterator)
{
- for (fs::directory_entry subDir : fs::directory_iterator(modsDir))
+ fs::path modsDir = dir.path() / "mods"; // Check for mods folder in the Thunderstore mod
+ // Use regex to match `AUTHOR-MOD-VERSION` pattern
+ if (!std::regex_match(dir.path().string(), pattern))
{
- if (fs::exists(subDir.path() / "mod.json"))
+ spdlog::warn("The following directory did not match 'AUTHOR-MOD-VERSION': {}", dir.path().string());
+ continue; // skip loading mod that doesn't match
+ }
+ if (fs::exists(modsDir) && fs::is_directory(modsDir))
+ {
+ for (fs::directory_entry subDir : fs::directory_iterator(modsDir))
{
- modDirs.push_back(subDir.path());
+ if (fs::exists(subDir.path() / "mod.json"))
+ {
+ modDirs.push_back(subDir.path());
+ }
}
}
}