@@ -901,8 +901,7 @@ bool CASW_Weapon::ASWReload( int iClipSize1, int iClipSize2, int iActivity )
901901 if ( UsesClipsForAmmo1 () )
902902 {
903903 // need to reload primary clip?
904- int primary = MIN ( iClipSize1 - m_iClip1, pMarine->GetAmmoCount ( m_iPrimaryAmmoType ) );
905- if ( primary != 0 )
904+ if ( m_iClip1 < iClipSize1 && pMarine->GetAmmoCount ( m_iPrimaryAmmoType ) > 0 )
906905 {
907906 bReload = true ;
908907 }
@@ -929,8 +928,7 @@ bool CASW_Weapon::ASWReload( int iClipSize1, int iClipSize2, int iActivity )
929928 pAmmoBag->GiveClipTo ( pMarine, m_iPrimaryAmmoType, true );
930929
931930 // now we've given a clip, check if we can reload
932- primary = MIN ( iClipSize1 - m_iClip1, pMarine->GetAmmoCount ( m_iPrimaryAmmoType ) );
933- if ( primary != 0 )
931+ if ( m_iClip1 < iClipSize1 && pMarine->GetAmmoCount ( m_iPrimaryAmmoType ) > 0 )
934932 {
935933 bReload = true ;
936934 }
@@ -942,8 +940,7 @@ bool CASW_Weapon::ASWReload( int iClipSize1, int iClipSize2, int iActivity )
942940 if ( UsesClipsForAmmo2 () )
943941 {
944942 // need to reload secondary clip?
945- int secondary = MIN ( iClipSize2 - m_iClip2, pMarine->GetAmmoCount ( m_iSecondaryAmmoType ) );
946- if ( secondary != 0 )
943+ if ( m_iClip2 < iClipSize2 && pMarine->GetAmmoCount ( m_iSecondaryAmmoType ) > 0 )
947944 {
948945 bReload = true ;
949946 }
@@ -1199,8 +1196,9 @@ void CASW_Weapon::FinishReload( void )
11991196
12001197 if (pOwner)
12011198 {
1202- // If I use primary clips, reload primary
1203- if ( UsesClipsForAmmo1 () )
1199+ // Additional checks are needed to prevent accidentally reloading ammo types that don't require reloading now.
1200+ // If I use primary clips, current clip not overflowing and I have spare ammo, reload primary
1201+ if ( UsesClipsForAmmo1 () && m_iClip1 < GetMaxClip1 () && pOwner->GetAmmoCount (m_iPrimaryAmmoType) > 0 )
12041202 {
12051203 // asw: throw away what's in the clip currently
12061204 m_iClip1 = 0 ;
@@ -1209,8 +1207,8 @@ void CASW_Weapon::FinishReload( void )
12091207 pOwner->RemoveAmmo ( primary, m_iPrimaryAmmoType);
12101208 }
12111209
1212- // If I use secondary clips, reload secondary
1213- if ( UsesClipsForAmmo2 () )
1210+ // If I use secondary clips, current clip not overflowing and I have spare ammo, reload secondary
1211+ if ( UsesClipsForAmmo2 () && m_iClip2 < GetMaxClip2 () && pOwner-> GetAmmoCount (m_iSecondaryAmmoType) > 0 )
12141212 {
12151213 int secondary = MIN ( GetMaxClip2 () - m_iClip2, pOwner->GetAmmoCount (m_iSecondaryAmmoType));
12161214 m_iClip2 += secondary;
0 commit comments