From 50e38cbd21950cc3bf31113c6a222d7ef8a3625b Mon Sep 17 00:00:00 2001 From: Kot <1192090+koteq@users.noreply.github.com> Date: Mon, 5 Feb 2024 00:10:30 +0400 Subject: [PATCH] Fix quantum dispose (#24772) * Fix quantum disposable issue * remove force * Iterate over all the disposal holder children instead of contained ones --- .../Unit/EntitySystems/DisposableSystem.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index cc9d2f711b..eb3cda4db9 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -36,8 +36,6 @@ namespace Content.Server.Disposal.Unit.EntitySystems private EntityQuery _physicsQuery; private EntityQuery _xformQuery; - private List _entList = new(); - public override void Initialize() { base.Initialize(); @@ -119,15 +117,17 @@ namespace Content.Server.Disposal.Unit.EntitySystems } } - _entList.Clear(); - _entList.AddRange(holder.Container.ContainedEntities); - - foreach (var entity in _entList) + // We're purposely iterating over all the holder's children + // because the holder might have something teleported into it, + // outside the usual container insertion logic. + var children = holderTransform.ChildEnumerator; + while (children.MoveNext(out var entity)) { RemComp(entity); var meta = _metaQuery.GetComponent(entity); - _containerSystem.Remove((entity, null, meta), holder.Container, reparent: false, force: true); + if (holder.Container.Contains(entity)) + _containerSystem.Remove((entity, null, meta), holder.Container, reparent: false, force: true); var xform = _xformQuery.GetComponent(entity); if (xform.ParentUid != uid) -- 2.52.0