From 6aae2f0ae98747e61645716f835777bab9cbcaab Mon Sep 17 00:00:00 2001 From: Regalis Date: Fri, 2 Jun 2017 21:54:20 +0300 Subject: [PATCH] - Job assignment fix: characters that are in a different team don't add to the assigned job count. - If a client doesn't enter the game within 30 seconds of starting the game, their character is automatically killed (otherwise the character would stay in-game in the disabled state indefinitely). - Clients don't update CombatMissions if neither team has any characters (the clients may not have received messages about the characters spawning yet, which would cause them to show the "team dead" message immediately when the round starts). --- .../Source/Events/Missions/CombatMission.cs | 8 +++++++- Subsurface/Source/Networking/GameServer.cs | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Subsurface/Source/Events/Missions/CombatMission.cs b/Subsurface/Source/Events/Missions/CombatMission.cs index cc2335880..08360dd2a 100644 --- a/Subsurface/Source/Events/Missions/CombatMission.cs +++ b/Subsurface/Source/Events/Missions/CombatMission.cs @@ -166,7 +166,13 @@ namespace Barotrauma } } } - + + 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; + } + bool[] teamDead = { crews[0].All(c => c.IsDead || c.IsUnconscious), diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index bb57df447..d51503625 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -33,6 +33,8 @@ namespace Barotrauma.Networking private DateTime sparseUpdateTimer; private DateTime refreshMasterTimer; + private DateTime roundStartTime; + private RestClient restClient; private bool masterServerResponded; private IRestResponse masterServerResponse; @@ -534,6 +536,14 @@ namespace Barotrauma.Networking } else { + //if 30 seconds have passed since the round started and the client isn't ingame yet, + //kill the clients character + if (gameStarted && c.Character != null && (DateTime.Now - roundStartTime).Seconds > 30.0f) + { + c.Character.Kill(CauseOfDeath.Disconnected); + c.Character = null; + } + ClientWriteLobby(c); } } @@ -1231,6 +1241,8 @@ namespace Barotrauma.Networking gameStarted = true; initiatedStartGame = false; + roundStartTime = DateTime.Now; + yield return CoroutineStatus.Success; } @@ -1944,6 +1956,9 @@ namespace Barotrauma.Networking unassigned = new List(unassigned); int[] assignedClientCount = new int[JobPrefab.List.Count]; + + int teamID = 0; + if (unassigned.Count > 0) teamID = unassigned[0].TeamID; if (assignHost) { @@ -1956,7 +1971,7 @@ namespace Barotrauma.Networking assignedClientCount[JobPrefab.List.IndexOf(myCharacter.Info.Job.Prefab)] = 1; } } - else if (myCharacter != null && !myCharacter.IsDead) + else if (myCharacter != null && !myCharacter.IsDead && myCharacter.TeamID == teamID) { assignedClientCount[JobPrefab.List.IndexOf(myCharacter.Info.Job.Prefab)]++; } @@ -1964,7 +1979,7 @@ namespace Barotrauma.Networking //count the clients who already have characters with an assigned job foreach (Client c in connectedClients) { - if (unassigned.Contains(c)) continue; + if (c.TeamID != teamID || unassigned.Contains(c)) continue; if (c.Character != null && !c.Character.IsDead) { assignedClientCount[JobPrefab.List.IndexOf(c.Character.Info.Job.Prefab)]++;