Skip to content

Commit

Permalink
Re-added loadiwd
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex109 committed Mar 30, 2024
1 parent 8dffbd6 commit bb565de
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
26 changes: 26 additions & 0 deletions cod4qol/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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 <iwdName>\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)
Expand Down
1 change: 1 addition & 0 deletions cod4qol/commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace commands
void InitializeCommands();

void LoadZone();
void LoadIWD();
void iPrintLnBold(const char* text);
void WriteProtectedConfig();
void ReadProtectedConfig();
Expand Down
4 changes: 2 additions & 2 deletions cod4qol/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion cod4qol/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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<int*>(0xCAF7554);
inline int* modIndex = reinterpret_cast<int*>(0xCAF7558);
Expand Down

0 comments on commit bb565de

Please sign in to comment.