From d05ed6c54bf892a5e8e3d33a71b8bf2603f998f5 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 12 Jan 2018 10:56:56 +0200 Subject: [PATCH] Fixed banip command only kicking the matching client out of the server without banning, + the command now kickbans all clients with a matching ip. Closes #227 --- Barotrauma/BarotraumaShared/Source/DebugConsole.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs index c5ffe793d..bf228f6b5 100644 --- a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs @@ -711,7 +711,7 @@ namespace Barotrauma { if (GameMain.Server == null || args.Length == 0) return; - ShowQuestionPrompt("Reason for banning the ip \"" + commands[1] + "\"?", (reason) => + ShowQuestionPrompt("Reason for banning the ip \"" + args[0] + "\"?", (reason) => { ShowQuestionPrompt("Enter the duration of the ban (leave empty to ban permanently, or use the format \"[days] d [hours] h\")", (duration) => { @@ -727,14 +727,17 @@ namespace Barotrauma banDuration = parsedBanDuration; } - var client = GameMain.Server.ConnectedClients.Find(c => c.Connection.RemoteEndPoint.Address.ToString() == args[0]); - if (client == null) + var clients = GameMain.Server.ConnectedClients.FindAll(c => c.Connection.RemoteEndPoint.Address.ToString() == args[0]); + if (clients.Count == 0) { GameMain.Server.BanList.BanPlayer("Unnamed", args[0], reason, banDuration); } else { - GameMain.Server.KickClient(client, reason); + foreach (Client cl in clients) + { + GameMain.Server.BanClient(cl, reason, false, banDuration); + } } }); });