Skip to content

Commit

Permalink
Ensure HasPrimary flag assignation on successful weapon removal (s1le…
Browse files Browse the repository at this point in the history
  • Loading branch information
dystopm authored and Vaqtincha committed Oct 25, 2023
1 parent e422a37 commit 2aba0ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
Expand Down
11 changes: 6 additions & 5 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 9 additions & 1 deletion regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2aba0ec

Please sign in to comment.