Unstable 1.2.1.0
This commit is contained in:
@@ -122,12 +122,12 @@ namespace Barotrauma.Networking
|
||||
VoipSound = null;
|
||||
}
|
||||
|
||||
public void SetPermissions(ClientPermissions permissions, IEnumerable<string> permittedConsoleCommands)
|
||||
public void SetPermissions(ClientPermissions permissions, IEnumerable<Identifier> permittedConsoleCommands)
|
||||
{
|
||||
List<DebugConsole.Command> permittedCommands = new List<DebugConsole.Command>();
|
||||
foreach (string commandName in permittedConsoleCommands)
|
||||
foreach (Identifier commandName in permittedConsoleCommands)
|
||||
{
|
||||
var consoleCommand = DebugConsole.Commands.Find(c => c.names.Contains(commandName));
|
||||
var consoleCommand = DebugConsole.Commands.Find(c => c.Names.Contains(commandName));
|
||||
if (consoleCommand != null)
|
||||
{
|
||||
permittedCommands.Add(consoleCommand);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma.Networking
|
||||
public bool LateCampaignJoin = false;
|
||||
|
||||
private ClientPermissions permissions = ClientPermissions.None;
|
||||
private List<string> permittedConsoleCommands = new List<string>();
|
||||
private List<Identifier> permittedConsoleCommands = new List<Identifier>();
|
||||
|
||||
private bool connected;
|
||||
|
||||
@@ -170,9 +170,9 @@ namespace Barotrauma.Networking
|
||||
internal readonly struct PermissionChangedEvent
|
||||
{
|
||||
public readonly ClientPermissions NewPermissions;
|
||||
public readonly ImmutableArray<string> NewPermittedConsoleCommands;
|
||||
public readonly ImmutableArray<Identifier> NewPermittedConsoleCommands;
|
||||
|
||||
public PermissionChangedEvent(ClientPermissions newPermissions, IReadOnlyList<string> newPermittedConsoleCommands)
|
||||
public PermissionChangedEvent(ClientPermissions newPermissions, IReadOnlyList<Identifier> newPermittedConsoleCommands)
|
||||
{
|
||||
NewPermissions = newPermissions;
|
||||
NewPermittedConsoleCommands = newPermittedConsoleCommands.ToImmutableArray();
|
||||
@@ -1211,11 +1211,11 @@ namespace Barotrauma.Networking
|
||||
targetClient?.SetPermissions(permissions, permittedCommands);
|
||||
if (clientId == SessionId)
|
||||
{
|
||||
SetMyPermissions(permissions, permittedCommands.Select(command => command.names[0]));
|
||||
SetMyPermissions(permissions, permittedCommands.Select(command => command.Names[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMyPermissions(ClientPermissions newPermissions, IEnumerable<string> permittedConsoleCommands)
|
||||
private void SetMyPermissions(ClientPermissions newPermissions, IEnumerable<Identifier> permittedConsoleCommands)
|
||||
{
|
||||
if (!(this.permittedConsoleCommands.Any(c => !permittedConsoleCommands.Contains(c)) ||
|
||||
permittedConsoleCommands.Any(c => !this.permittedConsoleCommands.Contains(c))))
|
||||
@@ -1227,7 +1227,7 @@ namespace Barotrauma.Networking
|
||||
permissions.HasFlag(ClientPermissions.ManageRound) != newPermissions.HasFlag(ClientPermissions.ManageRound);
|
||||
|
||||
permissions = newPermissions;
|
||||
this.permittedConsoleCommands = new List<string>(permittedConsoleCommands);
|
||||
this.permittedConsoleCommands = permittedConsoleCommands.ToList();
|
||||
//don't show the "permissions changed" popup if the client owns the server
|
||||
if (!IsServerOwner)
|
||||
{
|
||||
@@ -1265,10 +1265,10 @@ namespace Barotrauma.Networking
|
||||
var commandsLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), rightColumn.RectTransform),
|
||||
TextManager.Get("PermittedConsoleCommands"), wrap: true, font: GUIStyle.SubHeadingFont);
|
||||
var commandList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), rightColumn.RectTransform));
|
||||
foreach (string permittedCommand in permittedConsoleCommands)
|
||||
foreach (Identifier permittedCommand in permittedConsoleCommands)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), commandList.Content.RectTransform, minSize: new Point(0, 15)),
|
||||
permittedCommand, font: GUIStyle.SmallFont)
|
||||
permittedCommand.Value, font: GUIStyle.SmallFont)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
@@ -1348,6 +1348,7 @@ namespace Barotrauma.Networking
|
||||
bool respawnAllowed = inc.ReadBoolean();
|
||||
ServerSettings.AllowDisguises = inc.ReadBoolean();
|
||||
ServerSettings.AllowRewiring = inc.ReadBoolean();
|
||||
ServerSettings.AllowImmediateItemDelivery = inc.ReadBoolean();
|
||||
ServerSettings.AllowFriendlyFire = inc.ReadBoolean();
|
||||
ServerSettings.LockAllDefaultWires = inc.ReadBoolean();
|
||||
ServerSettings.AllowLinkingWifiToChat = inc.ReadBoolean();
|
||||
@@ -2551,18 +2552,18 @@ namespace Barotrauma.Networking
|
||||
return permissions.HasFlag(permission);
|
||||
}
|
||||
|
||||
public bool HasConsoleCommandPermission(string commandName)
|
||||
public bool HasConsoleCommandPermission(Identifier commandName)
|
||||
{
|
||||
if (!permissions.HasFlag(ClientPermissions.ConsoleCommands)) { return false; }
|
||||
|
||||
if (permittedConsoleCommands.Any(c => c.Equals(commandName, StringComparison.OrdinalIgnoreCase))) { return true; }
|
||||
if (permittedConsoleCommands.Contains(commandName)) { return true; }
|
||||
|
||||
//check aliases
|
||||
foreach (DebugConsole.Command command in DebugConsole.Commands)
|
||||
{
|
||||
if (command.names.Contains(commandName))
|
||||
if (command.Names.Contains(commandName))
|
||||
{
|
||||
if (command.names.Intersect(permittedConsoleCommands).Any()) { return true; }
|
||||
if (command.Names.Intersect(permittedConsoleCommands).Any()) { return true; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,9 @@ namespace Barotrauma.Networking
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
public LanguageIdentifier Language { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
public string SelectedSub { get; set; } = string.Empty;
|
||||
|
||||
public Version GameVersion { get; set; } = new Version(0, 0, 0, 0);
|
||||
|
||||
public Option<int> Ping = Option<int>.None();
|
||||
@@ -104,6 +107,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
public ImmutableArray<ContentPackageInfo> ContentPackages;
|
||||
|
||||
public int ContentPackageCount;
|
||||
|
||||
public bool IsModded => ContentPackages.Any(p => !GameMain.VanillaContent.NameMatches(p.Name));
|
||||
|
||||
public ServerInfo(Endpoint endpoint)
|
||||
@@ -309,6 +314,14 @@ namespace Barotrauma.Networking
|
||||
TextManager.Get(GameMode.IsEmpty ? "Unknown" : "GameMode." + GameMode).Fallback(GameMode.Value),
|
||||
textAlignment: Alignment.Right);
|
||||
|
||||
if (!string.IsNullOrEmpty(SelectedSub))
|
||||
{
|
||||
var submarineText = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("Submarine"));
|
||||
new GUITextBlock(new RectTransform(Vector2.One, submarineText.RectTransform),
|
||||
SelectedSub,
|
||||
textAlignment: Alignment.Right);
|
||||
}
|
||||
|
||||
GUITextBlock playStyleText = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), content.RectTransform), TextManager.Get("serverplaystyle"));
|
||||
new GUITextBlock(new RectTransform(Vector2.One, playStyleText.RectTransform), TextManager.Get("servertag." + playStyle), textAlignment: Alignment.Right);
|
||||
|
||||
@@ -385,6 +398,15 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ContentPackageCount > ContentPackages.Length)
|
||||
{
|
||||
new GUITextBlock(
|
||||
new RectTransform(new Vector2(1.0f, 0.15f), contentPackageList.Content.RectTransform) { MinSize = new Point(0, 15) },
|
||||
TextManager.GetWithVariable("workshopitemdownloadprompttruncated", "[number]", (ContentPackageCount - ContentPackages.Length).ToString()))
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -423,14 +445,16 @@ namespace Barotrauma.Networking
|
||||
AllowSpectating = getBool("allowspectating");
|
||||
AllowRespawn = getBool("allowrespawn");
|
||||
VoipEnabled = getBool("voicechatenabled");
|
||||
|
||||
GameMode = valueGetter("gamemode")?.ToIdentifier() ?? Identifier.Empty;
|
||||
if (float.TryParse(valueGetter("traitors"), NumberStyles.Any, CultureInfo.InvariantCulture, out float traitorProbability)) { TraitorProbability = traitorProbability; }
|
||||
if (Enum.TryParse(valueGetter("playstyle"), out PlayStyle playStyle)) { PlayStyle = playStyle; }
|
||||
Language = valueGetter("language")?.ToLanguageIdentifier() ?? LanguageIdentifier.None;
|
||||
SelectedSub = valueGetter("submarine") ?? string.Empty;
|
||||
|
||||
ContentPackages = ExtractContentPackageInfo(ServerName, valueGetter).ToImmutableArray();
|
||||
|
||||
ContentPackageCount = ContentPackages.Length;
|
||||
if (int.TryParse(valueGetter("packagecount"), out int packageCount)) { ContentPackageCount = packageCount; }
|
||||
|
||||
bool getBool(string key)
|
||||
{
|
||||
string? data = valueGetter(key);
|
||||
|
||||
@@ -936,6 +936,10 @@ namespace Barotrauma.Networking
|
||||
TextManager.Get("ServerSettingsAllowVoteKick"));
|
||||
GetPropertyData(nameof(AllowVoteKick)).AssignGUIComponent(voteKickBox);
|
||||
|
||||
var allowImmediateItemDeliveryBox = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
|
||||
TextManager.Get("ServerSettingsImmediateItemDelivery"));
|
||||
GetPropertyData(nameof(AllowImmediateItemDelivery)).AssignGUIComponent(allowImmediateItemDeliveryBox);
|
||||
|
||||
GUITextBlock.AutoScaleAndNormalize(tickBoxContainer.Content.Children.Select(c => ((GUITickBox)c).TextBlock));
|
||||
|
||||
tickBoxContainer.RectTransform.MinSize = new Point(0, (int)(tickBoxContainer.Content.Children.First().Rect.Height * 2.0f + tickBoxContainer.Padding.Y + tickBoxContainer.Padding.W));
|
||||
|
||||
Reference in New Issue
Block a user