From ed676a5413c2d26b2982e5b014e0731f0eda6a0d Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 21 Jul 2022 17:40:51 +0300 Subject: [PATCH] Fix deploy animations on fast weapon switching (#289) --- dlls/player.cpp | 17 +++++++++++++++++ dlls/weapons.cpp | 2 +- dlls/weapons.h | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index cce57d02..e4d7f0fb 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3095,7 +3095,15 @@ void CBasePlayer::SelectItem( const char *pstr ) if( m_pActiveItem ) { + CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)(m_pActiveItem->GetWeaponPtr()); + if (weapon) + weapon->m_ForceSendAnimations = true; + m_pActiveItem->Deploy(); + + if (weapon) + weapon->m_ForceSendAnimations = false; + m_pActiveItem->UpdateItemInfo(); } } @@ -3121,7 +3129,16 @@ void CBasePlayer::SelectLastItem( void ) CBasePlayerItem *pTemp = m_pActiveItem; m_pActiveItem = m_pLastItem; m_pLastItem = pTemp; + + CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)(m_pActiveItem->GetWeaponPtr()); + if (weapon) + weapon->m_ForceSendAnimations = true; + m_pActiveItem->Deploy(); + + if (weapon) + weapon->m_ForceSendAnimations = false; + m_pActiveItem->UpdateItemInfo(); } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 76e5408d..094a4f38 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 = 1; + skiplocal = !m_ForceSendAnimations; else skiplocal = 0; diff --git a/dlls/weapons.h b/dlls/weapons.h index c5f0d46a..396f3724 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -351,6 +351,9 @@ 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