From bb565de2de2b7dbaeba0cbeab35ff975d561de18 Mon Sep 17 00:00:00 2001 From: Rex109 Date: Sat, 30 Mar 2024 18:50:23 +0100 Subject: [PATCH] Re-added loadiwd --- cod4qol/commands.cpp | 26 ++++++++++++++++++++++++++ cod4qol/commands.hpp | 1 + cod4qol/game.cpp | 4 ++-- cod4qol/game.hpp | 3 ++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/cod4qol/commands.cpp b/cod4qol/commands.cpp index 4f05609..9f9eb9b 100644 --- a/cod4qol/commands.cpp +++ b/cod4qol/commands.cpp @@ -8,6 +8,7 @@ void commands::InitializeCommands() std::cout << "Initializing commands..." << std::endl; game::Cmd_AddCommand("loadzone", LoadZone); + game::Cmd_AddCommand("loadiwd", LoadIWD); game::Cmd_AddCommand("vm_anim", VmAnim); game::Cmd_AddCommand("readprotectedconfig", ReadProtectedConfig); game::Cmd_AddCommand("writeprotectedconfig", WriteProtectedConfig); @@ -16,6 +17,8 @@ void commands::InitializeCommands() game::Cmd_AddCommand("togglesteamauthupdate", ToggleSteamAuthUpdate); game::Cmd_AddCommand("openlink", OpenLink); + //REFLECTION 0D0701E0+E4 + game::Cmd_AddCommand("loaddemos", LoadDemos); game::Cmd_AddCommand("playselecteddemo", PlaySelectedDemo); game::Cmd_AddCommand("getdemoname", GetDemoName); @@ -105,6 +108,29 @@ void commands::LoadZone() game::DB_LoadXAssets(info, 2, 1); } +void commands::LoadIWD() +{ + if (!sv_running->current.enabled) + { + game::Com_PrintMessage(0, "You must be playing on a local server to use loadiwd\n", 0); + return; + } + + if (game::Cmd_Argc() < 2) + { + game::Com_PrintMessage(0, "Usage: loadiwd \n", 0); + return; + } + + std::string iwd_name = game::Cmd_Argv(1); + + std::string relative_dir = game::fs_homepath->current.string; + relative_dir.append("\\main\\"); + relative_dir.append(iwd_name); + + game::FS_AddSingleIwdFileForGameDirectory(relative_dir.c_str(), iwd_name.c_str(), "main");; +} + void commands::VmAnim() { if (!sv_running->current.enabled) diff --git a/cod4qol/commands.hpp b/cod4qol/commands.hpp index 174cd3d..e0bc8cd 100644 --- a/cod4qol/commands.hpp +++ b/cod4qol/commands.hpp @@ -36,6 +36,7 @@ namespace commands void InitializeCommands(); void LoadZone(); + void LoadIWD(); void iPrintLnBold(const char* text); void WriteProtectedConfig(); void ReadProtectedConfig(); diff --git a/cod4qol/game.cpp b/cod4qol/game.cpp index 98b00ac..45bf17f 100644 --- a/cod4qol/game.cpp +++ b/cod4qol/game.cpp @@ -23,7 +23,7 @@ HMODULE game::GetCurrentModule() return hModule; } -bool game::LoadIWD(const char* pakfile, const char* basename, const char* gamename) +bool game::LoadLocalizedIWD(const char* pakfile, const char* basename, const char* gamename) { hooks::write_addr((game::cod4x_entry + 0x386E2), "\x01", 1); bool result = FS_AddSingleIwdFileForGameDirectory(pakfile, basename, gamename); @@ -76,7 +76,7 @@ void game::LoadModFiles() } } - LoadIWD(relative_dir.c_str(), "xcommon_cod4qol.iwd", "main"); + LoadLocalizedIWD(relative_dir.c_str(), "xcommon_cod4qol.iwd", "main"); game::Cbuf_AddText("loadzone qol\n", 0); } diff --git a/cod4qol/game.hpp b/cod4qol/game.hpp index 91ee1a5..b4fdf33 100644 --- a/cod4qol/game.hpp +++ b/cod4qol/game.hpp @@ -510,7 +510,7 @@ namespace game int Cmd_Argc(); const char* Cmd_Argv(int arg); HMODULE GetCurrentModule(); - bool LoadIWD(const char* pakfile, const char* basename, const char* gamename); + bool LoadLocalizedIWD(const char* pakfile, const char* basename, const char* gamename); void LoadModFiles(); void WriteBytesToFile(const byte* data, DWORD size, const char* filename); @@ -560,6 +560,7 @@ namespace game inline game::dvar_s* fs_game = game::Find("fs_game"); inline game::dvar_s* fs_homepath = game::Find("fs_homepath"); + inline game::dvar_s* sv_pure = game::Find("sv_pure"); inline int* modCount = reinterpret_cast(0xCAF7554); inline int* modIndex = reinterpret_cast(0xCAF7558);