Fixed clients being able to vote for kicking multiple times by disconnecting and reconnecting
This commit is contained in:
@@ -1774,8 +1774,9 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public void UpdateVoteStatus()
|
public void UpdateVoteStatus()
|
||||||
{
|
{
|
||||||
if (server.Connections.Count == 0) return;
|
if (server.Connections.Count == 0|| connectedClients.Count == 0) return;
|
||||||
if (connectedClients.Count == 0) return;
|
|
||||||
|
Client.UpdateKickVotes(connectedClients);
|
||||||
|
|
||||||
var clientsToKick = connectedClients.FindAll(c => c.KickVoteCount >= connectedClients.Count * KickVoteRequiredRatio);
|
var clientsToKick = connectedClients.FindAll(c => c.KickVoteCount >= connectedClients.Count * KickVoteRequiredRatio);
|
||||||
foreach (Client c in clientsToKick)
|
foreach (Client c in clientsToKick)
|
||||||
|
|||||||
@@ -229,11 +229,13 @@ namespace Barotrauma
|
|||||||
byte kickedClientID = inc.ReadByte();
|
byte kickedClientID = inc.ReadByte();
|
||||||
|
|
||||||
Client kicked = GameMain.Server.ConnectedClients.Find(c => c.ID == kickedClientID);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user