func_breakable: Remove m_iszSpawnObject on restart round (#476)

func_breakable: Remove m_iszSpawnObject on restart round
This commit is contained in:
Vaqtincha 2020-01-14 22:38:54 +05:00 committed by Dmitry Novikov
parent a7443e9e1e
commit 315d0d06f5

View File

@ -157,6 +157,22 @@ void CBreakable::Restart()
{ {
pev->flags |= FL_WORLDBRUSH; pev->flags |= FL_WORLDBRUSH;
} }
#ifdef REGAMEDLL_FIXES
if (m_iszSpawnObject)
{
CBaseEntity *pEntity = nullptr;
while ((pEntity = UTIL_FindEntityByClassname(pEntity, STRING(m_iszSpawnObject))))
{
if (!FNullEnt(pEntity->pev->owner) && FClassnameIs(pEntity->pev->owner, "func_breakable"))
{
pEntity->SetThink(&CBaseEntity::SUB_Remove);
pEntity->pev->nextthink = gpGlobals->time + 0.1f;
}
}
}
#endif
} }
void CBreakable::KeyValue(KeyValueData *pkvd) void CBreakable::KeyValue(KeyValueData *pkvd)
@ -821,12 +837,9 @@ void CBreakable::Die()
auto pItem = CBaseEntity::Create((char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict()); auto pItem = CBaseEntity::Create((char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict());
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
// FIX: entity leak!
if (pItem) if (pItem)
{ {
pItem->pev->spawnflags |= SF_NORESPAWN; pItem->pev->spawnflags |= SF_NORESPAWN;
pItem->SetThink(&CBaseEntity::SUB_Remove);
pItem->pev->nextthink = gpGlobals->time + CGameRules::GetItemKillDelay();
} }
#endif #endif