Skip to content

Commit

Permalink
Removed reflection hashes print, renamed and fixed auto bhop
Browse files Browse the repository at this point in the history
  • Loading branch information
Rex109 committed Nov 23, 2024
1 parent e3488e3 commit 4926f48
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
11 changes: 1 addition & 10 deletions cod4qol/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ void commands::InitializeCommands()
game::Cmd_AddCommand("toggleconsoleupdate", ToggleConsoleUpdate);
game::Cmd_AddCommand("toggleloadinginfoupdate", ToggleLoadingInfoUpdate);
game::Cmd_AddCommand("togglesteamauthupdate", ToggleSteamAuthUpdate);
game::Cmd_AddCommand("toggleenablebhopupdate", ToggleEnableBhopUpdate);
game::Cmd_AddCommand("openlink", OpenLink);

game::Cmd_AddCommand("loaddemos", LoadDemos);
Expand Down Expand Up @@ -80,7 +79,7 @@ void commands::InitializeCommands()

qol_stockmenu = game::Cvar_RegisterBool("qol_stockmenu", 0, game::dvar_flags::saved, "Load the stock menu even with a mod loaded.");

qol_enablebhop = game::Cvar_RegisterBool("qol_enablebhop", 0, game::dvar_flags::saved, "Enable auto bunny hopping.");
qol_enableautobhop = game::Cvar_RegisterBool("qol_enableautobhop", 0, game::dvar_flags::saved, "Enable auto bunny hopping.");

qol_debugreflections = game::Cvar_RegisterBool("qol_debugreflections", 0, game::dvar_flags::saved, "Enable red reflections, useful for fixing reflections on custom maps. Requires map restart.");

Expand Down Expand Up @@ -249,14 +248,6 @@ void commands::ToggleSteamAuthUpdate()
}
}

void commands::ToggleEnableBhopUpdate()
{
if (commands::qol_enablebhop->current.enabled)
hooks::write_addr(0x407DE3, "\xEB", 1);
else
hooks::write_addr(0x407DE3, "\x74", 1);
}

void commands::OpenLink()
{
if (game::Cmd_Argc() < 2)
Expand Down
3 changes: 1 addition & 2 deletions cod4qol/commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace commands
inline game::dvar_s* qol_disable_steam_auth;
inline game::dvar_s* qol_ambient;
inline game::dvar_s* qol_stockmenu;
inline game::dvar_s* qol_enablebhop;
inline game::dvar_s* qol_enableautobhop;
inline game::dvar_s* qol_show_mainmenuinfo;
inline game::dvar_s* qol_debugreflections;

Expand All @@ -45,7 +45,6 @@ namespace commands
void SetGun(game::GfxViewParms* view_parms);
void ToggleLoadingInfoUpdate();
void ToggleSteamAuthUpdate();
void ToggleEnableBhopUpdate();
void OpenLink();

void LoadDemos();
Expand Down
26 changes: 24 additions & 2 deletions cod4qol/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ void game::cleanUpReflections()
std::string hash = crc32(lockedRect.pBits, lockedRect.Pitch * lockedRect.Pitch);
cubemap->UnlockRect(D3DCUBEMAP_FACE_POSITIVE_X, 0);

std::cout << hash << std::endl;

if (hash == "e06ccbba" || hash == "444c60df" || hash == "c1eacd74" || hash == "48ed9648")
{
rgp->world->reflectionProbes[i].reflectionImage->texture.cubemap = nullptr;
Expand Down Expand Up @@ -288,6 +286,30 @@ unsigned int game::hookedCG_StartAmbient(int a1)
return game::pCG_StartAmbient(a1);
}

__declspec(naked) void game::hookedCL_CmdButtons()
{
static bool jump_pressed = false;
const static uint32_t retn_addr = 0x4639CF;
__asm pushad;

if (!jump_pressed || !commands::qol_enableautobhop->current.enabled)
{
jump_pressed = true;
__asm
{
popad;
jmp game::pCL_CmdButtons;
}
}

jump_pressed = false;
__asm
{
popad;
jmp retn_addr;
}
}

int game::Cmd_Argc()
{
return game::cmd_args->argc[game::cmd_args->nesting];
Expand Down
5 changes: 5 additions & 0 deletions cod4qol/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,11 @@ namespace game

unsigned int hookedCG_StartAmbient(int a1);

typedef void(*CL_CmdButtons)();
inline CL_CmdButtons pCL_CmdButtons;

void hookedCL_CmdButtons();

int Cmd_Argc();
const char* Cmd_Argv(int arg);
HMODULE GetCurrentModule();
Expand Down
4 changes: 4 additions & 0 deletions cod4qol/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ void hooks::InitializeHooks()
game::pCG_StartAmbient = (game::CG_StartAmbient)(0x43F200);
hooks::install(&(PVOID&)game::pCG_StartAmbient, (PBYTE)game::hookedCG_StartAmbient);

//CL_CmdButtons
game::pCL_CmdButtons = (game::CL_CmdButtons)(0x4639C8);
hooks::install(&(PVOID&)game::pCL_CmdButtons, (PBYTE)game::hookedCL_CmdButtons);

std::cout << "Hooks installed!" << std::endl;
}

Expand Down

0 comments on commit 4926f48

Please sign in to comment.