From 79ff990ddf7c7af40f70bcc7ba2d3220730852ab Mon Sep 17 00:00:00 2001 From: faint <46868845+ficcialfaint@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:57:50 +0300 Subject: [PATCH] Replace direct uses of GameTicker dictionary with `TryGetValue` (#33222) Fix station events schedulers, antag selection and possibly other systems acting weird in a rare scenario --- Content.Server/Antag/AntagSelectionSystem.cs | 2 +- Content.Server/GameTicking/GameTicker.Lobby.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 610c0ad182..45daa7a312 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -184,7 +184,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem 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); diff --git a/Content.Server/GameTicking/GameTicker.Lobby.cs b/Content.Server/GameTicking/GameTicker.Lobby.cs index 61d9fd99ca..9a9eb61b67 100644 --- a/Content.Server/GameTicking/GameTicker.Lobby.cs +++ b/Content.Server/GameTicking/GameTicker.Lobby.cs @@ -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; } } -- 2.51.2