Skip to content

Commit

Permalink
Fix ammo pickup sound playing when picking up a weapon for the first …
Browse files Browse the repository at this point in the history
…time
  • Loading branch information
SamVanheer committed Mar 24, 2023
1 parent a9f1de5 commit 3d13792
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Fixed tripmines not detonating if placed on breakable and a save game is loaded [#192](https://github.com/SamVanheer/halflife-updated/issues/192) (Thanks forklift.mdl)
* Fixed func_friction not working properly in multiplayer (halflife issue [#1542](https://github.com/ValveSoftware/halflife/issues/1542)) (Thanks L453rh4wk)
* Fixed spray logo using wrong decal after save game load when not using custom spray [#193](https://github.com/SamVanheer/halflife-updated/issues/193) (Thanks Ronin4862)
* Fixed ammo pickup sound playing when picking up a weapon for the first time (bug introduced by [#153](https://github.com/SamVanheer/halflife-updated/issues/153) in Beta 12)

## Changes in V1.0.0 Beta 014

Expand Down
2 changes: 0 additions & 2 deletions cl_dll/hl/hl_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ void CBasePlayerItem::AttachToPlayer(CBasePlayer* pPlayer) {}
bool CBasePlayerWeapon::AddDuplicate(CBasePlayerItem* pOriginal) { return false; }
void CBasePlayerWeapon::AddToPlayer(CBasePlayer* pPlayer) {}
bool CBasePlayerWeapon::UpdateClientData(CBasePlayer* pPlayer) { return false; }
bool CBasePlayerWeapon::AddPrimaryAmmo(int iCount, char* szName, int iMaxClip, int iMaxCarry) { return true; }
bool CBasePlayerWeapon::AddSecondaryAmmo(int iCount, char* szName, int iMax) { return true; }
bool CBasePlayerWeapon::IsUseable() { return true; }
int CBasePlayerWeapon::PrimaryAmmoIndex() { return m_iPrimaryAmmoType; }
int CBasePlayerWeapon::SecondaryAmmoIndex() { return m_iSecondaryAmmoType; }
Expand Down
6 changes: 3 additions & 3 deletions dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ void CBasePlayerWeapon::SendWeaponAnim(int iAnim, int body)
MESSAGE_END();
}

bool CBasePlayerWeapon::AddPrimaryAmmo(int iCount, char* szName, int iMaxClip, int iMaxCarry)
bool CBasePlayerWeapon::AddPrimaryAmmo(CBasePlayerWeapon* origin, int iCount, char* szName, int iMaxClip, int iMaxCarry)
{
int iIdAmmo;

Expand All @@ -743,7 +743,7 @@ bool CBasePlayerWeapon::AddPrimaryAmmo(int iCount, char* szName, int iMaxClip, i
if (iIdAmmo > 0)
{
m_iPrimaryAmmoType = iIdAmmo;
if (m_pPlayer->HasPlayerItem(this))
if (this != origin)
{
// play the "got ammo" sound only if we gave some ammo to a player that already had this gun.
// if the player is just getting this gun for the first time, DefaultTouch will play the "picked up gun" sound for us.
Expand Down Expand Up @@ -944,7 +944,7 @@ bool CBasePlayerWeapon::ExtractAmmo(CBasePlayerWeapon* pWeapon)
{
// blindly call with m_iDefaultAmmo. It's either going to be a value or zero. If it is zero,
// we only get the ammo in the weapon's clip, which is what we want.
iReturn = pWeapon->AddPrimaryAmmo(m_iDefaultAmmo, (char*)pszAmmo1(), iMaxClip(), iMaxAmmo1());
iReturn = pWeapon->AddPrimaryAmmo(this, m_iDefaultAmmo, (char*)pszAmmo1(), iMaxClip(), iMaxAmmo1());
m_iDefaultAmmo = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class CBasePlayerWeapon : public CBasePlayerItem
virtual bool ExtractClipAmmo(CBasePlayerWeapon* pWeapon); // { return true; } // Return true if you can add ammo to yourself when picked up

// generic "shared" ammo handlers
bool AddPrimaryAmmo(int iCount, char* szName, int iMaxClip, int iMaxCarry);
bool AddPrimaryAmmo(CBasePlayerWeapon* origin, int iCount, char* szName, int iMaxClip, int iMaxCarry);
bool AddSecondaryAmmo(int iCount, char* szName, int iMaxCarry);

void UpdateItemInfo() override {} // updates HUD state
Expand Down

0 comments on commit 3d13792

Please sign in to comment.