Skip to content

Commit

Permalink
fix: bandaid angle decay patches
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisAMJ committed Nov 27, 2023
1 parent 561806b commit 5247b08
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Modules/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Variable r_drawviewmodel;

Variable sar_disable_coop_score_hud("sar_disable_coop_score_hud", "0", "Disables the coop score HUD which appears in demo playback.\n");
Variable sar_disable_save_status_hud("sar_disable_save_status_hud", "0", "Disables the saving/saved HUD which appears when you make a save.\n");
Variable sar_patch_decay_major("sar_patch_decay_major", "0", "Patches Major Angle Decay. Read more at wiki Angle Decay page.\n");
Variable sar_patch_decay_minor("sar_patch_decay_minor", "0", "Patches Minor Angle Decay. Read more at wiki Angle Decay page.\n");

REDECL(Client::LevelInitPreEntity);
REDECL(Client::CreateMove);
Expand All @@ -67,6 +69,7 @@ REDECL(Client::DrawTranslucentRenderables);
REDECL(Client::DrawOpaqueRenderables);
REDECL(Client::CalcViewModelLag);
REDECL(Client::AddShadowToReceiver);
REDECL(Client::ApplyMouse);

CMDECL(Client::GetAbsOrigin, Vector, m_vecAbsOrigin);
CMDECL(Client::GetAbsAngles, QAngle, m_angAbsRotation);
Expand Down Expand Up @@ -512,6 +515,21 @@ DETOUR_T(void, Client::AddShadowToReceiver, unsigned short handle, void *pRender
}
Hook g_AddShadowToReceiverHook(&Client::AddShadowToReceiver_Hook);

extern Hook g_ApplyMouseHook;
DETOUR_T(void, Client::ApplyMouse, int nSlot, QAngle &viewangles, CUserCmd *cmd, float mouse_x, float mouse_y) {
if (mouse_x == 0.0f && mouse_y == 0.0f) {
if (std::abs(viewangles.x) > 45.0f) {
if (sar_patch_decay_major.GetBool()) return;
} else {
if (sar_patch_decay_minor.GetBool()) return;
}
}
g_ApplyMouseHook.Disable();
Client::ApplyMouse(thisptr, nSlot, viewangles, cmd, mouse_x, mouse_y);
g_ApplyMouseHook.Enable();
}
Hook g_ApplyMouseHook(&Client::ApplyMouse_Hook);

bool Client::Init() {
bool readJmp = false;

Expand Down Expand Up @@ -668,6 +686,13 @@ bool Client::Init() {
#endif
}

#ifdef _WIN32
Client::ApplyMouse = (decltype(Client::ApplyMouse))Memory::Scan(this->Name(), "55 8B EC 81 EC 98 00 00 00 56 6A FF");
#else
Client::ApplyMouse = (decltype(Client::ApplyMouse))Memory::Scan(this->Name(), "55 57 56 53 81 EC B8 00 00 00 8B B4 24");
#endif
g_ApplyMouseHook.SetFunc(Client::ApplyMouse);

cl_showpos = Variable("cl_showpos");
cl_sidespeed = Variable("cl_sidespeed");
cl_forwardspeed = Variable("cl_forwardspeed");
Expand Down
3 changes: 3 additions & 0 deletions src/Modules/Client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class Client : public Module {
// ClientModeShared::OverrideView
DECL_DETOUR_T(void, OverrideView, CViewSetup *m_View);

// C_Paint_Player::ApplyMouse
DECL_DETOUR_T(void, ApplyMouse, int nSlot, QAngle &viewangles, CUserCmd *cmd, float mouse_x, float mouse_y);

DECL_DETOUR_COMMAND(playvideo_end_level_transition);

bool Init() override;
Expand Down

0 comments on commit 5247b08

Please sign in to comment.