fix small CanInsert bug (#22302)

This commit is contained in:
Nemanja
2023-12-11 04:26:19 -05:00
committed by GitHub
parent f9dadba3ac
commit 1945ded919

View File

@@ -53,6 +53,8 @@ public abstract class SharedStorageSystem : EntitySystem
[ValidatePrototypeId<ItemSizePrototype>] [ValidatePrototypeId<ItemSizePrototype>]
public const string DefaultStorageMaxItemSize = "Normal"; public const string DefaultStorageMaxItemSize = "Normal";
public bool CheckingCanInsert;
/// <inheritdoc /> /// <inheritdoc />
public override void Initialize() public override void Initialize()
{ {
@@ -465,7 +467,11 @@ public abstract class SharedStorageSystem : EntitySystem
if (args.Cancelled || args.Container.ID != StorageComponent.ContainerId) if (args.Cancelled || args.Container.ID != StorageComponent.ContainerId)
return; 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(); args.Cancel();
} }
@@ -534,8 +540,7 @@ public abstract class SharedStorageSystem : EntitySystem
StorageComponent? storageComp = null, StorageComponent? storageComp = null,
ItemComponent? item = null, ItemComponent? item = null,
bool ignoreStacks = false, bool ignoreStacks = false,
bool ignoreLocation = false, bool ignoreLocation = false)
bool includeContainerChecks = true)
{ {
if (!Resolve(uid, ref storageComp) || !Resolve(insertEnt, ref item, 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; reason = null;
return false; return false;
} }
CheckingCanInsert = false;
reason = null; reason = null;
return true; return true;