Skip to content

Commit

Permalink
fix: dirty hack to fix both angle decays
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzyhau committed Nov 27, 2023
1 parent 561806b commit eee79dc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Modules/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ 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_remove_angle_decay("sar_disable_angle_decay", "0", 0, 2, "Removes angle decay.\n1 - remove small decay only.\n2 - remove angle decay entirely.\n");

REDECL(Client::LevelInitPreEntity);
REDECL(Client::CreateMove);
Expand All @@ -59,6 +60,7 @@ REDECL(Client::GetTextColorForClient);
REDECL(Client::DecodeUserCmdFromBuffer);
REDECL(Client::CInput_CreateMove);
REDECL(Client::GetButtonBits);
REDECL(Client::ApplyMouse);
REDECL(Client::SteamControllerMove);
REDECL(Client::playvideo_end_level_transition_callback);
REDECL(Client::OverrideView);
Expand Down Expand Up @@ -402,6 +404,27 @@ DETOUR(Client::GetButtonBits, bool bResetState) {
return bits;
}

// CInput::ApplyMouse
DETOUR(Client::ApplyMouse, int nSlot, QAngle &viewangles, CUserCmd *cmd, float mouse_x, float mouse_y) {

auto lastViewAngles = viewangles;

auto playerLocal = client->GetPlayer(nSlot + 1)->portal_local();

auto result = Client::ApplyMouse(thisptr, nSlot, viewangles, cmd, mouse_x, mouse_y);

if (sar_remove_angle_decay.GetBool()) {
if (
!mouse_x && !mouse_y && !viewangles.z &&
(sar_remove_angle_decay.GetInt() > 1 || fabsf(viewangles.x) < 45.0f)
) {
viewangles = lastViewAngles;
}
}

return result;
}

// CInput::SteamControllerMove
DETOUR(Client::SteamControllerMove, int nSlot, float flFrametime, CUserCmd *cmd) {
auto result = Client::SteamControllerMove(thisptr, nSlot, flFrametime, cmd);
Expand Down Expand Up @@ -580,6 +603,7 @@ bool Client::Init() {
g_Input->Hook(Client::DecodeUserCmdFromBuffer_Hook, Client::DecodeUserCmdFromBuffer, Offsets::DecodeUserCmdFromBuffer);
g_Input->Hook(Client::GetButtonBits_Hook, Client::GetButtonBits, Offsets::GetButtonBits);
g_Input->Hook(Client::SteamControllerMove_Hook, Client::SteamControllerMove, Offsets::SteamControllerMove);
g_Input->Hook(Client::ApplyMouse_Hook, Client::ApplyMouse, Offsets::ApplyMouse);

in_forceuser = Variable("in_forceuser");
if (!!in_forceuser && this->g_Input) {
Expand Down
3 changes: 3 additions & 0 deletions src/Modules/Client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class Client : public Module {
// CInput::GetButtonBits
DECL_DETOUR(GetButtonBits, bool bResetState);

// CInput::ApplyMouse
DECL_DETOUR(ApplyMouse, int nSlot, QAngle &viewangles, CUserCmd *cmd, float mouse_x, float mouse_y);

// CInput::SteamControllerMove
DECL_DETOUR(SteamControllerMove, int nSlot, float flFrametime, CUserCmd *cmd); // is it slot though? :thinking:

Expand Down
1 change: 1 addition & 0 deletions src/OffsetsData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ OFFSET_DEFAULT(GetAllClasses, 8, 8)
OFFSET_DEFAULT(HudProcessInput, 10, 10)
OFFSET_DEFAULT(IN_ActivateMouse, 15, 15)
OFFSET_DEFAULT(IN_DeactivateMouse, 16, 16)
OFFSET_DEFAULT(ApplyMouse, 56, 56)
OFFSET_DEFAULT(SteamControllerMove, 58, 58)
OFFSET_DEFAULT(LevelInitPreEntity, 5, 5)

Expand Down

0 comments on commit eee79dc

Please sign in to comment.