From 593c9185aa2d43d56bacd67599a0843342bea02d Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 6 Jun 2021 02:48:22 +0500 Subject: [PATCH] Do not override IsUseable for mp5. Merge https://github.com/Solokiller/halflife-updated/commit/a9b1d9cda8e063258fc9291ada671c09ef71472b. --- dlls/mp5.cpp | 6 ------ dlls/weapons.cpp | 32 +++++++++++++++++++++++++++----- dlls/weapons.h | 1 - 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index fcfbd179..47d0a24d 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -270,12 +270,6 @@ void CMP5::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again. } -BOOL CMP5::IsUseable() -{ - //Can be used if the player has AR grenades. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] > 0; -} - class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 42e1f6ce..88c91a36 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -897,16 +897,38 @@ BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax ) //========================================================= BOOL CBasePlayerWeapon::IsUseable( void ) { - if( m_iClip <= 0 ) + if( m_iClip > 0 ) + { + return TRUE; + } + + // Player has unlimited ammo for this weapon or does not use magazines + if( iMaxAmmo1() == WEAPON_NOCLIP ) + { + return TRUE; + } + + if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) + { + return TRUE; + } + + if( pszAmmo2() ) { - if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] <= 0 && iMaxAmmo1() != -1 ) + // Player has unlimited ammo for this weapon or does not use magazines + if( iMaxAmmo2() == WEAPON_NOCLIP ) { - // clip is empty (or nonexistant) and the player has no more ammo of this type. - return FALSE; + return TRUE; + } + + if( m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] > 0 ) + { + return TRUE; } } - return TRUE; + // clip is empty (or nonexistant) and the player has no more ammo of this type. + return FALSE; } BOOL CBasePlayerWeapon::CanDeploy( void ) diff --git a/dlls/weapons.h b/dlls/weapons.h index d1051883..a3870299 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -568,7 +568,6 @@ public: BOOL Deploy( void ); void Reload( void ); void WeaponIdle( void ); - BOOL IsUseable(); float m_flNextAnimTime; int m_iShell;