diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2023-09-17 01:41:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-17 01:41:27 +0200 |
commit | b7823492e802456d44e4919940267081bf436f08 (patch) | |
tree | 818e06bafd5c01691028a7b2ca7265cc603e905d /NorthstarDLL/mods/modmanager.cpp | |
parent | 8c0ce09205ecc28073468b55964f4433f16e3a65 (diff) | |
parent | af1df846a32f66e02ab1dbb1b7d12007e893204c (diff) | |
download | NorthstarLauncher-b7823492e802456d44e4919940267081bf436f08.tar.gz NorthstarLauncher-b7823492e802456d44e4919940267081bf436f08.zip |
Merge branch 'main' into indentation
Diffstat (limited to 'NorthstarDLL/mods/modmanager.cpp')
-rw-r--r-- | NorthstarDLL/mods/modmanager.cpp | 39 |
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()); + } } } } |