]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix station income instantly accumulating roundstart (#36572)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Mon, 14 Apr 2025 23:00:34 +0000 (19:00 -0400)
committerGitHub <noreply@github.com>
Mon, 14 Apr 2025 23:00:34 +0000 (01:00 +0200)
Fix station money accumulating roundstart

Content.Server/Cargo/Systems/CargoSystem.Bounty.cs
Content.Server/Cargo/Systems/CargoSystem.Funds.cs
Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Content.Server/Cargo/Systems/CargoSystem.cs
Content.Shared/Cargo/SharedCargoSystem.cs

index 9a6acbc6ef0bf5b8d4762bbc80d554ae6f371733..10e8b40e53e0d244578fed1dca3a43e5cd072b96 100644 (file)
@@ -55,13 +55,13 @@ public sealed partial class CargoSystem
             !TryComp<StationCargoBountyDatabaseComponent>(station, out var bountyDb))
             return;
 
-        var untilNextSkip = bountyDb.NextSkipTime - _timing.CurTime;
+        var untilNextSkip = bountyDb.NextSkipTime - Timing.CurTime;
         _uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(bountyDb.Bounties, bountyDb.History, untilNextSkip));
     }
 
     private void OnPrintLabelMessage(EntityUid uid, CargoBountyConsoleComponent component, BountyPrintLabelMessage args)
     {
-        if (_timing.CurTime < component.NextPrintTime)
+        if (Timing.CurTime < component.NextPrintTime)
             return;
 
         if (_station.GetOwningStation(uid) is not { } station)
@@ -71,7 +71,7 @@ public sealed partial class CargoSystem
             return;
 
         var label = Spawn(component.BountyLabelId, Transform(uid).Coordinates);
-        component.NextPrintTime = _timing.CurTime + component.PrintDelay;
+        component.NextPrintTime = Timing.CurTime + component.PrintDelay;
         SetupBountyLabel(label, station, bounty.Value);
         _audio.PlayPvs(component.PrintSound, uid);
     }
@@ -81,7 +81,7 @@ public sealed partial class CargoSystem
         if (_station.GetOwningStation(uid) is not { } station || !TryComp<StationCargoBountyDatabaseComponent>(station, out var db))
             return;
 
-        if (_timing.CurTime < db.NextSkipTime)
+        if (Timing.CurTime < db.NextSkipTime)
             return;
 
         if (!TryGetBountyFromId(station, args.BountyId, out var bounty))
@@ -101,8 +101,8 @@ public sealed partial class CargoSystem
             return;
 
         FillBountyDatabase(station);
-        db.NextSkipTime = _timing.CurTime + db.SkipDelay;
-        var untilNextSkip = db.NextSkipTime - _timing.CurTime;
+        db.NextSkipTime = Timing.CurTime + db.SkipDelay;
+        var untilNextSkip = db.NextSkipTime - Timing.CurTime;
         _uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, db.History, untilNextSkip));
         _audio.PlayPvs(component.SkipSound, uid);
     }
@@ -471,7 +471,7 @@ public sealed partial class CargoSystem
                     skipped
                         ? CargoBountyHistoryData.BountyResult.Skipped
                         : CargoBountyHistoryData.BountyResult.Completed,
-                    _timing.CurTime,
+                    Timing.CurTime,
                     actorName));
                 ent.Comp.Bounties.RemoveAt(i);
                 return true;
@@ -513,7 +513,7 @@ public sealed partial class CargoSystem
                 continue;
             }
 
-            var untilNextSkip = db.NextSkipTime - _timing.CurTime;
+            var untilNextSkip = db.NextSkipTime - Timing.CurTime;
             _uiSystem.SetUiState((uid, ui), CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, db.History, untilNextSkip));
         }
     }
index f167697e728d5f02b03782b91a63e2fbbffbb84a..7990fbce1c0f3af2c6ddaae8d241f1895e39c001 100644 (file)
@@ -28,7 +28,7 @@ public sealed partial class CargoSystem
             args.Amount > GetBalanceFromAccount((station, bank), ent.Comp.Account) * ent.Comp.TransferLimit)
             return;
 
-        if (_timing.CurTime < ent.Comp.NextAccountActionTime)
+        if (Timing.CurTime < ent.Comp.NextAccountActionTime)
             return;
 
         if (!_accessReaderSystem.IsAllowed(args.Actor, ent))
@@ -38,7 +38,7 @@ public sealed partial class CargoSystem
             return;
         }
 
-        ent.Comp.NextAccountActionTime = _timing.CurTime + ent.Comp.AccountActionDelay;
+        ent.Comp.NextAccountActionTime = Timing.CurTime + ent.Comp.AccountActionDelay;
         Dirty(ent);
         UpdateBankAccount((station, bank), -args.Amount, CreateAccountDistribution(ent.Comp.Account, bank));
         _audio.PlayPvs(ApproveSound, ent);
index 39b3f144ff55a6c7622176ed6345d90730fa34f3..ef9a601a8982881bbcc5074a5dab5b09bbcdf90b 100644 (file)
@@ -78,7 +78,7 @@ namespace Content.Server.Cargo.Systems
             var stationQuery = EntityQueryEnumerator<StationBankAccountComponent>();
             while (stationQuery.MoveNext(out var uid, out var bank))
             {
-                if (_timing.CurTime < bank.NextIncomeTime)
+                if (Timing.CurTime < bank.NextIncomeTime)
                     continue;
                 bank.NextIncomeTime += bank.IncomeDelay;
 
index 450f292c9d5e4ddab9c87b012ee6a2bd46ba2bc3..646625d5d8b1bdceb73937cb697ad4d2d19b65f7 100644 (file)
@@ -17,14 +17,12 @@ using JetBrains.Annotations;
 using Robust.Server.GameObjects;
 using Robust.Shared.Audio.Systems;
 using Robust.Shared.Prototypes;
-using Robust.Shared.Timing;
 using Robust.Shared.Random;
 
 namespace Content.Server.Cargo.Systems;
 
 public sealed partial class CargoSystem : SharedCargoSystem
 {
-    [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly IPrototypeManager _protoMan = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
index e2ef2348603565ab34059e86cb03dcbf62451a1b..8f76f778881adda27a3e8eb14dc950e52efeba5e 100644 (file)
@@ -3,11 +3,27 @@ using Content.Shared.Cargo.Components;
 using Content.Shared.Cargo.Prototypes;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Serialization;
+using Robust.Shared.Timing;
 
 namespace Content.Shared.Cargo;
 
 public abstract class SharedCargoSystem : EntitySystem
 {
+    [Dependency] protected readonly IGameTiming Timing = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<StationBankAccountComponent, MapInitEvent>(OnMapInit);
+    }
+
+    private void OnMapInit(Entity<StationBankAccountComponent> ent, ref MapInitEvent args)
+    {
+        ent.Comp.NextIncomeTime = Timing.CurTime + ent.Comp.IncomeDelay;
+        Dirty(ent);
+    }
+
     /// <summary>
     /// For a given station, retrieves the balance in a specific account.
     /// </summary>