From 734b86bfba5e946d5a4297c37b82bc0d6c6b7890 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 16 Jul 2018 11:24:11 +0300 Subject: [PATCH] Fixed clients being unable to give non-permanent or range bans. Closes #481 --- .../BarotraumaClient/Source/Networking/GameClient.cs | 2 ++ .../BarotraumaShared/Source/Networking/GameServer.cs | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 020657672..85a95579e 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -1441,6 +1441,8 @@ namespace Barotrauma.Networking msg.Write((byte)ClientPermissions.Ban); msg.Write(kickedName); msg.Write(reason); + msg.Write(range); + msg.Write(duration.HasValue ? duration.Value.TotalSeconds : 0.0); //0 = permaban client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered); } diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index 6f23189c2..a28c46986 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -780,11 +780,21 @@ namespace Barotrauma.Networking case ClientPermissions.Ban: string bannedName = inc.ReadString().ToLowerInvariant(); string banReason = inc.ReadString(); + bool range = inc.ReadBoolean(); + double durationSeconds = inc.ReadDouble(); + var bannedClient = connectedClients.Find(cl => cl != sender && cl.Name.ToLowerInvariant() == bannedName); if (bannedClient != null) { Log("Client \"" + sender.Name + "\" banned \"" + bannedClient.Name + "\".", ServerLog.MessageType.ServerMessage); - BanClient(bannedClient, string.IsNullOrEmpty(banReason) ? "Banned by " + sender.Name : banReason, false); + if (durationSeconds > 0) + { + BanClient(bannedClient, string.IsNullOrEmpty(banReason) ? "Banned by " + sender.Name : banReason, range, TimeSpan.FromSeconds(durationSeconds)); + } + else + { + BanClient(bannedClient, string.IsNullOrEmpty(banReason) ? "Banned by " + sender.Name : banReason, range); + } } break; case ClientPermissions.EndRound: