]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix small CanInsert bug (#22302)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Mon, 11 Dec 2023 09:26:19 +0000 (04:26 -0500)
committerGitHub <noreply@github.com>
Mon, 11 Dec 2023 09:26:19 +0000 (02:26 -0700)
Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs

index 3a92de1e73a8cce9ec7c40bb5af1e89e845660df..57b25e0dd6c7b13ea137403bc0336a69475e43eb 100644 (file)
@@ -53,6 +53,8 @@ public abstract class SharedStorageSystem : EntitySystem
     [ValidatePrototypeId<ItemSizePrototype>]
     public const string DefaultStorageMaxItemSize = "Normal";
 
+    public bool CheckingCanInsert;
+
     /// <inheritdoc />
     public override void Initialize()
     {
@@ -465,7 +467,11 @@ public abstract class SharedStorageSystem : EntitySystem
         if (args.Cancelled || args.Container.ID != StorageComponent.ContainerId)
             return;
 
-        if (!CanInsert(uid, args.EntityUid, out _, component, ignoreStacks: true, includeContainerChecks: false))
+        // don't run cyclical CanInsert() loops
+        if (CheckingCanInsert)
+            return;
+
+        if (!CanInsert(uid, args.EntityUid, out _, component, ignoreStacks: true))
             args.Cancel();
     }
 
@@ -534,8 +540,7 @@ public abstract class SharedStorageSystem : EntitySystem
         StorageComponent? storageComp = null,
         ItemComponent? item = null,
         bool ignoreStacks = false,
-        bool ignoreLocation = false,
-        bool includeContainerChecks = true)
+        bool ignoreLocation = false)
     {
         if (!Resolve(uid, ref storageComp) || !Resolve(insertEnt, ref item, false))
         {
@@ -592,11 +597,14 @@ public abstract class SharedStorageSystem : EntitySystem
             }
         }
 
-        if (includeContainerChecks && !_containerSystem.CanInsert(insertEnt, storageComp.Container))
+        CheckingCanInsert = true;
+        if (!_containerSystem.CanInsert(insertEnt, storageComp.Container))
         {
+            CheckingCanInsert = false;
             reason = null;
             return false;
         }
+        CheckingCanInsert = false;
 
         reason = null;
         return true;