r5sdk/r5dev/game/client/input.cpp
Kawe Mazidjatari 51ea9c7c4f CUserCmd hardening
Fix several exploitable bugs in the CUserCmd class. Some of these have been used to exploit/cheat in-game. Fixes contain:
- Camera position clamping (the only patch that hasn't been tested yet!)
- Weapon activity exploit, allowing player to infinitely throw ordnances, and perform other 'cheats'.
- Akimbo exploit + server crasher, allowing client to set multiple inventory weapons as active. The active weapon index bounds were also not checked, a properly crafter CUserCmd message would therefore be able to crash the server.

Note that this does not fix all issues related to the UserCmd class; further reversing and testing revealed there is more to be fixed, these fixes will get implemented with a future commit.
2023-06-13 17:43:32 +02:00

30 lines
935 B
C++

//=============================================================================//
//
// Purpose:
//
//=============================================================================//
#include "input.h"
#include "common/global.h"
#include "game/shared/weapon_types.h"
void CInput::SetCustomWeaponActivity(CInput* pInput, int weaponActivity)
{
// Server only allows other custom weapon activities if cheats are enabled,
// don't bother simulating it on the client without the cheats cvar, as
// otherwise visual glitches occur.
if (!sv_cheats->GetBool() && weaponActivity != ACT_VM_WEAPON_INSPECT)
weaponActivity = ACT_NONE;
v_CInput__SetCustomWeaponActivity(pInput, weaponActivity);
}
void VInput::Attach(void) const
{
DetourAttach(&v_CInput__SetCustomWeaponActivity, CInput::SetCustomWeaponActivity);
}
void VInput::Detach(void) const
{
DetourDetach(&v_CInput__SetCustomWeaponActivity, CInput::SetCustomWeaponActivity);
}