From 106f722581cae4b3f6a33318dd9365ef20546863 Mon Sep 17 00:00:00 2001 From: Javekson Date: Mon, 13 Nov 2023 18:36:32 +0400 Subject: [PATCH 1/3] feat(SwitchTeam): add of bomb removal on team switch --- regamedll/dlls/player.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 5e7eed2fc..ce41b5723 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8390,21 +8390,20 @@ void CBasePlayer::__API_HOOK(SwitchTeam)() if (m_bHasDefuser) { RemoveDefuser(); + } -#ifndef REGAMEDLL_FIXES - // NOTE: unreachable code - Vaqtincha - for (int i = 0; i < MAX_ITEM_TYPES; i++) - { - m_pActiveItem = m_rgpPlayerItems[i]; - - if (m_pActiveItem && FClassnameIs(m_pActiveItem->pev, "item_thighpack")) - { - m_pActiveItem->Drop(); - m_rgpPlayerItems[i] = nullptr; - } + if (m_bHasC4) + { + if (CSGameRules()->m_iNumTerrorist > 1 && CSPlayer()->RemovePlayerItem("weapon_c4")) { + m_bHasC4 = false; + pev->body = 0; + SetBombIcon(FALSE); + SetProgressBarTime(0); + CSGameRules()->GiveC4(); + } + else if (IsAlive()) { + DropPlayerItem("weapon_c4"); } -#endif - } szOldTeam = GetTeam(oldTeam); From 8fa910c4f75d41ba31a7d3b346c3db7f404ebfe2 Mon Sep 17 00:00:00 2001 From: Javekson Date: Wed, 15 Nov 2023 18:39:40 +0400 Subject: [PATCH 2/3] refactor(SwitchTeam): improved code organization for bomb removal --- regamedll/dlls/player.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index ce41b5723..3ac2148e2 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8392,20 +8392,6 @@ void CBasePlayer::__API_HOOK(SwitchTeam)() RemoveDefuser(); } - if (m_bHasC4) - { - if (CSGameRules()->m_iNumTerrorist > 1 && CSPlayer()->RemovePlayerItem("weapon_c4")) { - m_bHasC4 = false; - pev->body = 0; - SetBombIcon(FALSE); - SetProgressBarTime(0); - CSGameRules()->GiveC4(); - } - else if (IsAlive()) { - DropPlayerItem("weapon_c4"); - } - } - szOldTeam = GetTeam(oldTeam); szNewTeam = GetTeam(m_iTeam); @@ -8438,6 +8424,20 @@ void CBasePlayer::__API_HOOK(SwitchTeam)() // Initialize the player counts now that a player has switched teams int NumDeadCT, NumDeadTerrorist, NumAliveTerrorist, NumAliveCT; CSGameRules()->InitializePlayerCounts(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT); + + if (m_bHasC4) + { + if (NumAliveTerrorist > 0 && CSPlayer()->RemovePlayerItemEx("weapon_c4", true)) { + m_bHasC4 = false; + pev->body = 0; + SetBombIcon(FALSE); + SetProgressBarTime(0); + CSGameRules()->GiveC4(); + } + else { + DropPlayerItem("weapon_c4"); + } + } #endif } From 466d1bbb6d3b97b59069c4ca1f80ddf9ecafaa19 Mon Sep 17 00:00:00 2001 From: Javekson Date: Wed, 15 Nov 2023 20:09:29 +0400 Subject: [PATCH 3/3] refactor(SwitchTeam): remove redundant code lines for bomb removal --- regamedll/dlls/player.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 3ac2148e2..ef231af88 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8428,10 +8428,6 @@ void CBasePlayer::__API_HOOK(SwitchTeam)() if (m_bHasC4) { if (NumAliveTerrorist > 0 && CSPlayer()->RemovePlayerItemEx("weapon_c4", true)) { - m_bHasC4 = false; - pev->body = 0; - SetBombIcon(FALSE); - SetProgressBarTime(0); CSGameRules()->GiveC4(); } else {