From 9874544ac746b388908363cb6e31a0ae6a93f9c4 Mon Sep 17 00:00:00 2001 From: dystopm Date: Fri, 25 Aug 2023 22:51:28 -0400 Subject: [PATCH 1/4] Update client.cpp --- regamedll/dlls/client.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 22f58938b..cc805a325 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4817,6 +4817,16 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) item->fuser2 = weapon->m_flStartThrow; item->fuser3 = weapon->m_flReleaseThrow; item->iuser1 = weapon->m_iSwing; + +#ifdef REGAMEDLL_FIXES + if (pPlayerItem == pPlayer->m_pActiveItem && weapon->m_iClip == II.iMaxClip) + { + int defMaxClip = g_weaponInfo_default[II.iId].gunClipSize; + + if (defMaxClip != II.iMaxClip) + item->m_iClip = defMaxClip; + } +#endif } } From 1f0a1e9316c0528d564b1c65b69129989a57fedc Mon Sep 17 00:00:00 2001 From: dystopm Date: Mon, 11 Sep 2023 14:27:36 -0300 Subject: [PATCH 2/4] Add functions for default weaponinfo array --- regamedll/dlls/client.cpp | 6 +++--- regamedll/dlls/weapontype.cpp | 12 ++++++++++++ regamedll/dlls/weapontype.h | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index ea922326f..314fa8fc7 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4826,10 +4826,10 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) #ifdef REGAMEDLL_FIXES if (pPlayerItem == pPlayer->m_pActiveItem && weapon->m_iClip == II.iMaxClip) { - int defMaxClip = g_weaponInfo_default[II.iId].gunClipSize; + const WeaponInfoStruct *wpnInfo = GetDefaultWeaponInfo(II.iId); - if (defMaxClip != II.iMaxClip) - item->m_iClip = defMaxClip; + if (wpnInfo->gunClipSize != II.iMaxClip) + item->m_iClip = wpnInfo->gunClipSize; } #endif } diff --git a/regamedll/dlls/weapontype.cpp b/regamedll/dlls/weapontype.cpp index 209c7b89d..56480d13d 100644 --- a/regamedll/dlls/weapontype.cpp +++ b/regamedll/dlls/weapontype.cpp @@ -529,6 +529,18 @@ WeaponInfoStruct *GetWeaponInfo(const char *weaponName) return nullptr; } + +WeaponInfoStruct *GetDefaultWeaponInfo(int weaponID) +{ + for (auto& info : g_weaponInfo_default) { + if (info.id == weaponID) { + return &info; + } + } + + return nullptr; +} + AmmoInfoStruct *GetAmmoInfo(const char *ammoName) { for (auto& info : g_ammoInfo) { diff --git a/regamedll/dlls/weapontype.h b/regamedll/dlls/weapontype.h index 97752ec8f..2005b6af7 100644 --- a/regamedll/dlls/weapontype.h +++ b/regamedll/dlls/weapontype.h @@ -445,6 +445,8 @@ void WeaponInfoReset(); WeaponInfoStruct *GetWeaponInfo(int weaponID); WeaponInfoStruct *GetWeaponInfo(const char *weaponName); +WeaponInfoStruct *GetDefaultWeaponInfo(int weaponID); + AmmoInfoStruct *GetAmmoInfo(AmmoType ammoID); AmmoInfoStruct *GetAmmoInfo(const char *ammoName); From d4d32159346fdeaec33c8633a74f31e7de979b2b Mon Sep 17 00:00:00 2001 From: dystopm Date: Mon, 11 Sep 2023 17:21:07 -0300 Subject: [PATCH 3/4] Whitespace cleaning and pointer safety check --- regamedll/dlls/client.cpp | 6 +++--- regamedll/dlls/weapontype.cpp | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 314fa8fc7..3aa6da58d 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4823,13 +4823,13 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) item->fuser3 = weapon->m_flReleaseThrow; item->iuser1 = weapon->m_iSwing; -#ifdef REGAMEDLL_FIXES +#ifdef REGAMEDLL_FIXES if (pPlayerItem == pPlayer->m_pActiveItem && weapon->m_iClip == II.iMaxClip) { const WeaponInfoStruct *wpnInfo = GetDefaultWeaponInfo(II.iId); - if (wpnInfo->gunClipSize != II.iMaxClip) - item->m_iClip = wpnInfo->gunClipSize; + if (wpnInfo && wpnInfo->gunClipSize != II.iMaxClip) + item->m_iClip = wpnInfo->gunClipSize; } #endif } diff --git a/regamedll/dlls/weapontype.cpp b/regamedll/dlls/weapontype.cpp index 56480d13d..2b8ae4458 100644 --- a/regamedll/dlls/weapontype.cpp +++ b/regamedll/dlls/weapontype.cpp @@ -529,7 +529,6 @@ WeaponInfoStruct *GetWeaponInfo(const char *weaponName) return nullptr; } - WeaponInfoStruct *GetDefaultWeaponInfo(int weaponID) { for (auto& info : g_weaponInfo_default) { From 252d9c1f09b00042a6c8a1debf9de4b793be8c28 Mon Sep 17 00:00:00 2001 From: dystopm Date: Mon, 11 Sep 2023 18:10:48 -0300 Subject: [PATCH 4/4] Added reload condition to enhance conditions --- regamedll/dlls/client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 3aa6da58d..fefc9f42f 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4824,7 +4824,7 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) item->iuser1 = weapon->m_iSwing; #ifdef REGAMEDLL_FIXES - if (pPlayerItem == pPlayer->m_pActiveItem && weapon->m_iClip == II.iMaxClip) + if (pPlayerItem == pPlayer->m_pActiveItem && !weapon->m_fInReload && weapon->m_iClip == II.iMaxClip) { const WeaponInfoStruct *wpnInfo = GetDefaultWeaponInfo(II.iId);