From ac9d40b606dabcd48a0477d348cb6f45a10d4809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= Date: Sun, 16 Aug 2020 19:35:50 +0200 Subject: [PATCH] Fix suspicion crash on forcing 0 players readied --- Content.Server/GameTicking/GamePresets/PresetSuspicion.cs | 6 ++++++ Content.Shared/SharedGameTicker.cs | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Content.Server/GameTicking/GamePresets/PresetSuspicion.cs b/Content.Server/GameTicking/GamePresets/PresetSuspicion.cs index 1f6e0437ca..fc09cc14a3 100644 --- a/Content.Server/GameTicking/GamePresets/PresetSuspicion.cs +++ b/Content.Server/GameTicking/GamePresets/PresetSuspicion.cs @@ -41,6 +41,12 @@ namespace Content.Server.GameTicking.GamePresets return false; } + if (readyPlayers.Count == 0) + { + _chatManager.DispatchServerAnnouncement($"No players readied up! Can't start Suspicion."); + return false; + } + var list = new List(readyPlayers); var prefList = new List(); diff --git a/Content.Shared/SharedGameTicker.cs b/Content.Shared/SharedGameTicker.cs index 5952c35f3e..846598dfbf 100644 --- a/Content.Shared/SharedGameTicker.cs +++ b/Content.Shared/SharedGameTicker.cs @@ -176,7 +176,7 @@ namespace Content.Shared public TimeSpan RoundDuration; - public uint PlayerCount; + public int PlayerCount; public List AllPlayersEndInfo; @@ -189,9 +189,9 @@ namespace Content.Shared var seconds = buffer.ReadInt32(); RoundDuration = new TimeSpan(hours, mins, seconds); - PlayerCount = buffer.ReadUInt32(); + PlayerCount = buffer.ReadInt32(); AllPlayersEndInfo = new List(); - for(var i = 0; i < PlayerCount + 1; i++) + for(var i = 0; i < PlayerCount; i++) { var readPlayerData = new RoundEndPlayerInfo {