From 41be6004b4b1fcffdd15576490bf74c895758a74 Mon Sep 17 00:00:00 2001 From: jhh8 Date: Thu, 11 Dec 2025 21:21:27 +0200 Subject: [PATCH] dont find entities which are marked for deletion was leading to vscript crashes in a typical while find entity loop especially if ran every tick. entity would be marked for deletion and deemed invalid with IsValid function, but the find function would resurrect it in the same tick, then trying to use the resurrected handle shortly afterwards would crash the game. Also now doing Destroy in the typical while find loop is fine --- src/game/server/entitylist.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/game/server/entitylist.cpp b/src/game/server/entitylist.cpp index 13051f721..33e595a32 100644 --- a/src/game/server/entitylist.cpp +++ b/src/game/server/entitylist.cpp @@ -599,6 +599,9 @@ CBaseEntity *CGlobalEntityList::FindEntityByClassname( CBaseEntity *pStartEntity continue; } + if ( pEntity->IsMarkedForDeletion() ) + continue; + if ( pEntity->ClassMatches(szName) ) return pEntity; } @@ -727,6 +730,9 @@ CBaseEntity *CGlobalEntityList::FindEntityByName( CBaseEntity *pStartEntity, con continue; } + if ( ent->IsMarkedForDeletion() ) + continue; + if ( !ent->m_iName.Get() ) continue; @@ -788,6 +794,9 @@ CBaseEntity *CGlobalEntityList::FindEntityByModel( CBaseEntity *pStartEntity, co continue; } + if ( ent->IsMarkedForDeletion() ) + continue; + if ( !ent->edict() || !ent->GetModelName() ) continue; @@ -818,6 +827,9 @@ CBaseEntity *CGlobalEntityList::FindEntityByTarget( CBaseEntity *pStartEntity, c continue; } + if ( ent->IsMarkedForDeletion() ) + continue; + if ( !ent->m_target ) continue; @@ -890,6 +902,9 @@ CBaseEntity *CGlobalEntityList::FindEntityInSphere( CBaseEntity *pStartEntity, c continue; } + if ( ent->IsMarkedForDeletion() ) + continue; + if ( !ent->edict() ) continue;