From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 11 May 2023 01:00:39 +0000 (+1000) Subject: Hotfix round restart loops (#16292) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=20748cc5426ef245edf5ead7f968f81cad10807b;p=space-station-14.git Hotfix round restart loops (#16292) Co-authored-by: DrSmugleaf --- diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 096d508f35..5ea96ff82c 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -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(); diff --git a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs index d480a5f661..50c64e718c 100644 --- a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs +++ b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs @@ -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? time) + { + time = null; + + if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized) + { + return false; + } + + time = data.TrackerTimes; + return true; + } + public Dictionary GetTrackerTimes(IPlayerSession id) { if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized) diff --git a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs index 1ff9eeee49..73e7e01f15 100644 --- a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs +++ b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs @@ -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(); + } for (var i = 0; i < jobs.Count; i++) {