Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into unstable
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Barotrauma.Steam;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -300,10 +301,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 (Address.Parse(arg).TryUnwrap(out var address))
|
||||
{
|
||||
client ??= GameMain.Server.ConnectedClients.Find(c => c.AddressMatches(address));
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -873,7 +880,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);
|
||||
});
|
||||
@@ -882,7 +889,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);
|
||||
});
|
||||
@@ -905,10 +912,12 @@ namespace Barotrauma
|
||||
client);
|
||||
});
|
||||
|
||||
AssignOnExecute("banendpoint", (string[] args) =>
|
||||
AssignOnExecute("banaddress", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null || args.Length == 0) return;
|
||||
|
||||
if (!(Address.Parse(args[0]).TryUnwrap(out var address))) { return; }
|
||||
|
||||
ShowQuestionPrompt("Reason for banning the endpoint \"" + args[0] + "\"? (c to cancel)", (reason) =>
|
||||
{
|
||||
if (reason == "c" || reason == "C") { return; }
|
||||
@@ -926,16 +935,16 @@ namespace Barotrauma
|
||||
banDuration = parsedBanDuration;
|
||||
}
|
||||
|
||||
var clients = GameMain.Server.ConnectedClients.FindAll(c => c.EndpointMatches(args[0]));
|
||||
var clients = GameMain.Server.ConnectedClients.Where(c => c.AddressMatches(address)).ToList();
|
||||
if (clients.Count == 0)
|
||||
{
|
||||
GameMain.Server.ServerSettings.BanList.BanPlayer("Unnamed", args[0], reason, banDuration);
|
||||
GameMain.Server.ServerSettings.BanList.BanPlayer("Unnamed", address, reason, banDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Client cl in clients)
|
||||
{
|
||||
GameMain.Server.BanClient(cl, reason, false, banDuration);
|
||||
GameMain.Server.BanClient(cl, reason, banDuration);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1037,7 +1046,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);
|
||||
}));
|
||||
@@ -1046,7 +1056,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);
|
||||
});
|
||||
@@ -1530,11 +1540,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 (!(Address.Parse(args[0]).TryUnwrap(out var address))) { return; }
|
||||
var clients = GameMain.Server.ConnectedClients.Where(c => c.AddressMatches(address)).ToList();
|
||||
TimeSpan? duration = null;
|
||||
if (args.Length > 1)
|
||||
{
|
||||
@@ -1553,13 +1564,13 @@ namespace Barotrauma
|
||||
|
||||
if (clients.Count == 0)
|
||||
{
|
||||
GameMain.Server.ServerSettings.BanList.BanPlayer("Unnamed", args[0], reason, duration);
|
||||
GameMain.Server.ServerSettings.BanList.BanPlayer("Unnamed", address, reason, duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Client cl in clients)
|
||||
{
|
||||
GameMain.Server.BanClient(cl, reason, false, duration);
|
||||
GameMain.Server.BanClient(cl, reason, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1569,7 +1580,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Server == null || args.Length == 0) return;
|
||||
string clientName = string.Join(" ", args);
|
||||
GameMain.Server.UnbanPlayer(clientName, "");
|
||||
GameMain.Server.UnbanPlayer(clientName);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
@@ -1580,17 +1591,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()
|
||||
};
|
||||
}));
|
||||
|
||||
@@ -1886,20 +1900,17 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
foreach (var talentTree in talentTrees)
|
||||
{
|
||||
foreach (var subTree in talentTree.TalentSubTrees)
|
||||
{
|
||||
foreach (var talentId in talentTree.AllTalentIdentifiers)
|
||||
{
|
||||
foreach (var option in subTree.TalentOptionStages)
|
||||
if (TalentPrefab.TalentPrefabs.TryGet(talentId, out TalentPrefab talentPrefab))
|
||||
{
|
||||
foreach (var talent in option.Talents)
|
||||
{
|
||||
targetCharacter.GiveTalent(talent);
|
||||
NewMessage($"Talent \"{talent.DisplayName}\" given to \"{targetCharacter.Name}\" by \"{client.Name}\".");
|
||||
GameMain.Server.SendConsoleMessage($"Gave talent \"{talent.DisplayName}\" to \"{targetCharacter.Name}\".", client);
|
||||
NewMessage($"Unlocked talent \"{talent.DisplayName}\".");
|
||||
}
|
||||
targetCharacter.GiveTalent(talentPrefab);
|
||||
NewMessage($"Talent \"{talentPrefab.DisplayName}\" given to \"{targetCharacter.Name}\" by \"{client.Name}\".");
|
||||
GameMain.Server.SendConsoleMessage($"Gave talent \"{talentPrefab.DisplayName}\" to \"{targetCharacter.Name}\".", client);
|
||||
NewMessage($"Unlocked talent \"{talentPrefab.DisplayName}\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user