From a70319bbd20c85068f136095c77b017b88c632ca Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Sun, 9 Jun 2019 17:38:20 +0300 Subject: [PATCH] (97e5bb5d1) Don't show the "kick / vote to kick" buttons when inspecting the owner of the server, or display the "x voted to kick" message if someone tries to vote kick the owner. --- Barotrauma/BarotraumaClient/Source/Networking/Client.cs | 3 +++ .../BarotraumaClient/Source/Networking/GameClient.cs | 8 ++++++-- .../BarotraumaClient/Source/Screens/NetLobbyScreen.cs | 6 ++++-- .../BarotraumaServer/Source/Networking/GameServer.cs | 1 + Barotrauma/BarotraumaServer/Source/Networking/Voting.cs | 3 +-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/Client.cs b/Barotrauma/BarotraumaClient/Source/Networking/Client.cs index 55bc409f0..80c53f407 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/Client.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/Client.cs @@ -12,6 +12,7 @@ namespace Barotrauma.Networking public byte ID; public UInt16 CharacterID; public bool Muted; + public bool AllowKicking; } partial class Client : IDisposable @@ -37,6 +38,8 @@ namespace Barotrauma.Networking } } + public bool AllowKicking; + public void UpdateSoundPosition() { if (VoipSound == null) { return; } diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index ac6ffc6fc..96ea44c5e 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -1267,6 +1267,7 @@ namespace Barotrauma.Networking string name = inc.ReadString(); UInt16 characterID = inc.ReadUInt16(); bool muted = inc.ReadBoolean(); + bool allowKicking = inc.ReadBoolean(); inc.ReadPadBits(); tempClients.Add(new TempClient @@ -1274,7 +1275,8 @@ namespace Barotrauma.Networking ID = id, Name = name, CharacterID = characterID, - Muted = muted + Muted = muted, + AllowKicking = allowKicking }); } @@ -1290,13 +1292,15 @@ namespace Barotrauma.Networking { existingClient = new Client(tc.Name, tc.ID) { - Muted = tc.Muted + Muted = tc.Muted, + AllowKicking = tc.AllowKicking }; ConnectedClients.Add(existingClient); GameMain.NetLobbyScreen.AddPlayer(existingClient); } existingClient.Character = null; existingClient.Muted = tc.Muted; + existingClient.AllowKicking = tc.AllowKicking; if (tc.CharacterID > 0) { existingClient.Character = Entity.FindEntityByID(tc.CharacterID) as Character; diff --git a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs index 53b26baba..d050187db 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs @@ -1550,7 +1550,8 @@ namespace Barotrauma } - if (GameMain.Client != null && GameMain.Client.ServerSettings.Voting.AllowVoteKick && selectedClient != null) + if (GameMain.Client != null && GameMain.Client.ServerSettings.Voting.AllowVoteKick && + selectedClient != null && selectedClient.AllowKicking) { var kickVoteButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform), TextManager.Get("VoteToKick")) @@ -1561,7 +1562,8 @@ namespace Barotrauma }; } - if (GameMain.Client.HasPermission(ClientPermissions.Kick)) + if (GameMain.Client.HasPermission(ClientPermissions.Kick) && + selectedClient != null && selectedClient.AllowKicking) { var kickButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform), TextManager.Get("Kick")) diff --git a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs index 4e884f7fc..291ca50dc 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs @@ -1488,6 +1488,7 @@ namespace Barotrauma.Networking outmsg.Write(client.Name); outmsg.Write(client.Character == null || !gameStarted ? (ushort)0 : client.Character.ID); outmsg.Write(client.Muted); + outmsg.Write(client.Connection != OwnerConnection); //is kicking the player allowed outmsg.WritePadBits(); } } diff --git a/Barotrauma/BarotraumaServer/Source/Networking/Voting.cs b/Barotrauma/BarotraumaServer/Source/Networking/Voting.cs index 67f5012ba..cc4402453 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/Voting.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/Voting.cs @@ -62,11 +62,10 @@ namespace Barotrauma byte kickedClientID = inc.ReadByte(); Client kicked = GameMain.Server.ConnectedClients.Find(c => c.ID == kickedClientID); - if (kicked != null && !kicked.HasKickVoteFrom(sender)) + if (kicked != null && kicked.Connection != GameMain.Server.OwnerConnection && !kicked.HasKickVoteFrom(sender)) { kicked.AddKickVote(sender); Client.UpdateKickVotes(GameMain.Server.ConnectedClients); - GameMain.Server.SendChatMessage($"ServerMessage.HasVotedToKick~[initiator]={sender.Name}~[target]={kicked.Name}", ChatMessageType.Server, null); }