]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix inability to engage with economic Cargonia (#36668)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Fri, 18 Apr 2025 02:06:29 +0000 (22:06 -0400)
committerGitHub <noreply@github.com>
Fri, 18 Apr 2025 02:06:29 +0000 (12:06 +1000)
Fix inability to engage with cargo supremacy

Content.Server/Cargo/Systems/CargoSystem.Funds.cs
Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Content.Server/Cargo/Systems/CargoSystem.cs
Content.Server/Delivery/DeliverySystem.cs
Content.Shared/Cargo/SharedCargoSystem.cs

index 7990fbce1c0f3af2c6ddaae8d241f1895e39c001..d64c4676643c0d781231a2a6aa1573f9bb2f3b30 100644 (file)
@@ -39,8 +39,7 @@ public sealed partial class CargoSystem
         }
 
         ent.Comp.NextAccountActionTime = Timing.CurTime + ent.Comp.AccountActionDelay;
-        Dirty(ent);
-        UpdateBankAccount((station, bank), -args.Amount, CreateAccountDistribution(ent.Comp.Account, bank));
+        UpdateBankAccount((station, bank), -args.Amount,  ent.Comp.Account, dirty: false);
         _audio.PlayPvs(ApproveSound, ent);
 
         var tryGetIdentityShortInfoEvent = new TryGetIdentityShortInfoEvent(ent, args.Actor);
@@ -65,7 +64,7 @@ public sealed partial class CargoSystem
         else
         {
             var otherAccount = _protoMan.Index(args.Account.Value);
-            UpdateBankAccount((station, bank), args.Amount, CreateAccountDistribution(args.Account.Value, bank));
+            UpdateBankAccount((station, bank), args.Amount, args.Account.Value);
 
             if (!_emag.CheckFlag(ent, EmagType.Interaction))
             {
index ef9a601a8982881bbcc5074a5dab5b09bbcdf90b..f89f1b0e8f5969914fc23749c5d6fffffe0dad0e 100644 (file)
@@ -51,7 +51,7 @@ namespace Content.Server.Cargo.Systems
                 return;
 
             _audio.PlayPvs(ApproveSound, uid);
-            UpdateBankAccount((stationUid.Value, bank), (int) price, CreateAccountDistribution(component.Account, bank));
+            UpdateBankAccount((stationUid.Value, bank), (int) price, component.Account);
             QueueDel(args.Used);
             args.Handled = true;
         }
@@ -203,7 +203,7 @@ namespace Content.Server.Cargo.Systems
                 $"{ToPrettyString(player):user} approved order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] on account {component.Account} with balance at {accountBalance}");
 
             orderDatabase.Orders[component.Account].Remove(order);
-            UpdateBankAccount((station.Value, bank), -cost, CreateAccountDistribution(component.Account, bank));
+            UpdateBankAccount((station.Value, bank), -cost, component.Account);
             UpdateOrders(station.Value);
         }
 
index 84319ab79332c6fe2d75c34919a0537f8cf95943..aaa14d196f096a7ee150d7180721299b97497dc7 100644 (file)
@@ -334,13 +334,13 @@ public sealed partial class CargoSystem
         if (!SellPallets(gridUid, out var goods))
             return;
 
-        var baseDistribution = CreateAccountDistribution(bankAccount.PrimaryAccount, bankAccount, bankAccount.PrimaryCut);
+        var baseDistribution = CreateAccountDistribution((station, bankAccount));
         foreach (var (_, sellComponent, value) in goods)
         {
             Dictionary<ProtoId<CargoAccountPrototype>, double> distribution;
             if (sellComponent != null)
             {
-                distribution = new Dictionary<ProtoId<CargoAccountPrototype>, double>()
+                distribution = new Dictionary<ProtoId<CargoAccountPrototype>, double>
                 {
                     { sellComponent.OverrideAccount, bankAccount.PrimaryCut },
                     { bankAccount.PrimaryAccount, 1.0 - bankAccount.PrimaryCut },
index 646625d5d8b1bdceb73937cb697ad4d2d19b65f7..d0ec138e4e036888ec62f6de9e99f82747a92de3 100644 (file)
@@ -75,13 +75,26 @@ public sealed partial class CargoSystem : SharedCargoSystem
         UpdateBounty();
     }
 
+    public void UpdateBankAccount(
+        Entity<StationBankAccountComponent?> ent,
+        int balanceAdded,
+        ProtoId<CargoAccountPrototype> account,
+        bool dirty = true)
+    {
+        UpdateBankAccount(
+            ent,
+            balanceAdded,
+            new Dictionary<ProtoId<CargoAccountPrototype>, double> { {account, 1} },
+            dirty: dirty);
+    }
+
     /// <summary>
     /// Adds or removes funds from the <see cref="StationBankAccountComponent"/>.
     /// </summary>
     /// <param name="ent">The station.</param>
     /// <param name="balanceAdded">The amount of funds to add or remove.</param>
     /// <param name="accountDistribution">The distribution between individual <see cref="CargoAccountPrototype"/>.</param>
-    /// <param name="dirty">Whether to mark the bank accoujnt component as dirty.</param>
+    /// <param name="dirty">Whether to mark the bank account component as dirty.</param>
     [PublicAPI]
     public void UpdateBankAccount(
         Entity<StationBankAccountComponent?> ent,
index 91dff3b855becdf5bcc3989ca0096a96a6a8c7c5..329e3d11edf47c810020ffa1666cb8ae2f12ec05 100644 (file)
@@ -76,7 +76,7 @@ public sealed partial class DeliverySystem : SharedDeliverySystem
         _cargo.UpdateBankAccount(
             (ent.Comp.RecipientStation.Value, account),
             ent.Comp.SpesoReward,
-            _cargo.CreateAccountDistribution(account.PrimaryAccount, account, account.PrimaryCut));
+            _cargo.CreateAccountDistribution((ent.Comp.RecipientStation.Value, account)));
     }
 
     public override void Update(float frameTime)
index 8f76f778881adda27a3e8eb14dc950e52efeba5e..84633073b5aa25f2af6c075fa70c3d9ac4175a3b 100644 (file)
@@ -1,4 +1,3 @@
-using System.Linq;
 using Content.Shared.Cargo.Components;
 using Content.Shared.Cargo.Prototypes;
 using Robust.Shared.Prototypes;
@@ -36,30 +35,21 @@ public abstract class SharedCargoSystem : EntitySystem
     }
 
     /// <summary>
-    /// For a station, creates a distribution between one "primary" account and the other accounts.
-    /// The primary account receives the majority cut specified, with the remaining accounts getting cuts
-    /// distributed through the remaining amount, based on <see cref="StationBankAccountComponent.RevenueDistribution"/>
+    /// For a station, creates a distribution between one the bank's account and the other accounts.
+    /// The primary account receives the majority percentage listed on the bank account, with the remaining
+    /// funds distributed to all accounts based on <see cref="StationBankAccountComponent.RevenueDistribution"/>
     /// </summary>
-    public Dictionary<ProtoId<CargoAccountPrototype>, double> CreateAccountDistribution(
-        ProtoId<CargoAccountPrototype> primary,
-        StationBankAccountComponent stationBank,
-        double primaryCut = 1.0)
+    public Dictionary<ProtoId<CargoAccountPrototype>, double> CreateAccountDistribution(Entity<StationBankAccountComponent> stationBank)
     {
         var distribution = new Dictionary<ProtoId<CargoAccountPrototype>, double>
         {
-            { primary, primaryCut }
+            { stationBank.Comp.PrimaryAccount, stationBank.Comp.PrimaryCut }
         };
-        var remaining = 1.0 - primaryCut;
+        var remaining = 1.0 - stationBank.Comp.PrimaryCut;
 
-        var allAccountPercentages = new Dictionary<ProtoId<CargoAccountPrototype>, double>(stationBank.RevenueDistribution);
-        allAccountPercentages.Remove(primary);
-        var weightsSum = allAccountPercentages.Values.Sum();
-
-        foreach (var (account, percentage) in allAccountPercentages)
+        foreach (var (account, percentage) in stationBank.Comp.RevenueDistribution)
         {
-            var adjustedPercentage = percentage / weightsSum;
-
-            distribution.Add(account, remaining * adjustedPercentage);
+            distribution.Add(account, remaining * percentage);
         }
         return distribution;
     }