diff --git a/Content.Client/Changelog/ChangelogWindow.xaml.cs b/Content.Client/Changelog/ChangelogWindow.xaml.cs index a1b2d65eac..8fbfb3fc5c 100644 --- a/Content.Client/Changelog/ChangelogWindow.xaml.cs +++ b/Content.Client/Changelog/ChangelogWindow.xaml.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using Content.Client.Resources; using Content.Client.Stylesheets; +using Content.Shared.Administration; using JetBrains.Annotations; using Robust.Client.AutoGenerated; using Robust.Client.ResourceManagement; @@ -198,7 +199,7 @@ namespace Content.Client.Changelog } } - [UsedImplicitly] + [UsedImplicitly, AnyCommand] public sealed class ChangelogCommand : IConsoleCommand { public string Command => "changelog"; diff --git a/Content.Client/Commands/CreditsCommand.cs b/Content.Client/Commands/CreditsCommand.cs index 417f9c3eb4..f61c80c1d5 100644 --- a/Content.Client/Commands/CreditsCommand.cs +++ b/Content.Client/Commands/CreditsCommand.cs @@ -1,11 +1,12 @@ using Content.Client.Credits; using Content.Client.UserInterface; +using Content.Shared.Administration; using JetBrains.Annotations; using Robust.Shared.Console; namespace Content.Client.Commands { - [UsedImplicitly] + [UsedImplicitly, AnyCommand] public sealed class CreditsCommand : IConsoleCommand { public string Command => "credits"; diff --git a/Content.Client/Commands/ToggleOutlineCommand.cs b/Content.Client/Commands/ToggleOutlineCommand.cs index d8ad084c23..f8cefbf8d2 100644 --- a/Content.Client/Commands/ToggleOutlineCommand.cs +++ b/Content.Client/Commands/ToggleOutlineCommand.cs @@ -1,4 +1,4 @@ -using Content.Shared; +using Content.Shared.Administration; using Content.Shared.CCVar; using Robust.Shared.Configuration; using Robust.Shared.Console; @@ -6,6 +6,7 @@ using Robust.Shared.IoC; namespace Content.Client.Commands { + [AnyCommand] public class ToggleOutlineCommand : IConsoleCommand { public string Command => "toggleoutline"; diff --git a/Content.Client/Voting/UI/VoteCallMenu.xaml.cs b/Content.Client/Voting/UI/VoteCallMenu.xaml.cs index 0abc489a6a..e3a144137e 100644 --- a/Content.Client/Voting/UI/VoteCallMenu.xaml.cs +++ b/Content.Client/Voting/UI/VoteCallMenu.xaml.cs @@ -1,5 +1,6 @@ using System; using Content.Client.Stylesheets; +using Content.Shared.Administration; using Content.Shared.Voting; using JetBrains.Annotations; using Robust.Client.AutoGenerated; @@ -150,7 +151,7 @@ namespace Content.Client.Voting.UI } } - [UsedImplicitly] + [UsedImplicitly, AnyCommand] public sealed class VoteMenuCommand : IConsoleCommand { public string Command => "votemenu"; diff --git a/Content.Server/Administration/Managers/AdminManager.cs b/Content.Server/Administration/Managers/AdminManager.cs index 9b506f09c4..cd88ac315f 100644 --- a/Content.Server/Administration/Managers/AdminManager.cs +++ b/Content.Server/Administration/Managers/AdminManager.cs @@ -193,42 +193,54 @@ namespace Content.Server.Administration.Managers } // Load flags for engine commands, since those don't have the attributes. - if (_res.TryContentFileRead(new ResourcePath("/engineCommandPerms.yml"), out var fs)) + if (_res.TryContentFileRead(new ResourcePath("/engineCommandPerms.yml"), out var efs)) { - using var reader = new StreamReader(fs, EncodingHelpers.UTF8); - var yStream = new YamlStream(); - yStream.Load(reader); - var root = (YamlSequenceNode) yStream.Documents[0].RootNode; + LoadPermissionsFromStream(efs); + } - foreach (var child in root) + // Load flags for client-only commands, those don't have the flag attributes, only "AnyCommand". + if (_res.TryContentFileRead(new ResourcePath("/clientCommandPerms.yml"), out var cfs)) + { + LoadPermissionsFromStream(cfs); + } + } + + private void LoadPermissionsFromStream(Stream fs) + { + using var reader = new StreamReader(fs, EncodingHelpers.UTF8); + var yStream = new YamlStream(); + yStream.Load(reader); + var root = (YamlSequenceNode) yStream.Documents[0].RootNode; + + foreach (var child in root) + { + var map = (YamlMappingNode) child; + var commands = map.GetNode("Commands").Select(p => p.AsString()); + if (map.TryGetNode("Flags", out var flagsNode)) { - var map = (YamlMappingNode) child; - var commands = map.GetNode("Commands").Select(p => p.AsString()); - if (map.TryGetNode("Flags", out var flagsNode)) + var flagNames = flagsNode.AsString().Split(",", StringSplitOptions.RemoveEmptyEntries); + var flags = AdminFlagsHelper.NamesToFlags(flagNames); + foreach (var cmd in commands) { - var flagNames = flagsNode.AsString().Split(",", StringSplitOptions.RemoveEmptyEntries); - var flags = AdminFlagsHelper.NamesToFlags(flagNames); - foreach (var cmd in commands) + if (!_adminCommands.TryGetValue(cmd, out var exFlags)) { - if (!_adminCommands.TryGetValue(cmd, out var exFlags)) - { - _adminCommands.Add(cmd, new[] {flags}); - } - else - { - var newArr = new AdminFlags[exFlags.Length + 1]; - exFlags.CopyTo(newArr, 0); - exFlags[^1] = flags; - _adminCommands[cmd] = newArr; - } + _adminCommands.Add(cmd, new[] {flags}); + } + else + { + var newArr = new AdminFlags[exFlags.Length + 1]; + exFlags.CopyTo(newArr, 0); + exFlags[^1] = flags; + _adminCommands[cmd] = newArr; } } - else - { - _anyCommands.UnionWith(commands); - } + } + else + { + _anyCommands.UnionWith(commands); } } + } public void PromoteHost(IPlayerSession player) diff --git a/Resources/clientCommandPerms.yml b/Resources/clientCommandPerms.yml new file mode 100644 index 0000000000..a4ada3c8a2 --- /dev/null +++ b/Resources/clientCommandPerms.yml @@ -0,0 +1,30 @@ +- Flags: DEBUG + Commands: + - atvrange + - atvmode + - atvcbm + - debugai + - notify + - pathfinder + - entitymenug + - hidemechanisms + - showmechanisms + - menuvis + - togglehealthoverlay + - toggledecals + - nodevis + - nodevisfilter + +- Flags: MAPPING + Commands: + - showmarkers + - showsubfloor + - showsubfloorforever + - mapping + - toggledecals + - nodevis + - nodevisfilter + +- Flags: ADMIN + Commands: + - togglehealthoverlay diff --git a/Tools/package_client_build.py b/Tools/package_client_build.py index de30b2273a..526713dfd5 100755 --- a/Tools/package_client_build.py +++ b/Tools/package_client_build.py @@ -38,7 +38,9 @@ SHARED_IGNORED_RESOURCES = { CLIENT_IGNORED_RESOURCES = { "Maps", "emotes.xml", - "Groups" + "Groups", + "engineCommandPerms.yml", + "clientCommandPerms.yml" } CLIENT_CONTENT_ASSEMBLIES = [