aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/mods/modmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/mods/modmanager.cpp')
-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());
+ }
}
}
}