From 315d0d06f5bb82acd645089e783a77b756447e37 Mon Sep 17 00:00:00 2001 From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com> Date: Tue, 14 Jan 2020 22:38:54 +0500 Subject: [PATCH] func_breakable: Remove m_iszSpawnObject on restart round (#476) func_breakable: Remove m_iszSpawnObject on restart round --- regamedll/dlls/func_break.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/func_break.cpp b/regamedll/dlls/func_break.cpp index 3178daf4..238febf9 100644 --- a/regamedll/dlls/func_break.cpp +++ b/regamedll/dlls/func_break.cpp @@ -157,6 +157,22 @@ void CBreakable::Restart() { 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) @@ -821,12 +837,9 @@ void CBreakable::Die() auto pItem = CBaseEntity::Create((char *)STRING(m_iszSpawnObject), VecBModelOrigin(pev), pev->angles, edict()); #ifdef REGAMEDLL_FIXES - // FIX: entity leak! if (pItem) { pItem->pev->spawnflags |= SF_NORESPAWN; - pItem->SetThink(&CBaseEntity::SUB_Remove); - pItem->pev->nextthink = gpGlobals->time + CGameRules::GetItemKillDelay(); } #endif