]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix quantum dispose (#24772)
authorKot <1192090+koteq@users.noreply.github.com>
Sun, 4 Feb 2024 20:10:30 +0000 (00:10 +0400)
committerGitHub <noreply@github.com>
Sun, 4 Feb 2024 20:10:30 +0000 (15:10 -0500)
* Fix quantum disposable issue

* remove force

* Iterate over all the disposal holder children instead of contained ones

Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs

index cc9d2f711b308729e6ba68e9c111343e8743de02..eb3cda4db9b48deecc5b566a2b3199d24224fc35 100644 (file)
@@ -36,8 +36,6 @@ namespace Content.Server.Disposal.Unit.EntitySystems
         private EntityQuery<PhysicsComponent> _physicsQuery;
         private EntityQuery<TransformComponent> _xformQuery;
 
-        private List<EntityUid> _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<BeingDisposedComponent>(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)