]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Hotfix round restart loops (#16292)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Thu, 11 May 2023 01:00:39 +0000 (11:00 +1000)
committerGitHub <noreply@github.com>
Thu, 11 May 2023 01:00:39 +0000 (11:00 +1000)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
Content.Server/GameTicking/GameTicker.RoundFlow.cs
Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs
Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs

index 096d508f356b6874ab8933d876755d4aaa81d503..5ea96ff82c755053b829e8faa91177500465e663 100644 (file)
@@ -254,7 +254,7 @@ namespace Content.Server.GameTicking
                     return;
                 }
 
-                _sawmill.Warning($"Exception caught while trying to start the round! Restarting round...");
+                _sawmill.Error($"Exception caught while trying to start the round! Restarting round...");
                 _runtimeLog.LogException(e, nameof(GameTicker));
                 _startingRound = false;
                 RestartRound();
index d480a5f6617431bb944a3f50ab51f26e8506c884..50c64e718c3e1e1e8860b78d24ed4879458705ac 100644 (file)
@@ -1,4 +1,5 @@
-using System.Runtime.InteropServices;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
 using System.Threading;
 using System.Threading.Tasks;
 using Content.Server.Database;
@@ -350,6 +351,19 @@ public sealed class PlayTimeTrackingManager
         return GetPlayTimeForTracker(id, PlayTimeTrackingShared.TrackerOverall);
     }
 
+    public bool TryGetTrackerTimes(IPlayerSession id, [NotNullWhen(true)] out Dictionary<string, TimeSpan>? time)
+    {
+        time = null;
+
+        if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
+        {
+            return false;
+        }
+
+        time = data.TrackerTimes;
+        return true;
+    }
+
     public Dictionary<string, TimeSpan> GetTrackerTimes(IPlayerSession id)
     {
         if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized)
index 1ff9eeee49ca5eddab76f1c956e6e488b383b5c4..73e7e01f15db69e9f6f29a28318924f0a2c02e6a 100644 (file)
@@ -201,7 +201,12 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
             return;
 
         var player = _playerManager.GetSessionByUserId(userId);
-        var playTimes = _tracking.GetTrackerTimes(player);
+        if (!_tracking.TryGetTrackerTimes(player, out var playTimes))
+        {
+            // Sorry mate but your playtimes haven't loaded.
+            Logger.ErrorS("playtime", $"Playtimes weren't ready yet for {player} on roundstart!");
+            playTimes ??= new Dictionary<string, TimeSpan>();
+        }
 
         for (var i = 0; i < jobs.Count; i++)
         {