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
@@ -7,6 +7,7 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using Barotrauma.Steam;
namespace Barotrauma
{
@@ -299,10 +300,16 @@ namespace Barotrauma
Client client = GameMain.Server.ConnectedClients.Find(c => Homoglyphs.Compare(c.Name, arg));
if (int.TryParse(arg, out int id))
{
client ??= GameMain.Server.ConnectedClients.Find(c => c.ID == id);
client ??= GameMain.Server.ConnectedClients.Find(c => c.SessionId == id);
}
if (Endpoint.Parse(arg).TryUnwrap(out var endpoint))
{
client ??= GameMain.Server.ConnectedClients.Find(c => c.EndpointMatches(endpoint));
}
if (AccountId.Parse(arg).TryUnwrap(out var argAccountId))
{
client ??= GameMain.Server.ConnectedClients.Find(c => c.AccountId.ValueEquals(argAccountId));
}
client ??= GameMain.Server.ConnectedClients.Find(c => c.EndpointMatches(arg));
client ??= GameMain.Server.ConnectedClients.Find(c => c.SteamID == Steam.SteamManager.SteamIDStringToUInt64(arg));
return client;
}
@@ -872,7 +879,7 @@ namespace Barotrauma
NewMessage("***************", Color.Cyan);
foreach (Client c in GameMain.Server.ConnectedClients)
{
NewMessage("- " + c.ID.ToString() + ": " + c.Name + (c.Character != null ? " playing " + c.Character.LogName : "") + ", " + c.Karma, Color.Cyan);
NewMessage("- " + c.SessionId.ToString() + ": " + c.Name + (c.Character != null ? " playing " + c.Character.LogName : "") + ", " + c.Karma, Color.Cyan);
}
NewMessage("***************", Color.Cyan);
});
@@ -881,7 +888,7 @@ namespace Barotrauma
GameMain.Server.SendConsoleMessage("***************", client);
foreach (Client c in GameMain.Server.ConnectedClients)
{
GameMain.Server.SendConsoleMessage("- " + c.ID.ToString() + ": " + c.Name + (c.Character != null ? " playing " + c.Character.LogName : "") + ", " + c.Karma, client);
GameMain.Server.SendConsoleMessage("- " + c.SessionId.ToString() + ": " + c.Name + (c.Character != null ? " playing " + c.Character.LogName : "") + ", " + c.Karma, client);
}
GameMain.Server.SendConsoleMessage("***************", client);
});
@@ -904,10 +911,12 @@ namespace Barotrauma
client);
});
AssignOnExecute("banendpoint", (string[] args) =>
AssignOnExecute("banaddress", (string[] args) =>
{
if (GameMain.Server == null || args.Length == 0) return;
if (!(Endpoint.Parse(args[0]).TryUnwrap(out var endpoint))) { return; }
ShowQuestionPrompt("Reason for banning the endpoint \"" + args[0] + "\"? (c to cancel)", (reason) =>
{
if (reason == "c" || reason == "C") { return; }
@@ -925,16 +934,16 @@ namespace Barotrauma
banDuration = parsedBanDuration;
}
var clients = GameMain.Server.ConnectedClients.FindAll(c => c.EndpointMatches(args[0]));
var clients = GameMain.Server.ConnectedClients.Where(c => c.EndpointMatches(endpoint)).ToList();
if (clients.Count == 0)
{
GameMain.Server.ServerSettings.BanList.BanPlayer("Unnamed", args[0], reason, banDuration);
GameMain.Server.ServerSettings.BanList.BanPlayer("Unnamed", endpoint, reason, banDuration);
}
else
{
foreach (Client cl in clients)
{
GameMain.Server.BanClient(cl, reason, false, banDuration);
GameMain.Server.BanClient(cl, reason, banDuration);
}
}
});
@@ -1036,7 +1045,8 @@ namespace Barotrauma
NewMessage("***************", Color.Cyan);
foreach (Client c in GameMain.Server.ConnectedClients)
{
NewMessage("- " + c.ID.ToString() + ": " + c.Name + (c.Character != null ? " playing " + c.Character.LogName : "") + ", " + c.Connection.EndPointString + $", ping {c.Ping} ms", Color.Cyan);
NewMessage(
$"- {c.SessionId}: {c.Name}{(c.Character != null ? " playing " + c.Character.LogName : "")}, {c.Connection.Endpoint.StringRepresentation}, {c.Connection.AccountInfo.AccountId}, ping {c.Ping} ms", Color.Cyan);
}
NewMessage("***************", Color.Cyan);
}));
@@ -1045,7 +1055,7 @@ namespace Barotrauma
GameMain.Server.SendConsoleMessage("***************", client, Color.Cyan);
foreach (Client c in GameMain.Server.ConnectedClients)
{
GameMain.Server.SendConsoleMessage("- " + c.ID.ToString() + ": " + c.Name + ", " + c.Connection.EndPointString + $", ping {c.Ping} ms", client, Color.Cyan);
GameMain.Server.SendConsoleMessage("- " + c.SessionId.ToString() + ": " + c.Name + ", " + c.Connection.Endpoint.StringRepresentation + $", ping {c.Ping} ms", client, Color.Cyan);
}
GameMain.Server.SendConsoleMessage("***************", client, Color.Cyan);
});
@@ -1496,11 +1506,12 @@ namespace Barotrauma
);
AssignOnClientRequestExecute(
"banendpoint|banip",
"banaddress|banip",
(Client client, Vector2 cursorPos, string[] args) =>
{
if (args.Length < 1) return;
var clients = GameMain.Server.ConnectedClients.FindAll(c => c.EndpointMatches(args[0]));
if (args.Length < 1) { return; }
if (!(Endpoint.Parse(args[0]).TryUnwrap(out var endpoint))) { return; }
var clients = GameMain.Server.ConnectedClients.Where(c => c.EndpointMatches(endpoint)).ToList();
TimeSpan? duration = null;
if (args.Length > 1)
{
@@ -1519,13 +1530,13 @@ namespace Barotrauma
if (clients.Count == 0)
{
GameMain.Server.ServerSettings.BanList.BanPlayer("Unnamed", args[0], reason, duration);
GameMain.Server.ServerSettings.BanList.BanPlayer("Unnamed", endpoint, reason, duration);
}
else
{
foreach (Client cl in clients)
{
GameMain.Server.BanClient(cl, reason, false, duration);
GameMain.Server.BanClient(cl, reason, duration);
}
}
}
@@ -1535,7 +1546,7 @@ namespace Barotrauma
{
if (GameMain.Server == null || args.Length == 0) return;
string clientName = string.Join(" ", args);
GameMain.Server.UnbanPlayer(clientName, "");
GameMain.Server.UnbanPlayer(clientName);
},
() =>
{
@@ -1546,17 +1557,20 @@ namespace Barotrauma
};
}));
commands.Add(new Command("unbanip", "unbanip [ip]: Unban a specific IP.", (string[] args) =>
commands.Add(new Command("unbanaddress", "unbanaddress [endpoint]: Unban a specific endpoint.", (string[] args) =>
{
if (GameMain.Server == null || args.Length == 0) return;
GameMain.Server.UnbanPlayer("", args[0]);
if (Endpoint.Parse(args[0]).TryUnwrap(out var endpoint))
{
GameMain.Server.UnbanPlayer(endpoint);
}
},
() =>
{
if (GameMain.Server == null) return null;
return new string[][]
{
GameMain.Server.ServerSettings.BanList.BannedEndPoints.ToArray()
GameMain.Server.ServerSettings.BanList.BannedAddresses.Select(ep => ep.ToString()).ToArray()
};
}));