Skip to content

Commit

Permalink
Fix list inv desync upon inserting stackables (cosmatic-drift-14#188)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dffdff2423 committed Mar 6, 2024
1 parent 4dce4de commit d7fa3af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion Content.Server/Item/ItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ protected override void OnStackCountChanged(EntityUid uid, ItemComponent compone
return;

_storage.RecalculateStorageUsed(container.Owner, storage);
_storage.UpdateUI(container.Owner, storage);
}
}
13 changes: 12 additions & 1 deletion Content.Shared/Item/SharedItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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<StorageComponent>(container.Owner, out var storage))
return;
_storage.UpdateUI(container.Owner, storage);
// end CD
}

private void AddPickupVerb(EntityUid uid, ItemComponent component, GetVerbsEvent<InteractionVerb> args)
{
if (args.Hands == null ||
Expand Down

0 comments on commit d7fa3af

Please sign in to comment.