From 0e8d3ad4c5e4bbd28f8fd1a32313de9230dc7797 Mon Sep 17 00:00:00 2001 From: Sam V Date: Fri, 31 Mar 2023 18:53:33 +0200 Subject: [PATCH] Fix Gauss gun sometimes settting player uranium ammo to -1 ValveSoftware/halflife#3343 --- CHANGELOG.md | 1 + dlls/gauss.cpp | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83bacd36c..d2a6a640a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * 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) +* Fixed Gauss gun sometimes settting player uranium ammo to -1 (halflife issue [#3343](https://github.com/ValveSoftware/halflife/issues/3343)) ## Changes in V1.0.0 Beta 014 diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 18da1e824..e4ac8f3e6 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -199,22 +199,25 @@ void CGauss::SecondaryAttack() } else { - // during the charging process, eat one bit of ammo every once in a while - if (UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000) + if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0) { + // during the charging process, eat one bit of ammo every once in a while + if (UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000) + { #ifdef CLIENT_DLL - if (bIsMultiplayer()) + if (bIsMultiplayer()) #else - if (g_pGameRules->IsMultiplayer()) + if (g_pGameRules->IsMultiplayer()) #endif - { - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1; - } - else - { - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; + { + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; + m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1; + } + else + { + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; + m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; + } } }