From f5d8669da36ad8cc3f0a7de1c84d5a9efc8777e1 Mon Sep 17 00:00:00 2001 From: Regalis Date: Sat, 3 Jun 2017 18:12:25 +0300 Subject: [PATCH] Clients wait until both teams have characters in them before they start to update CombatMissions. Character spawn messages aren't guaranteed to arrive at the same frame, so it's possible for one team to be empty at the start of the round, causing the clients to think the other team already won. --- .../Source/Events/Missions/CombatMission.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Subsurface/Source/Events/Missions/CombatMission.cs b/Subsurface/Source/Events/Missions/CombatMission.cs index a010effed..64c696a4f 100644 --- a/Subsurface/Source/Events/Missions/CombatMission.cs +++ b/Subsurface/Source/Events/Missions/CombatMission.cs @@ -19,6 +19,8 @@ namespace Barotrauma private static string[] teamNames = { "Team A", "Team B" }; + private bool initialized = false; + public override bool AllowRespawn { get { return false; } @@ -152,8 +154,10 @@ namespace Barotrauma public override void Update(float deltaTime) { - if (crews[0].Count == 0 && crews[1].Count == 0) + if (!initialized) { + crews[0].Clear(); + crews[1].Clear(); foreach (Character character in Character.CharacterList) { if (character.TeamID == 1) @@ -165,14 +169,16 @@ namespace Barotrauma crews[1].Add(character); } } - } - if (GameMain.Client == null) - { - //no characters in either team, i.e. the client hasn't received spawn messages yet - if (crews[0].Count == 0 && crews[1].Count == 0) return; - } + if (GameMain.Client != null) + { + //no characters in one of the teams, the client may not have received all spawn messages yet + if (crews[0].Count == 0 || crews[1].Count == 0) return; + } + initialized = true; + } + bool[] teamDead = { crews[0].All(c => c.IsDead || c.IsUnconscious),