2f107db...5202af9
This commit is contained in:
@@ -1,7 +1,22 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Lidgren.Network;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma.Networking
|
||||
{
|
||||
partial class BannedPlayer
|
||||
{
|
||||
public BannedPlayer(string name, UInt16 uniqueIdentifier, bool isRangeBan, string ip, ulong steamID)
|
||||
{
|
||||
this.Name = name;
|
||||
this.SteamID = steamID;
|
||||
this.IsRangeBan = isRangeBan;
|
||||
this.IP = ip;
|
||||
this.UniqueIdentifier = uniqueIdentifier;
|
||||
}
|
||||
}
|
||||
|
||||
partial class BanList
|
||||
{
|
||||
private GUIComponent banFrame;
|
||||
@@ -11,12 +26,27 @@ namespace Barotrauma.Networking
|
||||
get { return banFrame; }
|
||||
}
|
||||
|
||||
public List<UInt16> localRemovedBans = new List<UInt16>();
|
||||
public List<UInt16> localRangeBans = new List<UInt16>();
|
||||
|
||||
private void RecreateBanFrame()
|
||||
{
|
||||
if (banFrame != null)
|
||||
{
|
||||
var parent = banFrame.Parent;
|
||||
parent.RemoveChild(banFrame);
|
||||
CreateBanFrame(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public GUIComponent CreateBanFrame(GUIComponent parent)
|
||||
{
|
||||
banFrame = new GUIListBox(new RectTransform(Vector2.One, parent.RectTransform, Anchor.Center));
|
||||
|
||||
foreach (BannedPlayer bannedPlayer in bannedPlayers)
|
||||
{
|
||||
if (localRemovedBans.Contains(bannedPlayer.UniqueIdentifier)) continue;
|
||||
|
||||
var playerFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.25f), ((GUIListBox)banFrame).Content.RectTransform) { MinSize = new Point(0, 70) }, style: null)
|
||||
{
|
||||
UserData = banFrame
|
||||
@@ -28,8 +58,10 @@ namespace Barotrauma.Networking
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
|
||||
string ip = bannedPlayer.IP;
|
||||
if (localRangeBans.Contains(bannedPlayer.UniqueIdentifier)) ip = ToRange(ip);
|
||||
GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), paddedPlayerFrame.RectTransform),
|
||||
bannedPlayer.IP + " (" + bannedPlayer.Name + ")");
|
||||
bannedPlayer.Name + " (" + ip + ")");
|
||||
|
||||
var removeButton = new GUIButton(new RectTransform(new Vector2(0.2f, 0.4f), paddedPlayerFrame.RectTransform, Anchor.TopRight), TextManager.Get("BanListRemove"))
|
||||
{
|
||||
@@ -71,14 +103,9 @@ namespace Barotrauma.Networking
|
||||
BannedPlayer banned = obj as BannedPlayer;
|
||||
if (banned == null) return false;
|
||||
|
||||
RemoveBan(banned);
|
||||
localRemovedBans.Add(banned.UniqueIdentifier);
|
||||
|
||||
if (banFrame != null)
|
||||
{
|
||||
var parent = banFrame.Parent;
|
||||
parent.RemoveChild(banFrame);
|
||||
CreateBanFrame(parent);
|
||||
}
|
||||
RecreateBanFrame();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -88,14 +115,9 @@ namespace Barotrauma.Networking
|
||||
BannedPlayer banned = obj as BannedPlayer;
|
||||
if (banned == null) return false;
|
||||
|
||||
RangeBan(banned);
|
||||
localRangeBans.Add(banned.UniqueIdentifier);
|
||||
|
||||
if (banFrame != null)
|
||||
{
|
||||
var parent = banFrame.Parent;
|
||||
parent.RemoveChild(banFrame);
|
||||
CreateBanFrame(parent);
|
||||
}
|
||||
RecreateBanFrame();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -106,5 +128,66 @@ namespace Barotrauma.Networking
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ClientAdminRead(NetBuffer incMsg)
|
||||
{
|
||||
bool hasPermission = incMsg.ReadBoolean();
|
||||
if (!hasPermission)
|
||||
{
|
||||
incMsg.ReadPadBits();
|
||||
return;
|
||||
}
|
||||
|
||||
bool isOwner = incMsg.ReadBoolean();
|
||||
incMsg.ReadPadBits();
|
||||
|
||||
bannedPlayers.Clear();
|
||||
Int32 bannedPlayerCount = incMsg.ReadVariableInt32();
|
||||
for (int i = 0; i < bannedPlayerCount; i++)
|
||||
{
|
||||
string name = incMsg.ReadString();
|
||||
UInt16 uniqueIdentifier = incMsg.ReadUInt16();
|
||||
bool isRangeBan = incMsg.ReadBoolean(); incMsg.ReadPadBits();
|
||||
|
||||
string ip = "";
|
||||
UInt64 steamID = 0;
|
||||
if (isOwner)
|
||||
{
|
||||
ip = incMsg.ReadString();
|
||||
steamID = incMsg.ReadUInt64();
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = "IP concealed by host";
|
||||
steamID = 0;
|
||||
}
|
||||
bannedPlayers.Add(new BannedPlayer(name, uniqueIdentifier, isRangeBan, ip, steamID));
|
||||
}
|
||||
|
||||
if (banFrame != null)
|
||||
{
|
||||
var parent = banFrame.Parent;
|
||||
parent.RemoveChild(banFrame);
|
||||
CreateBanFrame(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientAdminWrite(NetBuffer outMsg)
|
||||
{
|
||||
outMsg.Write((UInt16)localRemovedBans.Count);
|
||||
foreach (UInt16 uniqueId in localRemovedBans)
|
||||
{
|
||||
outMsg.Write(uniqueId);
|
||||
}
|
||||
|
||||
outMsg.Write((UInt16)localRangeBans.Count);
|
||||
foreach (UInt16 uniqueId in localRangeBans)
|
||||
{
|
||||
outMsg.Write(uniqueId);
|
||||
}
|
||||
|
||||
localRemovedBans.Clear();
|
||||
localRangeBans.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user