(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.
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user