From: Kot <1192090+koteq@users.noreply.github.com> Date: Sun, 4 Feb 2024 20:10:30 +0000 (+0400) Subject: Fix quantum dispose (#24772) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=50e38cbd21950cc3bf31113c6a222d7ef8a3625b;p=space-station-14.git Fix quantum dispose (#24772) * Fix quantum disposable issue * remove force * Iterate over all the disposal holder children instead of contained ones --- 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)