]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Don't throw on player spawn for playtime failure (#24148)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Tue, 16 Jan 2024 08:01:41 +0000 (19:01 +1100)
committerGitHub <noreply@github.com>
Tue, 16 Jan 2024 08:01:41 +0000 (01:01 -0700)
Still gets logged but won't abort the entire startup process.

Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs

index f865b25bacfef410df8d6ecb90382a330d0af0ba..035b60e4f33c94451375a549b8729c815986b951 100644 (file)
@@ -164,7 +164,11 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
             !_cfg.GetCVar(CCVars.GameRoleTimers))
             return true;
 
-        var playTimes = _tracking.GetTrackerTimes(player);
+        if (!_tracking.TryGetTrackerTimes(player, out var playTimes))
+        {
+            Log.Error($"Unable to check playtimes {Environment.StackTrace}");
+            playTimes = new Dictionary<string, TimeSpan>();
+        }
 
         return JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes);
     }
@@ -175,7 +179,11 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
         if (!_cfg.GetCVar(CCVars.GameRoleTimers))
             return roles;
 
-        var playTimes = _tracking.GetTrackerTimes(player);
+        if (!_tracking.TryGetTrackerTimes(player, out var playTimes))
+        {
+            Log.Error($"Unable to check playtimes {Environment.StackTrace}");
+            playTimes = new Dictionary<string, TimeSpan>();
+        }
 
         foreach (var job in _prototypes.EnumeratePrototypes<JobPrototype>())
         {
@@ -202,7 +210,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
         if (!_cfg.GetCVar(CCVars.GameRoleTimers))
             return;
 
-        var player = _playerManager.GetSessionByUserId(userId);
+        var player = _playerManager.GetSessionById(userId);
         if (!_tracking.TryGetTrackerTimes(player, out var playTimes))
         {
             // Sorry mate but your playtimes haven't loaded.