Skip to content

Commit 41be600

Browse files
committed
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
1 parent 4bb0be7 commit 41be600

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/game/server/entitylist.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ CBaseEntity *CGlobalEntityList::FindEntityByClassname( CBaseEntity *pStartEntity
599599
continue;
600600
}
601601

602+
if ( pEntity->IsMarkedForDeletion() )
603+
continue;
604+
602605
if ( pEntity->ClassMatches(szName) )
603606
return pEntity;
604607
}
@@ -727,6 +730,9 @@ CBaseEntity *CGlobalEntityList::FindEntityByName( CBaseEntity *pStartEntity, con
727730
continue;
728731
}
729732

733+
if ( ent->IsMarkedForDeletion() )
734+
continue;
735+
730736
if ( !ent->m_iName.Get() )
731737
continue;
732738

@@ -788,6 +794,9 @@ CBaseEntity *CGlobalEntityList::FindEntityByModel( CBaseEntity *pStartEntity, co
788794
continue;
789795
}
790796

797+
if ( ent->IsMarkedForDeletion() )
798+
continue;
799+
791800
if ( !ent->edict() || !ent->GetModelName() )
792801
continue;
793802

@@ -818,6 +827,9 @@ CBaseEntity *CGlobalEntityList::FindEntityByTarget( CBaseEntity *pStartEntity, c
818827
continue;
819828
}
820829

830+
if ( ent->IsMarkedForDeletion() )
831+
continue;
832+
821833
if ( !ent->m_target )
822834
continue;
823835

@@ -890,6 +902,9 @@ CBaseEntity *CGlobalEntityList::FindEntityInSphere( CBaseEntity *pStartEntity, c
890902
continue;
891903
}
892904

905+
if ( ent->IsMarkedForDeletion() )
906+
continue;
907+
893908
if ( !ent->edict() )
894909
continue;
895910

0 commit comments

Comments
 (0)