From 2aba0ec251d7d19cf182b7d0a8120733bc7c3d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Tue, 10 Oct 2023 19:03:48 -0300 Subject: [PATCH] Ensure HasPrimary flag assignation on successful weapon removal (#866) --- regamedll/dlls/client.cpp | 4 ++-- regamedll/dlls/multiplay_gamerules.cpp | 11 ++++++----- regamedll/dlls/player.cpp | 10 +++++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 9460d0b49..56297b358 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -2251,7 +2251,7 @@ bool EXT_FUNC __API_HOOK(BuyGunAmmo)(CBasePlayer *pPlayer, CBasePlayerItem *weap if (pPlayer->m_iAccount >= info->clipCost) { #ifdef REGAMEDLL_FIXES - if (pPlayer->GiveAmmo(info->buyClipSize, info->ammoName2, weapon->iMaxAmmo1()) == -1) + if (pPlayer->GiveAmmo(info->buyClipSize, weapon->pszAmmo1(), weapon->iMaxAmmo1()) == -1) return false; EMIT_SOUND(ENT(weapon->pev), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM); @@ -4813,7 +4813,7 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) const WeaponInfoStruct *wpnInfo = GetDefaultWeaponInfo(II.iId); if (wpnInfo && wpnInfo->gunClipSize != II.iMaxClip) - item->m_iClip = wpnInfo->gunClipSize; + item->m_iClip = wpnInfo->gunClipSize; } #endif } diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 5222cc080..becd1bf9f 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -3588,14 +3588,15 @@ void CHalfLifeMultiplay::ClientDisconnected(edict_t *pClient) { pPlayer->DropPlayerItem("weapon_c4"); } - -#ifndef REGAMEDLL_FIXES - // Why ? DropPlayerItem didn't handle item_thighpack + if (pPlayer->m_bHasDefuser) { - pPlayer->DropPlayerItem("item_thighpack"); - } +#ifdef REGAMEDLL_FIXES + SpawnDefuser(pPlayer->pev->origin, nullptr); +#else + pPlayer->DropPlayerItem("item_thighpack"); // DropPlayerItem didn't handle item_thighpack #endif + } if (pPlayer->m_bIsVIP) { diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 9861c35f7..092815260 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8056,8 +8056,10 @@ CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszIte g_pGameRules->GetNextBestWeapon(this, pWeapon); UTIL_MakeVectors(pev->angles); +#ifndef REGAMEDLL_FIXES if (pWeapon->iItemSlot() == PRIMARY_WEAPON_SLOT) - m_bHasPrimary = false; + m_bHasPrimary = false; // I may have more than just 1 primary weapon :) +#endif if (FClassnameIs(pWeapon->pev, "weapon_c4")) { @@ -8127,6 +8129,12 @@ CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszIte return nullptr; } +#ifdef REGAMEDLL_FIXES + if (!m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]) { + m_bHasPrimary = false; // ensure value assignation on successful weapon removal + } +#endif + if (FClassnameIs(pWeapon->pev, "weapon_c4")) { pWeaponBox->m_bIsBomb = true;