Skip to content

Commit 39fc35e

Browse files
committed
test
1 parent c7e2d7e commit 39fc35e

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

primedev/mods/modmanager.cpp

+28-8
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ void ModManager::LoadMods()
113113

114114
// ensure dirs exist
115115
fs::remove_all(GetCompiledAssetsPath());
116-
fs::create_directories(GetModFolderPath());
117-
fs::create_directories(GetThunderstoreModFolderPath());
116+
fs::create_directories(GetCoreModFolderPath());
117+
fs::create_directories(GetManualModFolderPath());
118+
fs::create_directories(GetThunderstoreLegacyModFolderPath());
118119
fs::create_directories(GetRemoteModFolderPath());
119120

120121
m_DependencyConstants.clear();
@@ -526,14 +527,29 @@ void ModManager::SearchFilesystemForMods()
526527
m_LoadedMods.clear();
527528

528529
// get mod directories
529-
std::filesystem::directory_iterator classicModsDir = fs::directory_iterator(GetModFolderPath());
530+
std::filesystem::directory_iterator coreModsDir = fs::directory_iterator(GetCoreModFolderPath());
531+
std::filesystem::directory_iterator manualModsDir = fs::directory_iterator(GetManualModFolderPath());
530532
std::filesystem::directory_iterator remoteModsDir = fs::directory_iterator(GetRemoteModFolderPath());
531-
std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath());
533+
std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreLegacyModFolderPath());
532534

533-
for (fs::directory_entry dir : classicModsDir)
535+
// Set up regex for `Northstar.*` pattern
536+
std::regex northstar_pattern(R"(.*\\Northstar\..+)");
537+
for (fs::directory_entry dir : coreModsDir)
538+
{
539+
if (!std::regex_match(dir.path().string(), northstar_pattern))
540+
{
541+
spdlog::warn(
542+
"The following directory did not match 'Northstar.*' and is most likely an incorrectly manually installed mod: {}",
543+
dir.path().string());
544+
continue; // skip loading mod that doesn't match
545+
}
534546
if (fs::exists(dir.path() / "mod.json"))
535547
modDirs.push_back(dir.path());
548+
}
536549

550+
for (fs::directory_entry dir : manualModsDir)
551+
if (fs::exists(dir.path() / "mod.json"))
552+
modDirs.push_back(dir.path());
537553
// Special case for Thunderstore and remote mods directories
538554
// Set up regex for `AUTHOR-MOD-VERSION` pattern
539555
std::regex pattern(R"(.*\\([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)-(\d+\.\d+\.\d+))");
@@ -673,13 +689,17 @@ void ConCommand_reload_mods(const CCommand& args)
673689
g_pModManager->LoadMods();
674690
}
675691

676-
fs::path GetModFolderPath()
692+
fs::path GetCoreModFolderPath()
693+
{
694+
return fs::path(GetNorthstarPrefix() + CORE_MOD_FOLDER_SUFFIX);
695+
}
696+
fs::path GetManualModFolderPath()
677697
{
678698
return fs::path(GetNorthstarPrefix() + MOD_FOLDER_SUFFIX);
679699
}
680-
fs::path GetThunderstoreModFolderPath()
700+
fs::path GetThunderstoreLegacyModFolderPath()
681701
{
682-
return fs::path(GetNorthstarPrefix() + THUNDERSTORE_MOD_FOLDER_SUFFIX);
702+
return fs::path(GetNorthstarPrefix() + THUNDERSTORE_LEGACY_MOD_FOLDER_SUFFIX);
683703
}
684704
fs::path GetRemoteModFolderPath()
685705
{

primedev/mods/modmanager.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
namespace fs = std::filesystem;
1515

16-
const std::string MOD_FOLDER_SUFFIX = "\\mods";
17-
const std::string THUNDERSTORE_MOD_FOLDER_SUFFIX = "\\packages";
16+
const std::string CORE_MOD_FOLDER_SUFFIX = "\\mods\\core";
17+
const std::string MANUAL_MOD_FOLDER_SUFFIX = "\\mods\\manual";
18+
const std::string THUNDERSTORE_LEGACY_MOD_FOLDER_SUFFIX = "\\mods\\thunderstore-legacy";
1819
const std::string REMOTE_MOD_FOLDER_SUFFIX = "\\runtime\\remote\\mods";
1920
const fs::path MOD_OVERRIDE_DIR = "mod";
2021
const std::string COMPILED_ASSETS_SUFFIX = "\\runtime\\compiled";
@@ -72,9 +73,11 @@ class ModManager
7273
void BuildKBActionsList();
7374
};
7475

76+
fs::path GetCoreModFolderPath();
77+
fs::path GetManualModFolderPath();
7578
fs::path GetModFolderPath();
7679
fs::path GetRemoteModFolderPath();
77-
fs::path GetThunderstoreModFolderPath();
80+
fs::path GetThunderstoreLegacyModFolderPath();
7881
fs::path GetCompiledAssetsPath();
7982

8083
extern ModManager* g_pModManager;

primedev/plugins/pluginmanager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ bool PluginManager::LoadPlugins(bool reloaded)
6161
return false;
6262
}
6363

64-
fs::create_directories(GetThunderstoreModFolderPath());
64+
fs::create_directories(GetThunderstoreLegacyModFolderPath());
6565

6666
std::vector<fs::path> paths;
6767

@@ -74,7 +74,7 @@ bool PluginManager::LoadPlugins(bool reloaded)
7474
FindPlugins(pluginPath, paths);
7575

7676
// Special case for Thunderstore mods dir
77-
std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreModFolderPath());
77+
std::filesystem::directory_iterator thunderstoreModsDir = fs::directory_iterator(GetThunderstoreLegacyModFolderPath());
7878
// Set up regex for `AUTHOR-MOD-VERSION` pattern
7979
std::regex pattern(R"(.*\\([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)-(\d+\.\d+\.\d+))");
8080
for (fs::directory_entry dir : thunderstoreModsDir)

0 commit comments

Comments
 (0)