From dd59006db09dc8ab21b0e9a611d86bbcceab4f81 Mon Sep 17 00:00:00 2001 From: s1lent Date: Wed, 15 Jan 2020 21:13:03 +0700 Subject: [PATCH] C4: Fixed a bug when a player died by explosive targets triggered by the main bomb (like is func_breakable around main bomb). (This is bug can be cause undefined behavior end round) --- regamedll/dlls/ggrenade.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/ggrenade.cpp b/regamedll/dlls/ggrenade.cpp index 277e0e8e..9a33234c 100644 --- a/regamedll/dlls/ggrenade.cpp +++ b/regamedll/dlls/ggrenade.cpp @@ -223,6 +223,19 @@ void CGrenade::__API_HOOK(Explode2)(TraceResult *pTrace, int bitsDamageType) Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, nullptr); } } + +#ifdef REGAMEDLL_FIXES + // A bomb has exploded so let's to trigger other explosive targets + if (m_pentCurBombTarget) + { + auto pBombTarget = CBaseEntity::Instance(m_pentCurBombTarget); + if (pBombTarget) + { + pBombTarget->Use(CBaseEntity::Instance(pevOwner), this, USE_TOGGLE, 0); + } + } +#endif + } LINK_HOOK_CLASS_VOID_CUSTOM2_CHAIN(CGrenade, ExplodeHeGrenade, Explode3, (TraceResult *pTrace, int bitsDamageType), pTrace, bitsDamageType) @@ -1403,14 +1416,17 @@ void CGrenade::C4Think() WRITE_BYTE(0); MESSAGE_END(); +#ifndef REGAMEDLL_FIXES + // BUG: Don't trigger targets until main bomb explodes (Moved to CGrenade::Explode2) if (m_pentCurBombTarget) { - CBaseEntity *pBombTarget = CBaseEntity::Instance(m_pentCurBombTarget); + auto pBombTarget = CBaseEntity::Instance(m_pentCurBombTarget); if (pBombTarget) { pBombTarget->Use(CBaseEntity::Instance(pev->owner), this, USE_TOGGLE, 0); } } +#endif // #ifndef REGAMEDLL_FIXES CBasePlayer *pBombOwner = CBasePlayer::Instance(pev->owner); if (pBombOwner)