aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NorthstarDLL/NorthstarDLL.vcxproj2
-rw-r--r--NorthstarDLL/NorthstarDLL.vcxproj.filters2
-rw-r--r--NorthstarDLL/mods/modmanager.cpp24
-rw-r--r--NorthstarDLL/mods/modmanager.h23
4 files changed, 27 insertions, 24 deletions
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj b/NorthstarDLL/NorthstarDLL.vcxproj
index e26f5762..0d8aebfc 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj
+++ b/NorthstarDLL/NorthstarDLL.vcxproj
@@ -509,7 +509,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="plugins\plugins.cpp" />
- <ClCompile Include="reloadturrets.cpp" />
+ <ClCompile Include="reloadmodturrets.cpp" />
<ClCompile Include="scripts\client\clientchathooks.cpp" />
<ClCompile Include="scripts\client\cursorposition.cpp" />
<ClCompile Include="scripts\client\scriptbrowserhooks.cpp" />
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj.filters b/NorthstarDLL/NorthstarDLL.vcxproj.filters
index 44687ba6..ed634a4c 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj.filters
+++ b/NorthstarDLL/NorthstarDLL.vcxproj.filters
@@ -1441,7 +1441,7 @@
<ClCompile Include="mods\reload\reloadmodweapons_misc.cpp">
<Filter>Source Files\mods\reload</Filter>
</ClCompile>
- <ClCompile Include="reloadturrets.cpp">
+ <ClCompile Include="reloadmodturrets.cpp">
<Filter>Source Files\mods\reload</Filter>
</ClCompile>
</ItemGroup>
diff --git a/NorthstarDLL/mods/modmanager.cpp b/NorthstarDLL/mods/modmanager.cpp
index 38305770..f97624be 100644
--- a/NorthstarDLL/mods/modmanager.cpp
+++ b/NorthstarDLL/mods/modmanager.cpp
@@ -19,6 +19,12 @@
#include <sstream>
#include <vector>
+// precaculated string hashes
+// note: use backslashes for these, since we use lexically_normal for file paths which uses them
+const size_t hScriptsRsonHash = STR_HASH("scripts\\vscripts\\scripts.rson");
+const size_t hPdefHash = STR_HASH("cfg\\server\\persistent_player_data_version_231.pdef"); // this can have multiple versions, but we use 231 so that's what we hash
+const size_t hKBActHash = STR_HASH("scripts\\kb_act.lst");
+
ModManager* g_pModManager;
Mod::Mod(fs::path modDir, std::string sJson, bool bRemote)
@@ -283,14 +289,6 @@ Mod::Mod(fs::path modDir, std::string sJson, bool bRemote)
ModManager::ModManager()
{
- // precaculated string hashes
- // note: use backslashes for these, since we use lexically_normal for file paths which uses them
- m_hScriptsRsonHash = STR_HASH("scripts\\vscripts\\scripts.rson");
- m_hPdefHash = STR_HASH(
- "cfg\\server\\persistent_player_data_version_231.pdef" // this can have multiple versions, but we use 231 so that's what we hash
- );
- m_hKBActHash = STR_HASH("scripts\\kb_act.lst");
-
m_LastModLoadState = nullptr;
m_ModLoadState = new ModLoadState;
@@ -351,7 +349,6 @@ auto ModConCommandCallback(const CCommand& command)
-
void ModManager::LoadMods(bool bReloadAssets, bool bDeferredAssetReload)
{
// reset state of all currently loaded mods, if we've loaded once already
@@ -467,9 +464,8 @@ void ModManager::LoadModDefinitions()
}
else
{
- // todo: need custom logic for deciding whether to enable remote mods, but should be off by default
- // in the future, remote mods should only be enabled explicitly at runtime, never based on any file or persistent state
- mod.m_bEnabled = false;
+ // remote mods should only be enabled explicitly at runtime, never based on any file or persistent state
+ mod.m_bEnabled = m_setsAllowedRemoteMods.find(mod.Name) != m_setsAllowedRemoteMods.end();
}
if (mod.m_bWasReadSuccessfully)
@@ -1175,13 +1171,13 @@ void ModManager::CompileAssetsForFile(const char* filename)
{
size_t fileHash = STR_HASH(NormaliseModFilePath(fs::path(filename)));
- if (fileHash == m_hScriptsRsonHash)
+ if (fileHash == hScriptsRsonHash)
BuildScriptsRson();
//else if (fileHash == m_hPdefHash)
//{
// // BuildPdef(); todo
//}
- else if (fileHash == m_hKBActHash)
+ else if (fileHash == hKBActHash)
BuildKBActionsList();
else
{
diff --git a/NorthstarDLL/mods/modmanager.h b/NorthstarDLL/mods/modmanager.h
index 3002a099..2673fb3c 100644
--- a/NorthstarDLL/mods/modmanager.h
+++ b/NorthstarDLL/mods/modmanager.h
@@ -133,10 +133,7 @@ class ModManager
private:
bool m_bHasLoadedMods = false;
- // precalculated hashes
- size_t m_hScriptsRsonHash;
- size_t m_hPdefHash;
- size_t m_hKBActHash;
+ std::unordered_set<std::string> m_setsAllowedRemoteMods {};
void LoadModDefinitions();
void SaveEnabledMods();
@@ -208,21 +205,31 @@ class ModManager
std::string NormaliseModFilePath(const fs::path path);
void CompileAssetsForFile(const char* filename);
- // getters
+ // getters and setters
inline std::vector<Mod>& GetMods()
{
return m_ModLoadState->m_LoadedMods;
- };
+ }
inline std::unordered_map<std::string, ModOverrideFile>& GetModFiles()
{
return m_ModLoadState->m_ModFiles;
- };
+ }
inline std::unordered_map<std::string, std::string>& GetDependencyConstants()
{
return m_ModLoadState->m_DependencyConstants;
- };
+ }
+
+ inline void SetAllowedRemoteMods(const std::unordered_set<std::string> setsAllowedRemoteMods)
+ {
+ m_setsAllowedRemoteMods = setsAllowedRemoteMods;
+ }
+
+ void ClearAllowedRemoteMods(void)
+ {
+ m_setsAllowedRemoteMods.clear();
+ }
// compile asset type stuff, these are done in files under runtime/compiled/
void BuildScriptsRson();