Merge pull request #421 from diamante0018/feature/disable-lean
[Lean] Add option to disable
This commit is contained in:
commit
6175bf7e24
@ -241,12 +241,12 @@ namespace Components
|
||||
mov dl, byte ptr[edi + 1Ah] // to_forwardMove
|
||||
mov dh, byte ptr[edi + 1Bh] // to_rightMove
|
||||
|
||||
mov[esp + 30h], dx // to_buttons
|
||||
mov [esp + 30h], dx // to_buttons
|
||||
|
||||
mov dl, byte ptr[ebp + 1Ah] // from_forwardMove
|
||||
mov dh, byte ptr[ebp + 1Bh] // from_rightMove
|
||||
mov dl, byte ptr [ebp + 1Ah] // from_forwardMove
|
||||
mov dh, byte ptr [ebp + 1Bh] // from_rightMove
|
||||
|
||||
mov[esp + 2Ch], dx // from_buttons
|
||||
mov [esp + 2Ch], dx // from_buttons
|
||||
|
||||
// return back
|
||||
push 0x60E40E
|
||||
@ -261,7 +261,7 @@ namespace Components
|
||||
|
||||
if (Game::MSG_ReadBit(msg))
|
||||
{
|
||||
short movementBits = static_cast<short>(key ^ Game::MSG_ReadBits(msg, 16));
|
||||
const auto movementBits = static_cast<short>(key ^ Game::MSG_ReadBits(msg, 16));
|
||||
|
||||
forward = static_cast<char>(movementBits);
|
||||
right = static_cast<char>(movementBits >> 8);
|
||||
|
@ -2,46 +2,48 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
Dvar::Var Lean::BGLean;
|
||||
|
||||
Game::kbutton_t Lean::in_leanleft;
|
||||
Game::kbutton_t Lean::in_leanright;
|
||||
|
||||
void Lean::IN_LeanLeft_Up()
|
||||
{
|
||||
Game::IN_KeyUp(&Lean::in_leanleft);
|
||||
Game::IN_KeyUp(&in_leanleft);
|
||||
}
|
||||
|
||||
void Lean::IN_LeanLeft_Down()
|
||||
{
|
||||
Game::IN_KeyDown(&Lean::in_leanleft);
|
||||
Game::IN_KeyDown(&in_leanleft);
|
||||
}
|
||||
|
||||
void Lean::IN_LeanRight_Up()
|
||||
{
|
||||
Game::IN_KeyUp(&Lean::in_leanright);
|
||||
Game::IN_KeyUp(&in_leanright);
|
||||
}
|
||||
|
||||
void Lean::IN_LeanRight_Down()
|
||||
{
|
||||
Game::IN_KeyDown(&Lean::in_leanright);
|
||||
Game::IN_KeyDown(&in_leanright);
|
||||
}
|
||||
|
||||
void Lean::SetLeanFlags(Game::usercmd_s* cmds)
|
||||
void Lean::SetLeanFlags(Game::usercmd_s* cmd)
|
||||
{
|
||||
if (Lean::in_leanleft.active || Lean::in_leanleft.wasPressed)
|
||||
if ((in_leanleft.active || in_leanleft.wasPressed) && BGLean.get<bool>())
|
||||
{
|
||||
cmds->buttons |= BUTTON_FLAG_LEANLEFT;
|
||||
cmd->buttons |= Game::CMD_BUTTON_LEAN_LEFT;
|
||||
}
|
||||
|
||||
if (Lean::in_leanright.active || Lean::in_leanright.wasPressed)
|
||||
if ((in_leanright.active || in_leanright.wasPressed) && BGLean.get<bool>())
|
||||
{
|
||||
cmds->buttons |= BUTTON_FLAG_LEANRIGHT;
|
||||
cmd->buttons |= Game::CMD_BUTTON_LEAN_RIGHT;
|
||||
}
|
||||
|
||||
Lean::in_leanleft.wasPressed = false;
|
||||
Lean::in_leanright.wasPressed = false;
|
||||
in_leanleft.wasPressed = false;
|
||||
in_leanright.wasPressed = false;
|
||||
}
|
||||
|
||||
void __declspec(naked) Lean::CL_CmdButtonsStub()
|
||||
void __declspec(naked) Lean::CL_CmdButtons_Stub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
@ -51,21 +53,35 @@ namespace Components
|
||||
|
||||
pushad
|
||||
push esi
|
||||
call Lean::SetLeanFlags
|
||||
call SetLeanFlags
|
||||
pop esi
|
||||
popad
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
void Lean::PM_UpdateLean_Stub(Game::playerState_s* ps, float msec, Game::usercmd_s* cmd, void(*capsuleTrace)(Game::trace_t*, const float*, const float*, const Game::Bounds*, int, int))
|
||||
{
|
||||
if (BGLean.get<bool>())
|
||||
{
|
||||
Game::PM_UpdateLean(ps, msec, cmd, capsuleTrace);
|
||||
}
|
||||
}
|
||||
|
||||
Lean::Lean()
|
||||
{
|
||||
Command::AddRaw("+leanleft", Lean::IN_LeanLeft_Down, true);
|
||||
Command::AddRaw("-leanleft", Lean::IN_LeanLeft_Up, true);
|
||||
Command::AddRaw("+leanleft", IN_LeanLeft_Down, true);
|
||||
Command::AddRaw("-leanleft", IN_LeanLeft_Up, true);
|
||||
|
||||
Command::AddRaw("+leanright", Lean::IN_LeanRight_Down, true);
|
||||
Command::AddRaw("-leanright", Lean::IN_LeanRight_Up, true);
|
||||
Command::AddRaw("+leanright", IN_LeanRight_Down, true);
|
||||
Command::AddRaw("-leanright", IN_LeanRight_Up, true);
|
||||
|
||||
Utils::Hook(0x5A6D84, Lean::CL_CmdButtonsStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x5A6D84, CL_CmdButtons_Stub, HOOK_CALL).install()->quick();
|
||||
|
||||
Utils::Hook(0x4A0C72, PM_UpdateLean_Stub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x4A0D72, PM_UpdateLean_Stub, HOOK_CALL).install()->quick();
|
||||
|
||||
BGLean = Dvar::Register<bool>("bg_lean", true,
|
||||
Game::DVAR_CODINFO, "Enable CoD4 leaning");
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define BUTTON_FLAG_LEANLEFT 0x40
|
||||
#define BUTTON_FLAG_LEANRIGHT 0x80
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class Lean : public Component
|
||||
@ -10,6 +7,8 @@ namespace Components
|
||||
public:
|
||||
Lean();
|
||||
|
||||
static Dvar::Var BGLean;
|
||||
|
||||
private:
|
||||
static Game::kbutton_t in_leanleft;
|
||||
static Game::kbutton_t in_leanright;
|
||||
@ -20,7 +19,9 @@ namespace Components
|
||||
static void IN_LeanRight_Up();
|
||||
static void IN_LeanRight_Down();
|
||||
|
||||
static void CL_CmdButtonsStub();
|
||||
static void SetLeanFlags(Game::usercmd_s* cmds);
|
||||
static void CL_CmdButtons_Stub();
|
||||
static void SetLeanFlags(Game::usercmd_s* cmd);
|
||||
|
||||
static void PM_UpdateLean_Stub(Game::playerState_s* ps, float msec, Game::usercmd_s* cmd, void(*capsuleTrace)(Game::trace_t*, const float*, const float*, const Game::Bounds*, int, int));
|
||||
};
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define BUTTON_FLAG_LEANLEFT 0x40
|
||||
#define BUTTON_FLAG_LEANRIGHT 0x80
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class SlowMotion : public Component
|
||||
|
@ -238,6 +238,7 @@ namespace Game
|
||||
MSG_WriteLong_t MSG_WriteLong = MSG_WriteLong_t(0x41CA20);
|
||||
MSG_WriteShort_t MSG_WriteShort = MSG_WriteShort_t(0x503B90);
|
||||
MSG_WriteString_t MSG_WriteString = MSG_WriteString_t(0x463820);
|
||||
MSG_ReadDeltaUsercmdKey_t MSG_ReadDeltaUsercmdKey = MSG_ReadDeltaUsercmdKey_t(0x491F00);
|
||||
MSG_WriteBitsCompress_t MSG_WriteBitsCompress = MSG_WriteBitsCompress_t(0x4319D0);
|
||||
MSG_ReadByte_t MSG_ReadByte = MSG_ReadByte_t(0x4C1C20);
|
||||
MSG_ReadBitsCompress_t MSG_ReadBitsCompress = MSG_ReadBitsCompress_t(0x4DCC30);
|
||||
@ -455,6 +456,7 @@ namespace Game
|
||||
PM_playerTrace_t PM_playerTrace = PM_playerTrace_t(0x458980);
|
||||
PM_Trace_t PM_Trace = PM_Trace_t(0x441F60);
|
||||
PM_GetEffectiveStance_t PM_GetEffectiveStance = PM_GetEffectiveStance_t(0x412540);
|
||||
PM_UpdateLean_t PM_UpdateLean = PM_UpdateLean_t(0x43DED0);
|
||||
|
||||
CL_MouseEvent_t CL_MouseEvent = CL_MouseEvent_t(0x4D7C50);
|
||||
IN_RecenterMouse_t IN_RecenterMouse = IN_RecenterMouse_t(0x463D80);
|
||||
|
@ -624,6 +624,9 @@ namespace Game
|
||||
typedef void(__cdecl * MSG_WriteString_t)(msg_t* msg, const char *str);
|
||||
extern MSG_WriteString_t MSG_WriteString;
|
||||
|
||||
typedef bool(__cdecl * MSG_ReadDeltaUsercmdKey_t)(msg_t* msg, int key, const usercmd_s* from, usercmd_s* to);
|
||||
extern MSG_ReadDeltaUsercmdKey_t MSG_ReadDeltaUsercmdKey;
|
||||
|
||||
typedef int(__cdecl * MSG_WriteBitsCompress_t)(bool trainHuffman, const char *from, char *to, int size);
|
||||
extern MSG_WriteBitsCompress_t MSG_WriteBitsCompress;
|
||||
|
||||
@ -1110,6 +1113,9 @@ namespace Game
|
||||
typedef EffectiveStance(__cdecl * PM_GetEffectiveStance_t)(const playerState_s* ps);
|
||||
extern PM_GetEffectiveStance_t PM_GetEffectiveStance;
|
||||
|
||||
typedef void(__cdecl * PM_UpdateLean_t)(playerState_s* ps, float msec, usercmd_s* cmd, void(*capsuleTrace)(trace_t*, const float*, const float*, const Bounds*, int, int));
|
||||
extern PM_UpdateLean_t PM_UpdateLean;
|
||||
|
||||
typedef int(__cdecl * CL_MouseEvent_t)(int x, int y, int dx, int dy);
|
||||
extern CL_MouseEvent_t CL_MouseEvent;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user