Skip to content

Commit

Permalink
Fix weapon deploy animations caused by lastinv command not working pr…
Browse files Browse the repository at this point in the history
…operly

Resolves #154
  • Loading branch information
SamVanheer committed Jul 20, 2022
1 parent 62525c6 commit 42f45bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ bool CBasePlayerWeapon::UpdateClientData(CBasePlayer* pPlayer)

void CBasePlayerWeapon::SendWeaponAnim(int iAnim, int body)
{
const bool skiplocal = UseDecrement() != false;
const bool skiplocal = !m_ForceSendAnimations && UseDecrement() != false;

m_pPlayer->pev->weaponanim = iAnim;

Expand Down
3 changes: 3 additions & 0 deletions dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,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 = false;
};


Expand Down
14 changes: 14 additions & 0 deletions dlls/weapons_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,20 @@ void CBasePlayer::SelectLastItem()
CBasePlayerItem* pTemp = m_pActiveItem;
m_pActiveItem = m_pLastItem;
m_pLastItem = pTemp;

auto weapon = static_cast<CBasePlayerWeapon*>(m_pActiveItem->GetWeaponPtr());

if (weapon)
{
weapon->m_ForceSendAnimations = true;
}

m_pActiveItem->Deploy();

if (weapon)
{
weapon->m_ForceSendAnimations = false;
}

m_pActiveItem->UpdateItemInfo();
}

0 comments on commit 42f45bd

Please sign in to comment.