From 1945ded919b485caaa91d4966bd3a69189ea6e16 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Mon, 11 Dec 2023 04:26:19 -0500 Subject: [PATCH] fix small CanInsert bug (#22302) --- .../Storage/EntitySystems/SharedStorageSystem.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs index 3a92de1e73..57b25e0dd6 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -53,6 +53,8 @@ public abstract class SharedStorageSystem : EntitySystem [ValidatePrototypeId] public const string DefaultStorageMaxItemSize = "Normal"; + public bool CheckingCanInsert; + /// 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;