From f8d023f286bdf1b38bb69349e1c474792a950f51 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 17 Mar 2024 01:06:17 +1100 Subject: [PATCH] Fix store refunds (#26173) --- Content.Server/Store/Systems/StoreSystem.Ui.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Content.Server/Store/Systems/StoreSystem.Ui.cs b/Content.Server/Store/Systems/StoreSystem.Ui.cs index a7490fd27f..25b1cd1f6c 100644 --- a/Content.Server/Store/Systems/StoreSystem.Ui.cs +++ b/Content.Server/Store/Systems/StoreSystem.Ui.cs @@ -323,7 +323,7 @@ public sealed partial class StoreSystem if (!component.RefundAllowed || component.BoughtEntities.Count == 0) return; - for (var i = component.BoughtEntities.Count; i >= 0; i--) + for (var i = component.BoughtEntities.Count - 1; i >= 0; i--) { var purchase = component.BoughtEntities[i]; @@ -332,7 +332,7 @@ public sealed partial class StoreSystem component.BoughtEntities.RemoveAt(i); - if (_actions.TryGetActionData(purchase, out var actionComponent)) + if (_actions.TryGetActionData(purchase, out var actionComponent, logError: false)) { _actionContainer.RemoveAction(purchase, actionComponent); } @@ -340,6 +340,8 @@ public sealed partial class StoreSystem EntityManager.DeleteEntity(purchase); } + component.BoughtEntities.Clear(); + foreach (var (currency, value) in component.BalanceSpent) { component.Balance[currency] += value;