From 5d342e24ef2fa3180cf39bf4cf11b836b7d18b42 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 16 Jul 2018 16:27:13 +0300 Subject: [PATCH] Clients are allowed to vote to end the round if they have spawned at some point during the round, even if the character they controlled doesn't exist anymore (huskified or eaten). Closes #483 --- .../BarotraumaShared/Source/Networking/Client.cs | 14 ++++++++++++-- .../Source/Networking/GameServer.cs | 2 ++ .../BarotraumaShared/Source/Networking/Voting.cs | 6 +++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Networking/Client.cs b/Barotrauma/BarotraumaShared/Source/Networking/Client.cs index fff97a991..80965f69a 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/Client.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/Client.cs @@ -29,10 +29,20 @@ namespace Barotrauma.Networking public byte TeamID = 0; - public Character Character; + private Character character; + public Character Character + { + get { return character; } + set + { + character = value; + if (character != null) HasSpawned = true; + } + } public CharacterInfo CharacterInfo; public NetConnection Connection { get; set; } - public bool InGame; + public bool InGame; + public bool HasSpawned; //has the client spawned as a character during the current round public UInt16 LastRecvGeneralUpdate = 0; diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index a28c46986..6dbd84ce9 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -1512,6 +1512,7 @@ namespace Barotrauma.Networking foreach (Client client in connectedClients) { client.Character = null; + client.HasSpawned = false; client.InGame = false; } } @@ -1631,6 +1632,7 @@ namespace Barotrauma.Networking } client.Character = null; + client.HasSpawned = false; client.InGame = false; if (string.IsNullOrWhiteSpace(msg)) msg = client.Name + " has left the server"; diff --git a/Barotrauma/BarotraumaShared/Source/Networking/Voting.cs b/Barotrauma/BarotraumaShared/Source/Networking/Voting.cs index 28d430888..c78a1bede 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/Voting.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/Voting.cs @@ -111,11 +111,11 @@ namespace Barotrauma #endif break; case VoteType.EndRound: - if (sender.Character == null) return; + if (!sender.HasSpawned) return; sender.SetVote(voteType, inc.ReadBoolean()); - GameMain.NetworkMember.EndVoteCount = GameMain.Server.ConnectedClients.Count(c => c.Character != null && c.GetVote(VoteType.EndRound)); - GameMain.NetworkMember.EndVoteMax = GameMain.Server.ConnectedClients.Count(c => c.Character != null); + GameMain.NetworkMember.EndVoteCount = GameMain.Server.ConnectedClients.Count(c => c.HasSpawned && c.GetVote(VoteType.EndRound)); + GameMain.NetworkMember.EndVoteMax = GameMain.Server.ConnectedClients.Count(c => c.HasSpawned); break; case VoteType.Kick: