diff options
Diffstat (limited to 'primedev')
-rw-r--r-- | primedev/mods/modmanager.cpp | 39 | ||||
-rw-r--r-- | primedev/mods/modmanager.h | 10 | ||||
-rw-r--r-- | primedev/plugins/pluginmanager.cpp | 4 |
3 files changed, 38 insertions, 15 deletions
diff --git a/primedev/mods/modmanager.cpp b/primedev/mods/modmanager.cpp index 45eddd3e..cc6195c7 100644 --- a/primedev/mods/modmanager.cpp +++ b/primedev/mods/modmanager.cpp @@ -615,8 +615,9 @@ void ModManager::LoadMods() // ensure dirs exist fs::remove_all(GetCompiledAssetsPath()); - fs::create_directories(GetModFolderPath()); - fs::create_directories(GetThunderstoreModFolderPath()); + fs::create_directories(GetCoreModFolderPath()); + fs::create_directories(GetManualModFolderPath()); + fs::create_directories(GetThunderstoreLegacyModFolderPath()); fs::create_directories(GetRemoteModFolderPath()); m_DependencyConstants.clear(); @@ -638,11 +639,27 @@ void ModManager::LoadMods() } // get mod directories - std::filesystem::directory_iterator classicModsDir = fs::directory_iterator(GetModFolderPath()); + std::filesystem::directory_iterator coreModsDir = fs::directory_iterator(GetCoreModFolderPath()); + std::filesystem::directory_iterator manualModsDir = fs::directory_iterator(GetManualModFolderPath()); std::filesystem::directory_iterator remoteModsDir = fs::directory_iterator(GetRemoteModFolderPath()); - std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath()); + std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreLegacyModFolderPath()); - for (fs::directory_entry dir : classicModsDir) + // Set up regex for `Northstar.*` pattern + std::regex northstar_pattern(R"(.*\\Northstar\..+)"); + for (fs::directory_entry dir : coreModsDir) + { + if (!std::regex_match(dir.path().string(), northstar_pattern)) + { + spdlog::warn( + "The following directory did not match 'Northstar.*' and is most likely an incorrectly manually installed mod: {}", + dir.path().string()); + continue; // skip loading mod that doesn't match + } + if (fs::exists(dir.path() / "mod.json")) + modDirs.push_back(dir.path()); + } + + for (fs::directory_entry dir : manualModsDir) if (fs::exists(dir.path() / "mod.json")) modDirs.push_back(dir.path()); @@ -1135,13 +1152,17 @@ void ConCommand_reload_mods(const CCommand& args) g_pModManager->LoadMods(); } -fs::path GetModFolderPath() +fs::path GetCoreModFolderPath() +{ + return fs::path(GetNorthstarPrefix() + CORE_MOD_FOLDER_SUFFIX); +} +fs::path GetManualModFolderPath() { - return fs::path(GetNorthstarPrefix() + MOD_FOLDER_SUFFIX); + return fs::path(GetNorthstarPrefix() + MANUAL_MOD_FOLDER_SUFFIX); } -fs::path GetThunderstoreModFolderPath() +fs::path GetThunderstoreLegacyModFolderPath() { - return fs::path(GetNorthstarPrefix() + THUNDERSTORE_MOD_FOLDER_SUFFIX); + return fs::path(GetNorthstarPrefix() + THUNDERSTORE_LEGACY_MOD_FOLDER_SUFFIX); } fs::path GetRemoteModFolderPath() { diff --git a/primedev/mods/modmanager.h b/primedev/mods/modmanager.h index 95a8fe12..3df7fe53 100644 --- a/primedev/mods/modmanager.h +++ b/primedev/mods/modmanager.h @@ -11,8 +11,9 @@ namespace fs = std::filesystem; -const std::string MOD_FOLDER_SUFFIX = "\\mods"; -const std::string THUNDERSTORE_MOD_FOLDER_SUFFIX = "\\packages"; +const std::string CORE_MOD_FOLDER_SUFFIX = "\\mods\\core"; +const std::string MANUAL_MOD_FOLDER_SUFFIX = "\\mods\\manual"; +const std::string THUNDERSTORE_LEGACY_MOD_FOLDER_SUFFIX = "\\mods\\thunderstore-legacy"; const std::string REMOTE_MOD_FOLDER_SUFFIX = "\\runtime\\remote\\mods"; const fs::path MOD_OVERRIDE_DIR = "mod"; const std::string COMPILED_ASSETS_SUFFIX = "\\runtime\\compiled"; @@ -181,9 +182,10 @@ public: void BuildKBActionsList(); }; -fs::path GetModFolderPath(); +fs::path GetCoreModFolderPath(); +fs::path GetManualModFolderPath(); fs::path GetRemoteModFolderPath(); -fs::path GetThunderstoreModFolderPath(); +fs::path GetThunderstoreLegacyModFolderPath(); fs::path GetCompiledAssetsPath(); extern ModManager* g_pModManager; diff --git a/primedev/plugins/pluginmanager.cpp b/primedev/plugins/pluginmanager.cpp index 14d5692b..0b89f76e 100644 --- a/primedev/plugins/pluginmanager.cpp +++ b/primedev/plugins/pluginmanager.cpp @@ -60,7 +60,7 @@ bool PluginManager::LoadPlugins(bool reloaded) return false; } - fs::create_directories(GetThunderstoreModFolderPath()); + fs::create_directories(GetThunderstoreLegacyModFolderPath()); std::vector<fs::path> paths; @@ -73,7 +73,7 @@ bool PluginManager::LoadPlugins(bool reloaded) FindPlugins(pluginPath, paths); // Special case for Thunderstore mods dir - std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath()); + std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreLegacyModFolderPath()); // 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) |