From e12d1aa743ccc7557302358fc7a57f1675044495 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 6 Aug 2022 17:40:26 +0300 Subject: [PATCH] Replace usage of m_ForceSendAnimations with entvars to avoid changing the class data layout (#306) --- dlls/player.cpp | 28 ++++++---------------------- dlls/weapons.cpp | 2 +- dlls/weapons.h | 3 --- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 234cfb31..f011b550 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3095,15 +3095,9 @@ void CBasePlayer::SelectItem( const char *pstr ) if( m_pActiveItem ) { - CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)(m_pActiveItem->GetWeaponPtr()); - if (weapon) - weapon->m_ForceSendAnimations = true; - + m_pActiveItem->pev->oldbuttons = 1; m_pActiveItem->Deploy(); - - if (weapon) - weapon->m_ForceSendAnimations = false; - + m_pActiveItem->pev->oldbuttons = 0; m_pActiveItem->UpdateItemInfo(); } } @@ -3130,14 +3124,9 @@ void CBasePlayer::SelectLastItem( void ) m_pActiveItem = m_pLastItem; m_pLastItem = pTemp; - CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)(m_pActiveItem->GetWeaponPtr()); - if (weapon) - weapon->m_ForceSendAnimations = true; - + m_pActiveItem->pev->oldbuttons = 1; m_pActiveItem->Deploy(); - - if (weapon) - weapon->m_ForceSendAnimations = false; + m_pActiveItem->pev->oldbuttons = 0; m_pActiveItem->UpdateItemInfo(); } @@ -4610,14 +4599,9 @@ BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) m_pActiveItem = pWeapon; - CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)(pWeapon->GetWeaponPtr()); - if (weapon) - weapon->m_ForceSendAnimations = true; - + pWeapon->pev->oldbuttons = 1; pWeapon->Deploy(); - - if (weapon) - weapon->m_ForceSendAnimations = false; + pWeapon->pev->oldbuttons = 0; return TRUE; } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 094a4f38..0443d271 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -820,7 +820,7 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body ) { if( UseDecrement() ) - skiplocal = !m_ForceSendAnimations; + skiplocal = !pev->oldbuttons; else skiplocal = 0; diff --git a/dlls/weapons.h b/dlls/weapons.h index 2963afa6..889e0c5a 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -349,9 +349,6 @@ public: // hle time creep vars float m_flPrevPrimaryAttack; float m_flLastFireTime; - - //Hack so deploy animations work when weapon prediction is enabled. - bool m_ForceSendAnimations; }; class CBasePlayerAmmo : public CBaseEntity