From c57a98a8cab5077a4b0cd9dfd1872306bfb30705 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 14 Feb 2023 13:34:48 +0000 Subject: temp commit for changing branch --- NorthstarDLL/mods/modmanager.cpp | 46 ++++++++++++++++++++++++++++++++++++++-- NorthstarDLL/mods/modmanager.h | 1 + 2 files changed, 45 insertions(+), 2 deletions(-) (limited to 'NorthstarDLL/mods') 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; -- cgit v1.2.3