From d7fa3af5a1163111ebe6876b48a6c7287e7fc12d Mon Sep 17 00:00:00 2001 From: dffdff2423 <57052305+dffdff2423@users.noreply.github.com> Date: Wed, 6 Mar 2024 15:52:42 -0600 Subject: [PATCH] Fix list inv desync upon inserting stackables (#188) Fixes a desync upon inserting a stack into a container that already had a stack of the same item type. This was because UpdateUI was only being called server side which has no effect. --- Content.Server/Item/ItemSystem.cs | 1 - Content.Shared/Item/SharedItemSystem.cs | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Content.Server/Item/ItemSystem.cs b/Content.Server/Item/ItemSystem.cs index efb99ae653..0e86b245aa 100644 --- a/Content.Server/Item/ItemSystem.cs +++ b/Content.Server/Item/ItemSystem.cs @@ -19,6 +19,5 @@ protected override void OnStackCountChanged(EntityUid uid, ItemComponent compone return; _storage.RecalculateStorageUsed(container.Owner, storage); - _storage.UpdateUI(container.Owner, storage); } } diff --git a/Content.Shared/Item/SharedItemSystem.cs b/Content.Shared/Item/SharedItemSystem.cs index a379c4f724..196b77f66d 100644 --- a/Content.Shared/Item/SharedItemSystem.cs +++ b/Content.Shared/Item/SharedItemSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Examine; using Content.Shared.Item.ItemToggle.Components; using Content.Shared.Storage; +using Content.Shared.Storage.EntitySystems; using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.GameStates; @@ -21,6 +22,9 @@ public abstract class SharedItemSystem : EntitySystem [Dependency] private readonly SharedCombatModeSystem _combatMode = default!; [Dependency] protected readonly SharedContainerSystem Container = default!; + // CD: Fix stackable insert desync + [Dependency] private readonly SharedStorageSystem _storage = default!; + public override void Initialize() { base.Initialize(); @@ -99,8 +103,15 @@ protected virtual void OnStackCountChanged(EntityUid uid, ItemComponent componen return; SetSize(uid, args.NewCount * size, component); + + // CD: Fix stackable insert desync + if (!Container.TryGetContainingContainer(uid, out var container) || + !TryComp(container.Owner, out var storage)) + return; + _storage.UpdateUI(container.Owner, storage); + // end CD } - + private void AddPickupVerb(EntityUid uid, ItemComponent component, GetVerbsEvent args) { if (args.Hands == null ||