Skip to content

Commit

Permalink
Fix CTF backpack not doubling clip size for most weapons
Browse files Browse the repository at this point in the history
Resolves #38
  • Loading branch information
SamVanheer committed Jan 23, 2022
1 parent 0913709 commit 5b77082
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions dlls/weapons_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 5b77082

Please sign in to comment.