]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make advertise system survive no map inits (#26553)
authorWrexbe (Josh) <81056464+wrexbe@users.noreply.github.com>
Sun, 31 Mar 2024 01:34:31 +0000 (18:34 -0700)
committerGitHub <noreply@github.com>
Sun, 31 Mar 2024 01:34:31 +0000 (12:34 +1100)
* Make advertise system survive no map inits

* Add comment to try prevent future bugs

Content.Server/Advertise/EntitySystems/AdvertiseSystem.cs

index bb254d11ef0be5b85ed6c24787e5dd8fa8edc1e0..b326321d5466943c5645cd748a1ab2f7980ce90b 100644 (file)
@@ -23,7 +23,7 @@ public sealed class AdvertiseSystem : EntitySystem
     /// <summary>
     /// The next time the game will check if advertisements should be displayed
     /// </summary>
-    private TimeSpan _nextCheckTime = TimeSpan.MaxValue;
+    private TimeSpan _nextCheckTime = TimeSpan.MinValue;
 
     public override void Initialize()
     {
@@ -33,8 +33,8 @@ public sealed class AdvertiseSystem : EntitySystem
         SubscribeLocalEvent<ApcPowerReceiverComponent, AdvertiseEnableChangeAttemptEvent>(OnPowerReceiverEnableChangeAttempt);
         SubscribeLocalEvent<VendingMachineComponent, AdvertiseEnableChangeAttemptEvent>(OnVendingEnableChangeAttempt);
 
-        // The component inits will lower this.
-        _nextCheckTime = TimeSpan.MaxValue;
+        // Force it to check on the next update.
+        _nextCheckTime = TimeSpan.MinValue;
     }
 
     private void OnMapInit(EntityUid uid, AdvertiseComponent advertise, MapInitEvent args)
@@ -110,6 +110,8 @@ public sealed class AdvertiseSystem : EntitySystem
         if (_nextCheckTime > curTime)
             return;
 
+        // Note that as _nextCheckTime currently starts at TimeSpan.MinValue, so this has to SET the value, not just
+        // increment it.
         _nextCheckTime = curTime + _maximumNextCheckDuration;
 
         var query = EntityQueryEnumerator<AdvertiseComponent>();