From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 16 Mar 2024 14:06:17 +0000 (+1100) Subject: Fix store refunds (#26173) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=f8d023f286bdf1b38bb69349e1c474792a950f51;p=space-station-14.git Fix store refunds (#26173) --- 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;