]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Replace direct uses of GameTicker dictionary with `TryGetValue` (#33222)
authorfaint <46868845+ficcialfaint@users.noreply.github.com>
Mon, 18 Nov 2024 18:57:50 +0000 (21:57 +0300)
committerGitHub <noreply@github.com>
Mon, 18 Nov 2024 18:57:50 +0000 (21:57 +0300)
Fix station events schedulers, antag selection and possibly other systems acting weird in a rare scenario

Content.Server/Antag/AntagSelectionSystem.cs
Content.Server/GameTicking/GameTicker.Lobby.cs

index 610c0ad182ada85af7b5105512eb713cba6677c5..45daa7a312f48a3a4e03c1dabbd360613be9942c 100644 (file)
@@ -184,7 +184,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
             return;
 
         var players = _playerManager.Sessions
-            .Where(x => GameTicker.PlayerGameStatuses[x.UserId] == PlayerGameStatus.JoinedGame)
+            .Where(x => GameTicker.PlayerGameStatuses.TryGetValue(x.UserId, out var status) && status == PlayerGameStatus.JoinedGame)
             .ToList();
 
         ChooseAntags((uid, component), players, midround: true);
index 61d9fd99caeae53e5e41ee47087c3cf7fdb49b92..9a9eb61b6737036e3ff5ce5bd246305b3799a9c5 100644 (file)
@@ -184,6 +184,6 @@ namespace Content.Server.GameTicking
             => UserHasJoinedGame(session.UserId);
 
         public bool UserHasJoinedGame(NetUserId userId)
-            => PlayerGameStatuses[userId] == PlayerGameStatus.JoinedGame;
+            => PlayerGameStatuses.TryGetValue(userId, out var status) && status == PlayerGameStatus.JoinedGame;
     }
 }