Unstable v0.19.1.0

This commit is contained in:
Juan Pablo Arce
2022-08-19 13:59:08 -03:00
parent 6b55adcdd9
commit 1219615d64
192 changed files with 3875 additions and 2648 deletions
@@ -1,28 +1,28 @@
using Barotrauma.Steam;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma.Networking
{
partial class BannedPlayer
{
public BannedPlayer(string name, UInt16 uniqueIdentifier, bool isRangeBan, string endPoint, ulong steamID, string reason, DateTime? expiration)
public BannedPlayer(
UInt32 uniqueIdentifier,
string name,
Either<Address, AccountId> addressOrAccountId,
string reason,
DateTime? expiration)
{
this.Name = name;
this.EndPoint = endPoint;
this.SteamID = steamID;
ParseEndPointAsSteamId();
this.IsRangeBan = isRangeBan;
this.AddressOrAccountId = addressOrAccountId;
this.UniqueIdentifier = uniqueIdentifier;
this.Reason = reason;
this.ExpirationTime = expiration;
}
}
public partial class BanList
partial class BanList
{
private GUIComponent banFrame;
@@ -31,8 +31,7 @@ namespace Barotrauma.Networking
get { return banFrame; }
}
public List<UInt16> localRemovedBans = new List<UInt16>();
public List<UInt16> localRangeBans = new List<UInt16>();
public List<UInt32> localRemovedBans = new List<UInt32>();
private void RecreateBanFrame()
{
@@ -71,28 +70,22 @@ namespace Barotrauma.Networking
RelativeSpacing = 0.02f
};
string endPoint = bannedPlayer.EndPoint;
if (localRangeBans.Contains(bannedPlayer.UniqueIdentifier)) endPoint = ToRange(endPoint);
GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), topArea.RectTransform),
bannedPlayer.Name + " (" + endPoint + ")");
textBlock.RectTransform.MinSize = new Point(textBlock.Rect.Width, 0);
var addressOrAccountId = bannedPlayer.AddressOrAccountId;
GUITextBlock textBlock = new GUITextBlock(
new RectTransform(new Vector2(0.5f, 1.0f), topArea.RectTransform),
bannedPlayer.Name + " (" + addressOrAccountId + ")") { CanBeFocused = true };
textBlock.RectTransform.MinSize = new Point(
(int)textBlock.Font.MeasureString(textBlock.Text.SanitizedValue).X, 0);
if (bannedPlayer.EndPoint.IndexOf(".x") <= -1)
{
var rangeBanButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.4f), topArea.RectTransform),
TextManager.Get("BanRange"), style: "GUIButtonSmall")
{
UserData = bannedPlayer,
OnClicked = RangeBan
};
}
var removeButton = new GUIButton(new RectTransform(new Vector2(0.2f, 0.4f), topArea.RectTransform),
TextManager.Get("BanListRemove"), style: "GUIButtonSmall")
{
UserData = bannedPlayer,
OnClicked = RemoveBan
};
topArea.RectTransform.MinSize = new Point(0, (int)topArea.RectTransform.Children.Max(c => c.Rect.Height * 1.25f));
topArea.RectTransform.MinSize = new Point(0, (int)(removeButton.Rect.Height * 1.25f));
topArea.ForceLayoutRecalculation();
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedPlayerFrame.RectTransform),
bannedPlayer.ExpirationTime == null ?
@@ -127,19 +120,6 @@ namespace Barotrauma.Networking
return true;
}
private bool RangeBan(GUIButton button, object obj)
{
BannedPlayer banned = obj as BannedPlayer;
if (banned == null) { return false; }
localRangeBans.Add(banned.UniqueIdentifier);
RecreateBanFrame();
GameMain.Client?.ServerSettings?.ClientAdminWrite(ServerSettings.NetFlags.Properties);
return true;
}
public void ClientAdminRead(IReadMessage incMsg)
{
@@ -159,8 +139,7 @@ namespace Barotrauma.Networking
for (int i = 0; i < (int)bannedPlayerCount; i++)
{
string name = incMsg.ReadString();
UInt16 uniqueIdentifier = incMsg.ReadUInt16();
bool isRangeBan = incMsg.ReadBoolean();
UInt32 uniqueIdentifier = incMsg.ReadUInt32();
bool includesExpiration = incMsg.ReadBoolean();
incMsg.ReadPadBits();
@@ -173,19 +152,30 @@ namespace Barotrauma.Networking
string reason = incMsg.ReadString();
string endPoint = "";
UInt64 steamID = 0;
Either<Address, AccountId> addressOrAccountId;
if (isOwner)
{
endPoint = incMsg.ReadString();
steamID = incMsg.ReadUInt64();
bool isAddress = incMsg.ReadBoolean();
incMsg.ReadPadBits();
string str = incMsg.ReadString();
if (isAddress && Address.Parse(str).TryUnwrap(out var address))
{
addressOrAccountId = address;
}
else if (AccountId.Parse(str).TryUnwrap(out var accountId))
{
addressOrAccountId = accountId;
}
else
{
continue;
}
}
else
{
endPoint = "Endpoint concealed by host";
steamID = 0;
addressOrAccountId = new UnknownAddress();
}
bannedPlayers.Add(new BannedPlayer(name, uniqueIdentifier, isRangeBan, endPoint, steamID, reason, expiration));
bannedPlayers.Add(new BannedPlayer(uniqueIdentifier, name, addressOrAccountId, reason, expiration));
}
if (banFrame != null)
@@ -198,20 +188,13 @@ namespace Barotrauma.Networking
public void ClientAdminWrite(IWriteMessage 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.WriteVariableUInt32((UInt32)localRemovedBans.Count);
foreach (UInt32 uniqueId in localRemovedBans)
{
outMsg.Write(uniqueId);
}
localRemovedBans.Clear();
localRangeBans.Clear();
}
}
}