aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NorthstarDLL/core/filesystem/filesystem.cpp2
-rw-r--r--NorthstarDLL/engine/r2engine.h2
-rw-r--r--NorthstarDLL/mods/modmanager.cpp46
-rw-r--r--NorthstarDLL/mods/modmanager.h1
-rw-r--r--NorthstarDLL/shared/misccommands.cpp18
5 files changed, 64 insertions, 5 deletions
diff --git a/NorthstarDLL/core/filesystem/filesystem.cpp b/NorthstarDLL/core/filesystem/filesystem.cpp
index 8ca73130..6cff7927 100644
--- a/NorthstarDLL/core/filesystem/filesystem.cpp
+++ b/NorthstarDLL/core/filesystem/filesystem.cpp
@@ -74,8 +74,6 @@ void SetNewModSearchPaths(Mod* mod)
{
if ((fs::absolute(mod->m_ModDirectory) / MOD_OVERRIDE_DIR).string().compare(sCurrentModPath))
{
- NS::log::fs->info("Changing mod search path from {} to {}", sCurrentModPath, mod->m_ModDirectory.string());
-
AddSearchPath(
&*(*g_pFilesystem), (fs::absolute(mod->m_ModDirectory) / MOD_OVERRIDE_DIR).string().c_str(), "GAME", PATH_ADD_TO_HEAD);
sCurrentModPath = (fs::absolute(mod->m_ModDirectory) / MOD_OVERRIDE_DIR).string();
diff --git a/NorthstarDLL/engine/r2engine.h b/NorthstarDLL/engine/r2engine.h
index ff8876b8..edf49890 100644
--- a/NorthstarDLL/engine/r2engine.h
+++ b/NorthstarDLL/engine/r2engine.h
@@ -245,7 +245,7 @@ namespace R2
FIELDS(0x3C,
// Simulation ticks - does not increase when game is paused
- uint32_t m_nTickCount; // this is weird and doesn't seem to increase once per frame?
+ DWORD m_nTickCount; // this is weird and doesn't seem to increase once per frame?
// Simulation tick interval
float m_flTickInterval;
diff --git a/NorthstarDLL/mods/modmanager.cpp b/NorthstarDLL/mods/modmanager.cpp
index d2321583..40ed9f3e 100644
--- a/NorthstarDLL/mods/modmanager.cpp
+++ b/NorthstarDLL/mods/modmanager.cpp
@@ -940,6 +940,12 @@ void ModManager::CheckModFilesForChanges()
m_AssetTypesToReload.bDamageDefs = true;
continue;
}
+
+ if (m_AssetTypesToReload.bDatatables && !pChangedFile->m_Path.parent_path().compare("scripts/datatable/"))
+ {
+ m_AssetTypesToReload.bDatatables = true;
+ continue;
+ }
}
}
@@ -988,6 +994,11 @@ void ModManager::ReloadNecessaryModAssets()
if (m_AssetTypesToReload.bAimAssistSettings)
vReloadCommands.push_back("ReloadAimAssistSettings");
+ if (m_AssetTypesToReload.bDatatables)
+ {
+ // TODO: clear disk datatable cache in scriptdatatables.cpp
+ }
+
// need to reimplement mat_reloadmaterials for this
//if (m_AssetTypesToReload.bMaterials)
// R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "mat_reloadmaterials", R2::cmd_source_t::kCommandSrcCode);
@@ -1007,6 +1018,14 @@ void ModManager::ReloadNecessaryModAssets()
}
R2::Cbuf_Execute();
+
+ // reset everything we've already reloaded at this point
+ m_AssetTypesToReload.bUiScript = false;
+ m_AssetTypesToReload.bLocalisation = false;
+ m_AssetTypesToReload.bPlaylists = false;
+ m_AssetTypesToReload.bAimAssistSettings = false;
+ m_AssetTypesToReload.bDatatables = false;
+ m_AssetTypesToReload.bModels = false;
}
void ModManager::InstallMods()
@@ -1116,11 +1135,32 @@ void ModManager::CompileAssetsForFile(const char* filename)
}
}
-void ConCommand_reload_mods(const CCommand& args)
+void ConCommand_mods_reload(const CCommand& args)
{
g_pModManager->LoadMods();
}
+void ConCommand_mods_getfileowner(const CCommand& args)
+{
+ if (args.ArgC() < 2)
+ {
+ spdlog::warn("usage: mods_getfileowner path/to/file.mdl");
+ return;
+ }
+
+ auto findFile = g_pModManager->GetModFiles().find(g_pModManager->NormaliseModFilePath(args.Arg(1)));
+ if (findFile != g_pModManager->GetModFiles().end())
+ {
+ // this can be null if asset is compiled!
+ if (findFile->second.m_pOwningMod != nullptr)
+ spdlog::info("file \"{}\" is owned by mod {}", args.Arg(1), findFile->second.m_pOwningMod->Name);
+ else
+ spdlog::info("file \"{}\" is overriden by a runtime compiled asset", args.Arg(1));
+ }
+ else
+ spdlog::warn("file not override not found");
+}
+
fs::path GetModFolderPath()
{
return GetNorthstarPrefix() / MOD_FOLDER_SUFFIX;
@@ -1138,5 +1178,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", ModManager, (ConCommand, MasterServer), (CMod
{
g_pModManager = new ModManager;
- RegisterConCommand("reload_mods", ConCommand_reload_mods, "reloads mods", FCVAR_NONE);
+ RegisterConCommand("reload_mods", ConCommand_mods_reload, "reloads mods", FCVAR_NONE);
+ RegisterConCommand("mods_reload", ConCommand_mods_reload, "reloads mods", FCVAR_NONE);
+ RegisterConCommand("mods_getfileowner", ConCommand_mods_getfileowner, "find the mod that owns a given file", FCVAR_NONE);
}
diff --git a/NorthstarDLL/mods/modmanager.h b/NorthstarDLL/mods/modmanager.h
index ea5c4105..253b7812 100644
--- a/NorthstarDLL/mods/modmanager.h
+++ b/NorthstarDLL/mods/modmanager.h
@@ -169,6 +169,7 @@ class ModManager
bool bPlayerSettings = false;
bool bAiSettings = false;
bool bDamageDefs = false; // damagedefs
+ bool bDatatables = false;
// can't actually reload this atm, just print a warning (todo, could maybe restart client to ensure loaded?)
bool bModels = false;
diff --git a/NorthstarDLL/shared/misccommands.cpp b/NorthstarDLL/shared/misccommands.cpp
index f3817867..5894f5a2 100644
--- a/NorthstarDLL/shared/misccommands.cpp
+++ b/NorthstarDLL/shared/misccommands.cpp
@@ -11,6 +11,8 @@
#include "server/auth/serverauthentication.h"
#include "squirrel/squirrel.h"
+AUTOHOOK_INIT()
+
void ConCommand_force_newgame(const CCommand& arg)
{
if (arg.ArgC() < 2)
@@ -141,6 +143,22 @@ void AddMiscConCommands()
RegisterConCommand("cvar_reset", ConCommand_cvar_reset, "resets a cvar's value to its default value", FCVAR_NONE);
}
+AUTOHOOK(Connect_f, engine.dll + 0x76720, void, , (const CCommand& arg))
+{
+ // tickcount number is weird, but consistent!
+ // todo this check sucks
+
+ if (*R2::g_pServerState != R2::server_state_t::ss_dead && R2::g_pGlobals->m_nTickCount != 60 && !strncmp(arg.Arg(1), "localhost", 9))
+ strncpy(const_cast<char*>(arg.GetCommandString() + 8), "127.0.0.1", 9);
+
+ Connect_f(arg);
+}
+
+ON_DLL_LOAD("engine.dll", connecttest, (CModule module))
+{
+ AUTOHOOK_DISPATCH()
+}
+
// fixes up various cvar flags to have more sane values
void FixupCvarFlags()
{