From 7935ecce4609a434d38bad30ce8f29edbecf2240 Mon Sep 17 00:00:00 2001 From: juanjp600 Date: Wed, 1 Mar 2017 17:04:51 -0300 Subject: [PATCH] - fixed crash in UpdateVoteStatus - fixed clients reconnecting automatically after being kicked for desync --- Subsurface/Source/Networking/GameClient.cs | 1 + Subsurface/Source/Networking/GameServer.cs | 3 ++- .../Networking/NetEntityEvent/ServerEntityEventManager.cs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 5f7e790be..d72ba0ebe 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -557,6 +557,7 @@ namespace Barotrauma.Networking case "The server has been shut down": case "You have been banned from the server": case "You have been kicked from the server": + case "You have been disconnected because of excessive desync": var msgBox = new GUIMessageBox("CONNECTION LOST", disconnectMsg); msgBox.Buttons[0].OnClicked += ReturnToServerList; break; diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 770a77d10..f9b5ac1e7 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -1669,7 +1669,8 @@ namespace Barotrauma.Networking public void UpdateVoteStatus() { if (server.Connections.Count == 0) return; - + if (connectedClients.Count == 0) return; + var clientsToKick = connectedClients.FindAll(c => c.KickVoteCount >= connectedClients.Count * KickVoteRequiredRatio); foreach (Client c in clientsToKick) { diff --git a/Subsurface/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs b/Subsurface/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs index af05bd87a..e29441edc 100644 --- a/Subsurface/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs +++ b/Subsurface/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs @@ -135,7 +135,7 @@ namespace Barotrauma.Networking //it's been 10 seconds since this event was created //kick everyone that hasn't received it yet, this is way too old List toKick = clients.FindAll(c => c.inGame && c.lastRecvEntityEventID <= lastSentToAll); - if (toKick!=null) toKick.ForEach(c => GameMain.Server.DisconnectClient(c,"","You have been disconnected because of excessive desync.")); + if (toKick!=null) toKick.ForEach(c => GameMain.Server.DisconnectClient(c,"","You have been disconnected because of excessive desync")); } }