Fix storage fill giving no reason for failing (#27122)
This commit is contained in:
@@ -65,12 +65,23 @@ public sealed partial class StorageSystem
|
|||||||
var sortedItems = items
|
var sortedItems = items
|
||||||
.OrderByDescending(x => ItemSystem.GetItemShape(x.Comp).GetArea());
|
.OrderByDescending(x => ItemSystem.GetItemShape(x.Comp).GetArea());
|
||||||
|
|
||||||
|
ClearCantFillReasons();
|
||||||
foreach (var ent in sortedItems)
|
foreach (var ent in sortedItems)
|
||||||
{
|
{
|
||||||
if (Insert(uid, ent, out _, out var reason, storageComp: storage, playSound: false))
|
if (Insert(uid, ent, out _, out var reason, storageComp: storage, playSound: false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (CantFillReasons.Count > 0)
|
||||||
|
{
|
||||||
|
var reasons = string.Join(", ", CantFillReasons.Select(s => Loc.GetString(s)));
|
||||||
|
if (reason == null)
|
||||||
|
reason = reasons;
|
||||||
|
else
|
||||||
|
reason += $", {reasons}";
|
||||||
|
}
|
||||||
|
|
||||||
Log.Error($"Tried to StorageFill {ToPrettyString(ent)} inside {ToPrettyString(uid)} but can't. reason: {reason}");
|
Log.Error($"Tried to StorageFill {ToPrettyString(ent)} inside {ToPrettyString(uid)} but can't. reason: {reason}");
|
||||||
|
ClearCantFillReasons();
|
||||||
Del(ent);
|
Del(ent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Containers.ItemSlots;
|
using Content.Shared.Containers.ItemSlots;
|
||||||
using Content.Shared.Coordinates;
|
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
@@ -65,6 +64,8 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||||||
private readonly List<ItemSizePrototype> _sortedSizes = new();
|
private readonly List<ItemSizePrototype> _sortedSizes = new();
|
||||||
private FrozenDictionary<string, ItemSizePrototype> _nextSmallest = FrozenDictionary<string, ItemSizePrototype>.Empty;
|
private FrozenDictionary<string, ItemSizePrototype> _nextSmallest = FrozenDictionary<string, ItemSizePrototype>.Empty;
|
||||||
|
|
||||||
|
protected readonly List<string> CantFillReasons = [];
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -628,8 +629,15 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||||||
if (CheckingCanInsert)
|
if (CheckingCanInsert)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!CanInsert(uid, args.EntityUid, out _, component, ignoreStacks: true))
|
if (!CanInsert(uid, args.EntityUid, out var reason, component, ignoreStacks: true))
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
if (reason != null)
|
||||||
|
CantFillReasons.Add(reason);
|
||||||
|
#endif
|
||||||
|
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateAppearance(Entity<StorageComponent?, AppearanceComponent?> entity)
|
public void UpdateAppearance(Entity<StorageComponent?, AppearanceComponent?> entity)
|
||||||
@@ -1072,7 +1080,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
{
|
{
|
||||||
var saved = list[i];
|
var saved = list[i];
|
||||||
|
|
||||||
if (saved == location)
|
if (saved == location)
|
||||||
{
|
{
|
||||||
list.Remove(location);
|
list.Remove(location);
|
||||||
@@ -1259,6 +1267,13 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void ClearCantFillReasons()
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
CantFillReasons.Clear();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plays a clientside pickup animation for the specified uid.
|
/// Plays a clientside pickup animation for the specified uid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user