From e4f4666f5d9b0904be87f0b776e9deed99862ef4 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Thu, 3 Nov 2022 23:01:42 +0500 Subject: [PATCH] Fix weapons reload bug on save/restore. --- dlls/hs/ak47.cpp | 3 +++ dlls/hs/goldengun.cpp | 6 +++--- dlls/hs/jackal.cpp | 6 +++--- dlls/hs/modman.cpp | 4 +++- dlls/hs/mw2.cpp | 2 ++ dlls/hs/zapper.cpp | 6 +++--- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/dlls/hs/ak47.cpp b/dlls/hs/ak47.cpp index dbd6ae88..cd4f736b 100644 --- a/dlls/hs/ak47.cpp +++ b/dlls/hs/ak47.cpp @@ -197,6 +197,9 @@ void CAK47::PrimaryAttack() void CAK47::Reload( void ) { + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == AK47_MAX_CLIP ) + return; + DefaultReload( AK47_MAX_CLIP, AK47_RELOAD, 3.0 ); } diff --git a/dlls/hs/goldengun.cpp b/dlls/hs/goldengun.cpp index 48ef99d6..00744ae3 100644 --- a/dlls/hs/goldengun.cpp +++ b/dlls/hs/goldengun.cpp @@ -169,12 +169,12 @@ void CGOLDENGUN::Reload( void ) { int iResult; - if (m_iClip == GOLDENGUN_MAX_CLIP) - return; + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == GOLDENGUN_MAX_CLIP ) + return; if (m_iClip == 0) { - iResult = DefaultReload( GOLDENGUN_MAX_CLIP, GOLDENGUN_RELOAD2, 2.7, 0 ); + iResult = DefaultReload( GOLDENGUN_MAX_CLIP, GOLDENGUN_RELOAD, 2.7, 0 ); } else { diff --git a/dlls/hs/jackal.cpp b/dlls/hs/jackal.cpp index ce94f966..209ceb59 100644 --- a/dlls/hs/jackal.cpp +++ b/dlls/hs/jackal.cpp @@ -149,12 +149,12 @@ void CJackal::Reload( void ) { int iResult; - if (m_iClip == JACKAL_MAX_CLIP) - return; + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == JACKAL_MAX_CLIP ) + return; if (m_iClip == 0) { - iResult = DefaultReload( JACKAL_MAX_CLIP, Jackal_RELOAD2, 2.7, 0 ); + iResult = DefaultReload( JACKAL_MAX_CLIP, Jackal_RELOAD, 2.7, 0 ); } else { diff --git a/dlls/hs/modman.cpp b/dlls/hs/modman.cpp index 21e76bec..ef5fe01c 100644 --- a/dlls/hs/modman.cpp +++ b/dlls/hs/modman.cpp @@ -442,8 +442,10 @@ void CModman::FireHorn() void CModman::Reload( void ) { + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CROSSBOW_MAX_CLIP ) + return; - if ( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) ) + if ( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5 ) ) { EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0,0xF)); } diff --git a/dlls/hs/mw2.cpp b/dlls/hs/mw2.cpp index 53d37b53..2b69fdfa 100644 --- a/dlls/hs/mw2.cpp +++ b/dlls/hs/mw2.cpp @@ -185,6 +185,8 @@ void CMW2::PrimaryAttack() void CMW2::Reload( void ) { + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == MW2_MAX_CLIP ) + return; DefaultReload( MW2_MAX_CLIP, MW2_RELOAD, 3.0 ); } diff --git a/dlls/hs/zapper.cpp b/dlls/hs/zapper.cpp index 7775e806..2927a5fe 100644 --- a/dlls/hs/zapper.cpp +++ b/dlls/hs/zapper.cpp @@ -164,8 +164,8 @@ void CZAPPER::Reload( void ) { int iResult; - if (m_iClip == ZAPPER_MAX_CLIP) - return; + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == ZAPPER_MAX_CLIP ) + return; if (m_iClip == 0) { @@ -173,7 +173,7 @@ void CZAPPER::Reload( void ) } else { - iResult = DefaultReload( ZAPPER_MAX_CLIP, ZAPPER_RELOAD, 1.5, 0 ); + iResult = DefaultReload( ZAPPER_MAX_CLIP, ZAPPER_RELOAD_NOT_EMPTY, 1.5, 0 ); } if (iResult) {