Fixed clients being able to vote for kicking multiple times by disconnecting and reconnecting

This commit is contained in:
Regalis
2017-04-18 19:46:57 +03:00
parent 67a3020430
commit f407a38c9e
2 changed files with 9 additions and 6 deletions

View File

@@ -1774,8 +1774,9 @@ namespace Barotrauma.Networking
public void UpdateVoteStatus()
{
if (server.Connections.Count == 0) return;
if (connectedClients.Count == 0) return;
if (server.Connections.Count == 0|| connectedClients.Count == 0) return;
Client.UpdateKickVotes(connectedClients);
var clientsToKick = connectedClients.FindAll(c => c.KickVoteCount >= connectedClients.Count * KickVoteRequiredRatio);
foreach (Client c in clientsToKick)

View File

@@ -229,11 +229,13 @@ namespace Barotrauma
byte kickedClientID = inc.ReadByte();
Client kicked = GameMain.Server.ConnectedClients.Find(c => c.ID == kickedClientID);
if (kicked == null) return;
if (kicked != null)
{
kicked.AddKickVote(sender);
Client.UpdateKickVotes(GameMain.Server.ConnectedClients);
kicked.AddKickVote(sender);
GameMain.Server.SendChatMessage(sender.name + " has voted to kick " + kicked.name, ChatMessageType.Server, null);
GameMain.Server.SendChatMessage(sender.name + " has voted to kick " + kicked.name, ChatMessageType.Server, null);
}
break;
}