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 4080f911..b06bd140 100644
--- a/NorthstarDLL/core/filesystem/filesystem.cpp
+++ b/NorthstarDLL/core/filesystem/filesystem.cpp
@@ -73,8 +73,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 aa96fe5a..06e32e29 100644
--- a/NorthstarDLL/mods/modmanager.cpp
+++ b/NorthstarDLL/mods/modmanager.cpp
@@ -939,6 +939,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;
+ }
}
}
@@ -987,6 +993,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);
@@ -1006,6 +1017,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()
@@ -1115,11 +1134,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;
@@ -1137,5 +1177,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 15e12720..ba00de29 100644
--- a/NorthstarDLL/shared/misccommands.cpp
+++ b/NorthstarDLL/shared/misccommands.cpp
@@ -10,6 +10,8 @@
#include "server/auth/serverauthentication.h"
#include "squirrel/squirrel.h"
+AUTOHOOK_INIT()
+
void ConCommand_force_newgame(const CCommand& arg)
{
if (arg.ArgC() < 2)
@@ -140,6 +142,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()
{