diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 6c519c9fd4a..69a276302f9 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -85,9 +85,11 @@ private void UpdateConsole(float frameTime) { _timer -= Delay; - foreach (var account in EntityQuery()) + var stationQuery = EntityQueryEnumerator(); + while (stationQuery.MoveNext(out var uid, out var bank)) { - account.Balance += account.IncreasePerSecond * Delay; + var balanceToAdd = bank.IncreasePerSecond * Delay; + UpdateBankAccount(uid, bank, balanceToAdd); } var query = EntityQueryEnumerator(); @@ -213,7 +215,7 @@ private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent com $"{ToPrettyString(player):user} approved order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] with balance at {bank.Balance}"); orderDatabase.Orders.Remove(order); - DeductFunds(bank, cost); + UpdateBankAccount(station.Value, bank, -cost); UpdateOrders(station.Value); } @@ -538,11 +540,6 @@ private bool FulfillOrder(CargoOrderData order, EntityCoordinates spawn, string? } - private void DeductFunds(StationBankAccountComponent component, int amount) - { - component.Balance = Math.Max(0, component.Balance - amount); - } - #region Station private bool TryGetOrderDatabase([NotNullWhen(true)] EntityUid? stationUid, [MaybeNullWhen(false)] out StationCargoOrderDatabaseComponent dbComp)