aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--primedev/mods/modmanager.cpp39
-rw-r--r--primedev/mods/modmanager.h10
-rw-r--r--primedev/plugins/pluginmanager.cpp4
3 files changed, 38 insertions, 15 deletions
diff --git a/primedev/mods/modmanager.cpp b/primedev/mods/modmanager.cpp
index 52fc6e8b..056ea136 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());
@@ -1166,13 +1183,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 7859d618..68a7c5d0 100644
--- a/primedev/mods/modmanager.h
+++ b/primedev/mods/modmanager.h
@@ -12,8 +12,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";
@@ -198,9 +199,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)