aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NorthstarDLL/core/hooks.cpp4
-rw-r--r--NorthstarDLL/engine/hoststate.cpp11
-rw-r--r--NorthstarDLL/mods/modmanager.cpp31
-rw-r--r--NorthstarDLL/mods/modmanager.h4
-rw-r--r--NorthstarDLL/mods/reload/reloadmodweapons.cpp3
5 files changed, 42 insertions, 11 deletions
diff --git a/NorthstarDLL/core/hooks.cpp b/NorthstarDLL/core/hooks.cpp
index 7c70b0a5..fe570efb 100644
--- a/NorthstarDLL/core/hooks.cpp
+++ b/NorthstarDLL/core/hooks.cpp
@@ -76,6 +76,10 @@ void __fileAutohook::DispatchForModule(const char* pModuleName)
{
const int iModuleNameLen = strlen(pModuleName);
+ for (__autovar* var : vars)
+ if (!strncmp(pModuleName, var->m_pAddrString, iModuleNameLen))
+ var->Dispatch();
+
for (__autohook* hook : hooks)
if ((hook->iAddressResolutionMode == __autohook::OFFSET_STRING && !strncmp(pModuleName, hook->pAddrString, iModuleNameLen)) ||
(hook->iAddressResolutionMode == __autohook::PROCADDRESS && !strcmp(pModuleName, hook->pModuleName)))
diff --git a/NorthstarDLL/engine/hoststate.cpp b/NorthstarDLL/engine/hoststate.cpp
index ec4733d6..918c1c4b 100644
--- a/NorthstarDLL/engine/hoststate.cpp
+++ b/NorthstarDLL/engine/hoststate.cpp
@@ -164,6 +164,17 @@ void, __fastcall, (CHostState* self))
sLastMode.clear();
}
+
+ // TODO: this does work, but will also be called in places it shouldn't be (e.g. immediately after reloading mods before we actually join a server, so all remote mods are lost)
+ // exclusively for reload after leave though, this does work!
+ /*
+ * if (g_pModManager->IsUsingRemoteMods())
+ * {
+ * g_pModManager->ClearAllowedRemoteMods();
+ * g_pModManager->LoadMods(true, true);
+ * }
+ */
+
}
// clang-format off
diff --git a/NorthstarDLL/mods/modmanager.cpp b/NorthstarDLL/mods/modmanager.cpp
index f97624be..f2a745bb 100644
--- a/NorthstarDLL/mods/modmanager.cpp
+++ b/NorthstarDLL/mods/modmanager.cpp
@@ -987,7 +987,7 @@ void ModManager::CheckModFilesForChanges(ModAssetsToReload* pAssetsToReload)
else if (fChangedPath.filename() == "springs.txt")
pAssetsToReload->bWeaponSprings = true;
else
- pAssetsToReload->setsWeaponSettings.insert(fChangedPath.replace_extension().string());
+ pAssetsToReload->setsWeaponSettings.insert(fChangedPath.filename().replace_extension().string());
continue;
}
@@ -1169,7 +1169,8 @@ std::string ModManager::NormaliseModFilePath(const fs::path path)
void ModManager::CompileAssetsForFile(const char* filename)
{
- size_t fileHash = STR_HASH(NormaliseModFilePath(fs::path(filename)));
+ std::string sNormalisedFilePath = NormaliseModFilePath(fs::path(filename));
+ size_t fileHash = STR_HASH(sNormalisedFilePath);
if (fileHash == hScriptsRsonHash)
BuildScriptsRson();
@@ -1182,17 +1183,23 @@ void ModManager::CompileAssetsForFile(const char* filename)
else
{
// check if we should build keyvalues, depending on whether any of our mods have patch kvs for this file
- for (Mod& mod : GetMods() | FilterEnabled)
+ if (m_ModLoadState->m_KeyValues.find(sNormalisedFilePath) != m_ModLoadState->m_KeyValues.end())
{
- if (m_ModLoadState->m_KeyValues.find(filename) != m_ModLoadState->m_KeyValues.end())
- {
- TryBuildKeyValues(filename);
- return;
- }
+ TryBuildKeyValues(sNormalisedFilePath.c_str());
+ return;
}
}
}
+bool ModManager::IsUsingRemoteMods()
+{
+ // if we hit any mods that are enabled and remote, return true
+ for (Mod& mod : GetMods() | FilterEnabled | FilterRemote)
+ return true;
+
+ return false;
+}
+
void ConCommand_mods_reload(const CCommand& args)
{
// reload assets now
@@ -1232,6 +1239,12 @@ void ConCommand_mods_getfileowner(const CCommand& args)
spdlog::warn("file not override not found");
}
+void ConCommand_mods_test_setallowedremotemod(const CCommand& args)
+{
+ if (args.ArgC() >= 2)
+ g_pModManager->SetAllowedRemoteMods({args.Arg(1)});
+}
+
fs::path GetModFolderPath()
{
return GetNorthstarPrefix() / MOD_FOLDER_SUFFIX;
@@ -1254,4 +1267,6 @@ ON_DLL_LOAD_RELIESON("engine.dll", ModManager, (ConCommand, MasterServer), (CMod
RegisterConCommand("mods_reload_deferred", ConCommand_mods_reload_deferred, "reloads mods, prefers reloading assets on level load rather than now", FCVAR_NONE);
RegisterConCommand("mods_reload_no_asset_reload", ConCommand_mods_no_asset_reload, "reloads mods without trying to reload assets", FCVAR_NONE);
RegisterConCommand("mods_getfileowner", ConCommand_mods_getfileowner, "find the mod that owns a given file", FCVAR_NONE);
+
+ RegisterConCommand("mods_test_setallowedremotemod", ConCommand_mods_test_setallowedremotemod, "", FCVAR_NONE);
}
diff --git a/NorthstarDLL/mods/modmanager.h b/NorthstarDLL/mods/modmanager.h
index 2673fb3c..146482b3 100644
--- a/NorthstarDLL/mods/modmanager.h
+++ b/NorthstarDLL/mods/modmanager.h
@@ -226,11 +226,13 @@ class ModManager
m_setsAllowedRemoteMods = setsAllowedRemoteMods;
}
- void ClearAllowedRemoteMods(void)
+ inline void ClearAllowedRemoteMods(void)
{
m_setsAllowedRemoteMods.clear();
}
+ bool IsUsingRemoteMods();
+
// compile asset type stuff, these are done in files under runtime/compiled/
void BuildScriptsRson();
void TryBuildKeyValues(const char* filename);
diff --git a/NorthstarDLL/mods/reload/reloadmodweapons.cpp b/NorthstarDLL/mods/reload/reloadmodweapons.cpp
index 077c2835..2e10ad56 100644
--- a/NorthstarDLL/mods/reload/reloadmodweapons.cpp
+++ b/NorthstarDLL/mods/reload/reloadmodweapons.cpp
@@ -135,7 +135,6 @@ bool, __fastcall, (void* a1, void* a2, void* a3, const char* pWeaponName))
if (g_pModManager->TryReloadWeapon(pWeaponName, &clientReloadPointers))
return true;
- spdlog::info("PrecacheWeaponFromStringtable: {}", pWeaponName);
return ClientPrecacheWeaponFromStringtable(a1, a2, a3, pWeaponName);
}
@@ -147,7 +146,7 @@ ON_DLL_LOAD_CLIENT("client.dll", ModReloadWeaponsClient, (CModule module))
g_pnClientWeaponsLoaded, g_ppClientWeaponDefs, &setsClientWeaponsToReload, ClientReparseWeapon, ClientReloadWeaponCallbacks);
}
-ON_DLL_LOAD_CLIENT("server.dll", ModReloadWeaponsServer, (CModule module))
+ON_DLL_LOAD("server.dll", ModReloadWeaponsServer, (CModule module))
{
AUTOHOOK_DISPATCH_MODULE(server.dll)