You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changing it to return m_iSecondaryAmmoType does not change the value returned in vanilla Half-Life code.
This can result in inconsistent behavior when making custom weapons. A modder that is unaware of this could end up with bugs and even crashes if the index is used to get the player's current remaining ammo since -1 is out of bounds.
With this change, if pszAmmo2() returns a non-null pointer it is safe to assume that SecondaryAmmoIndex also returns a valid index.
The text was updated successfully, but these errors were encountered:
The method
CBasePlayerWeapon::SecondaryAmmoIndexshould always return
m_iSecondaryAmmoType`.Currently this returns
-1
, and the MP5 overrides it to returnm_iSecondaryAmmoType
.For all other weapons
m_iSecondaryAmmoType
is initialized to-1
anyway:halflife/dlls/weapons.cpp
Line 801 in c7240b9
Changing it to return
m_iSecondaryAmmoType
does not change the value returned in vanilla Half-Life code.This can result in inconsistent behavior when making custom weapons. A modder that is unaware of this could end up with bugs and even crashes if the index is used to get the player's current remaining ammo since -1 is out of bounds.
With this change, if
pszAmmo2()
returns a non-null pointer it is safe to assume thatSecondaryAmmoIndex
also returns a valid index.The text was updated successfully, but these errors were encountered: