From 5b770823ecb8252356522494525d4117ddb0c303 Mon Sep 17 00:00:00 2001 From: Sam V Date: Sun, 23 Jan 2022 19:34:06 +0100 Subject: [PATCH] Fix CTF backpack not doubling clip size for most weapons Resolves #38 --- dlls/weapons_shared.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/dlls/weapons_shared.cpp b/dlls/weapons_shared.cpp index fe6efa588..8db70de82 100644 --- a/dlls/weapons_shared.cpp +++ b/dlls/weapons_shared.cpp @@ -77,9 +77,14 @@ bool CBasePlayerWeapon::DefaultReload(int iClipSize, int iAnim, float fDelay, in if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) return false; + if ((m_pPlayer->m_iItems & CTFItem::Backpack) != 0) + { + iClipSize *= 2; + } + int j = V_min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); - if (j == 0) + if (j <= 0) return false; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay; @@ -116,6 +121,8 @@ bool CanAttack(float attack_time, float curtime, bool isPredicted) void CBasePlayerWeapon::ItemPostFrame() { + int maxClip = iMaxClip(); + #ifndef CLIENT_DLL //Reset max clip and max ammo to default values if ((m_pPlayer->m_iItems & CTFItem::Backpack) == 0) @@ -132,12 +139,19 @@ void CBasePlayerWeapon::ItemPostFrame() m_iClip = iMaxClip(); } } + else + { + if (maxClip > 1) + { + maxClip *= 2; + } + } #endif if ((m_fInReload) && (m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase())) { // complete the reload. - int j = V_min(iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + int j = V_min(maxClip - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); // Add them to the clip m_iClip += j;