Skip to content

Commit

Permalink
Fix deploy animations on fast weapon switching (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave authored Jul 21, 2022
1 parent 25ba2b4 commit ed676a5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ class CBasePlayerWeapon : public CBasePlayerItem
// 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
Expand Down

0 comments on commit ed676a5

Please sign in to comment.