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)

This commit is contained in:
s1lent 2020-01-15 21:13:03 +07:00
parent f16333c9d6
commit dd59006db0

View File

@ -223,6 +223,19 @@ void CGrenade::__API_HOOK(Explode2)(TraceResult *pTrace, int bitsDamageType)
Create("spark_shower", pev->origin, pTrace->vecPlaneNormal, nullptr); 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) 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); WRITE_BYTE(0);
MESSAGE_END(); MESSAGE_END();
#ifndef REGAMEDLL_FIXES
// BUG: Don't trigger targets until main bomb explodes (Moved to CGrenade::Explode2)
if (m_pentCurBombTarget) if (m_pentCurBombTarget)
{ {
CBaseEntity *pBombTarget = CBaseEntity::Instance(m_pentCurBombTarget); auto pBombTarget = CBaseEntity::Instance(m_pentCurBombTarget);
if (pBombTarget) if (pBombTarget)
{ {
pBombTarget->Use(CBaseEntity::Instance(pev->owner), this, USE_TOGGLE, 0); pBombTarget->Use(CBaseEntity::Instance(pev->owner), this, USE_TOGGLE, 0);
} }
} }
#endif // #ifndef REGAMEDLL_FIXES
CBasePlayer *pBombOwner = CBasePlayer::Instance(pev->owner); CBasePlayer *pBombOwner = CBasePlayer::Instance(pev->owner);
if (pBombOwner) if (pBombOwner)