From 06e2bba8abb1ffceef3f0f204cf976825465967e Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:45:48 +1100 Subject: [PATCH] Toolshed refactor (#33598) * Content changes for engine toolshed PR * add contains command * more permissive commands --- .../Tests/Toolshed/AdminTest.cs | 20 ++- .../Tests/Toolshed/LocTest.cs | 23 ++- .../Tests/Toolshed/ToolshedTest.cs | 27 +++- Content.Server/Access/AddAccessLogCommand.cs | 17 +-- .../Administration/Toolshed/MarkedCommand.cs | 2 +- .../Toolshed/RejuvenateCommand.cs | 2 +- .../Toolshed/SolutionCommand.cs | 34 ++--- .../Administration/Toolshed/TagCommand.cs | 64 ++------ .../V2/Commands/DeleteChatMessageCommand.cs | 2 +- .../V2/Commands/NukeChatMessagesCommand.cs | 2 +- Content.Server/Mind/Toolshed/MindCommand.cs | 11 +- .../Polymorph/Toolshed/PolymorphCommand.cs | 4 +- .../Station/Commands/JobsCommand.cs | 50 ++----- .../Station/Commands/StationCommand.cs | 33 +---- .../BasicStationEventSchedulerSystem.cs | 8 +- .../Commands/AdminDebug/ACmdCommand.cs | 8 +- .../Commands/Verbs/RunVerbAsCommand.cs | 19 +-- .../Toolshed/Commands/VisualizeCommand.cs | 2 +- Resources/toolshedEngineCommandPerms.yml | 138 +++++++++--------- 19 files changed, 204 insertions(+), 262 deletions(-) diff --git a/Content.IntegrationTests/Tests/Toolshed/AdminTest.cs b/Content.IntegrationTests/Tests/Toolshed/AdminTest.cs index 040b09beec..ecb11fc1ba 100644 --- a/Content.IntegrationTests/Tests/Toolshed/AdminTest.cs +++ b/Content.IntegrationTests/Tests/Toolshed/AdminTest.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; -using System.Linq; +using System.Reflection; +using Content.Server.Administration.Managers; using Robust.Shared.Toolshed; namespace Content.IntegrationTests.Tests.Toolshed; @@ -10,10 +11,23 @@ public sealed class AdminTest : ToolshedTest [Test] public async Task AllCommandsHavePermissions() { + var toolMan = Server.ResolveDependency(); + var admin = Server.ResolveDependency(); + var ignored = new HashSet() + {typeof(LocTest).Assembly, typeof(Robust.UnitTesting.Shared.Toolshed.LocTest).Assembly}; + await Server.WaitAssertion(() => { - Assert.That(InvokeCommand("cmd:list where { acmd:perms isnull }", out var res)); - Assert.That((IEnumerable) res, Is.Empty, "All commands must have admin permissions set up."); + Assert.Multiple(() => + { + foreach (var cmd in toolMan.DefaultEnvironment.AllCommands()) + { + if (ignored.Contains(cmd.Cmd.GetType().Assembly)) + continue; + + Assert.That(admin.TryGetCommandFlags(cmd, out _), $"Command does not have admin permissions set up: {cmd.FullName()}"); + } + }); }); } } diff --git a/Content.IntegrationTests/Tests/Toolshed/LocTest.cs b/Content.IntegrationTests/Tests/Toolshed/LocTest.cs index 2b5553ad7d..fb210eba50 100644 --- a/Content.IntegrationTests/Tests/Toolshed/LocTest.cs +++ b/Content.IntegrationTests/Tests/Toolshed/LocTest.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Globalization; -using Robust.Shared.IoC; +using System.Reflection; using Robust.Shared.Localization; using Robust.Shared.Toolshed; @@ -14,10 +14,27 @@ public sealed class LocTest : ToolshedTest [Test] public async Task AllCommandsHaveDescriptions() { + var locMan = Server.ResolveDependency(); + var toolMan = Server.ResolveDependency(); + var locStrings = new HashSet(); + + var ignored = new HashSet() + {typeof(LocTest).Assembly, typeof(Robust.UnitTesting.Shared.Toolshed.LocTest).Assembly}; + await Server.WaitAssertion(() => { - Assert.That(InvokeCommand("cmd:list where { cmd:descloc loc:tryloc isnull }", out var res)); - Assert.That((IEnumerable)res!, Is.Empty, "All commands must have localized descriptions."); + Assert.Multiple(() => + { + foreach (var cmd in toolMan.DefaultEnvironment.AllCommands()) + { + if (ignored.Contains(cmd.Cmd.GetType().Assembly)) + continue; + + var descLoc = cmd.DescLocStr(); + Assert.That(locStrings.Add(descLoc), $"Duplicate command description key: {descLoc}"); + Assert.That(locMan.TryGetString(descLoc, out _), $"Failed to get command description for command {cmd.FullName()}"); + } + }); }); } } diff --git a/Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs b/Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs index 7de81fb3dc..6fc27e168c 100644 --- a/Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs +++ b/Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs @@ -74,15 +74,15 @@ public abstract class ToolshedTest : IInvocationContext return (T) res!; } - protected void ParseCommand(string command, Type? inputType = null, Type? expectedType = null, bool once = false) + protected void ParseCommand(string command, Type? inputType = null, Type? expectedType = null) { var parser = new ParserContext(command, Toolshed); - var success = CommandRun.TryParse(false, parser, inputType, expectedType, once, out _, out _, out var error); + var success = CommandRun.TryParse(parser, inputType, expectedType, out _); - if (error is not null) - ReportError(error); + if (parser.Error is not null) + ReportError(parser.Error); - if (error is null) + if (parser.Error is null) Assert.That(success, $"Parse failed despite no error being reported. Parsed {command}"); } @@ -153,11 +153,28 @@ public abstract class ToolshedTest : IInvocationContext return _errors; } + public bool HasErrors => _errors.Count > 0; + public void ClearErrors() { _errors.Clear(); } + public object? ReadVar(string name) + { + return Variables.GetValueOrDefault(name); + } + + public void WriteVar(string name, object? value) + { + Variables[name] = value; + } + + public IEnumerable GetVars() + { + return Variables.Keys; + } + public Dictionary Variables { get; } = new(); protected void ExpectError(Type err) diff --git a/Content.Server/Access/AddAccessLogCommand.cs b/Content.Server/Access/AddAccessLogCommand.cs index 8b3aebb16b..f55a9b8f1e 100644 --- a/Content.Server/Access/AddAccessLogCommand.cs +++ b/Content.Server/Access/AddAccessLogCommand.cs @@ -10,11 +10,7 @@ namespace Content.Server.Access; public sealed class AddAccessLogCommand : ToolshedCommand { [CommandImplementation] - public void AddAccessLog( - [CommandInvocationContext] IInvocationContext ctx, - [CommandArgument] EntityUid input, - [CommandArgument] float seconds, - [CommandArgument] ValueRef accessor) + public void AddAccessLog(IInvocationContext ctx, EntityUid input, float seconds, string accessor) { var accessReader = EnsureComp(input); @@ -23,19 +19,14 @@ public sealed class AddAccessLogCommand : ToolshedCommand ctx.WriteLine($"WARNING: Surpassing the limit of the log by {accessLogCount - accessReader.AccessLogLimit+1} entries!"); var accessTime = TimeSpan.FromSeconds(seconds); - var accessName = accessor.Evaluate(ctx)!; - accessReader.AccessLog.Enqueue(new AccessRecord(accessTime, accessName)); + accessReader.AccessLog.Enqueue(new AccessRecord(accessTime, accessor)); ctx.WriteLine($"Successfully added access log to {input} with this information inside:\n " + $"Time of access: {accessTime}\n " + - $"Accessed by: {accessName}"); + $"Accessed by: {accessor}"); } [CommandImplementation] - public void AddAccessLogPiped( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] float seconds, - [CommandArgument] ValueRef accessor) + public void AddAccessLogPiped(IInvocationContext ctx, [PipedArgument] EntityUid input, float seconds, string accessor) { AddAccessLog(ctx, input, seconds, accessor); } diff --git a/Content.Server/Administration/Toolshed/MarkedCommand.cs b/Content.Server/Administration/Toolshed/MarkedCommand.cs index b9e39cb82d..54d45a352d 100644 --- a/Content.Server/Administration/Toolshed/MarkedCommand.cs +++ b/Content.Server/Administration/Toolshed/MarkedCommand.cs @@ -7,7 +7,7 @@ namespace Content.Server.Administration.Toolshed; public sealed class MarkedCommand : ToolshedCommand { [CommandImplementation] - public IEnumerable Marked([CommandInvocationContext] IInvocationContext ctx) + public IEnumerable Marked(IInvocationContext ctx) { var res = (IEnumerable?)ctx.ReadVar("marked"); res ??= Array.Empty(); diff --git a/Content.Server/Administration/Toolshed/RejuvenateCommand.cs b/Content.Server/Administration/Toolshed/RejuvenateCommand.cs index 61b0d6213a..3925badc58 100644 --- a/Content.Server/Administration/Toolshed/RejuvenateCommand.cs +++ b/Content.Server/Administration/Toolshed/RejuvenateCommand.cs @@ -23,7 +23,7 @@ public sealed class RejuvenateCommand : ToolshedCommand } [CommandImplementation] - public void Rejuvenate([CommandInvocationContext] IInvocationContext ctx) + public void Rejuvenate(IInvocationContext ctx) { _rejuvenate ??= GetSys(); if (ExecutingEntity(ctx) is not { } ent) diff --git a/Content.Server/Administration/Toolshed/SolutionCommand.cs b/Content.Server/Administration/Toolshed/SolutionCommand.cs index f8c9bdd5c7..c529bcd16d 100644 --- a/Content.Server/Administration/Toolshed/SolutionCommand.cs +++ b/Content.Server/Administration/Toolshed/SolutionCommand.cs @@ -8,6 +8,7 @@ using Robust.Shared.Toolshed; using Robust.Shared.Toolshed.Syntax; using Robust.Shared.Toolshed.TypeParsers; using System.Linq; +using Robust.Shared.Prototypes; namespace Content.Server.Administration.Toolshed; @@ -17,48 +18,38 @@ public sealed class SolutionCommand : ToolshedCommand private SharedSolutionContainerSystem? _solutionContainer; [CommandImplementation("get")] - public SolutionRef? Get( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] ValueRef name - ) + public SolutionRef? Get([PipedArgument] EntityUid input, string name) { _solutionContainer ??= GetSys(); - if (_solutionContainer.TryGetSolution(input, name.Evaluate(ctx)!, out var solution)) + if (_solutionContainer.TryGetSolution(input, name, out var solution)) return new SolutionRef(solution.Value); return null; } [CommandImplementation("get")] - public IEnumerable Get( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable input, - [CommandArgument] ValueRef name - ) + public IEnumerable Get([PipedArgument] IEnumerable input, string name) { - return input.Select(x => Get(ctx, x, name)).Where(x => x is not null).Cast(); + return input.Select(x => Get(x, name)).Where(x => x is not null).Cast(); } [CommandImplementation("adjreagent")] public SolutionRef AdjReagent( - [CommandInvocationContext] IInvocationContext ctx, [PipedArgument] SolutionRef input, - [CommandArgument] Prototype name, - [CommandArgument] ValueRef amountRef + ProtoId proto, + FixedPoint2 amount ) { _solutionContainer ??= GetSys(); - var amount = amountRef.Evaluate(ctx); if (amount > 0) { - _solutionContainer.TryAddReagent(input.Solution, name.Value.ID, amount, out _); + _solutionContainer.TryAddReagent(input.Solution, proto, amount, out _); } else if (amount < 0) { - _solutionContainer.RemoveReagent(input.Solution, name.Value.ID, -amount); + _solutionContainer.RemoveReagent(input.Solution, proto, -amount); } return input; @@ -66,12 +57,11 @@ public sealed class SolutionCommand : ToolshedCommand [CommandImplementation("adjreagent")] public IEnumerable AdjReagent( - [CommandInvocationContext] IInvocationContext ctx, [PipedArgument] IEnumerable input, - [CommandArgument] Prototype name, - [CommandArgument] ValueRef amountRef + ProtoId name, + FixedPoint2 amount ) - => input.Select(x => AdjReagent(ctx, x, name, amountRef)); + => input.Select(x => AdjReagent(x, name, amount)); } public readonly record struct SolutionRef(Entity Solution) diff --git a/Content.Server/Administration/Toolshed/TagCommand.cs b/Content.Server/Administration/Toolshed/TagCommand.cs index 4c6f790e49..a751b85914 100644 --- a/Content.Server/Administration/Toolshed/TagCommand.cs +++ b/Content.Server/Administration/Toolshed/TagCommand.cs @@ -36,82 +36,50 @@ public sealed class TagCommand : ToolshedCommand } [CommandImplementation("add")] - public EntityUid Add( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] ValueRef> @ref - ) + public EntityUid Add([PipedArgument] EntityUid input, ProtoId tag) { _tag ??= GetSys(); - _tag.AddTag(input, @ref.Evaluate(ctx)!); + _tag.AddTag(input, tag); return input; } [CommandImplementation("add")] - public IEnumerable Add( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable input, - [CommandArgument] ValueRef> @ref - ) - => input.Select(x => Add(ctx, x, @ref)); + public IEnumerable Add([PipedArgument] IEnumerable input, ProtoId tag) + => input.Select(x => Add(x, tag)); [CommandImplementation("rm")] - public EntityUid Rm( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] ValueRef> @ref - ) + public EntityUid Rm([PipedArgument] EntityUid input, ProtoId tag) { _tag ??= GetSys(); - _tag.RemoveTag(input, @ref.Evaluate(ctx)!); + _tag.RemoveTag(input, tag); return input; } [CommandImplementation("rm")] - public IEnumerable Rm( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable input, - [CommandArgument] ValueRef> @ref - ) - => input.Select(x => Rm(ctx, x, @ref)); + public IEnumerable Rm([PipedArgument] IEnumerable input, ProtoId tag) + => input.Select(x => Rm(x, tag)); [CommandImplementation("addmany")] - public EntityUid AddMany( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] ValueRef, IEnumerable> @ref - ) + public EntityUid AddMany([PipedArgument] EntityUid input, IEnumerable> tags) { _tag ??= GetSys(); - _tag.AddTags(input, (IEnumerable>)@ref.Evaluate(ctx)!); + _tag.AddTags(input, tags); return input; } [CommandImplementation("addmany")] - public IEnumerable AddMany( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable input, - [CommandArgument] ValueRef, IEnumerable> @ref - ) - => input.Select(x => AddMany(ctx, x, @ref)); + public IEnumerable AddMany([PipedArgument] IEnumerable input, IEnumerable> tags) + => input.Select(x => AddMany(x, tags.ToArray())); [CommandImplementation("rmmany")] - public EntityUid RmMany( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] ValueRef, IEnumerable> @ref - ) + public EntityUid RmMany([PipedArgument] EntityUid input, IEnumerable> tags) { _tag ??= GetSys(); - _tag.RemoveTags(input, (IEnumerable>)@ref.Evaluate(ctx)!); + _tag.RemoveTags(input, tags); return input; } [CommandImplementation("rmmany")] - public IEnumerable RmMany( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable input, - [CommandArgument] ValueRef, IEnumerable> @ref - ) - => input.Select(x => RmMany(ctx, x, @ref)); + public IEnumerable RmMany([PipedArgument] IEnumerable input, IEnumerable> tags) + => input.Select(x => RmMany(x, tags.ToArray())); } diff --git a/Content.Server/Chat/V2/Commands/DeleteChatMessageCommand.cs b/Content.Server/Chat/V2/Commands/DeleteChatMessageCommand.cs index 1f9203d299..2aeb899829 100644 --- a/Content.Server/Chat/V2/Commands/DeleteChatMessageCommand.cs +++ b/Content.Server/Chat/V2/Commands/DeleteChatMessageCommand.cs @@ -14,7 +14,7 @@ public sealed class DeleteChatMessageCommand : ToolshedCommand [Dependency] private readonly IEntitySystemManager _manager = default!; [CommandImplementation("id")] - public void DeleteChatMessage([CommandInvocationContext] IInvocationContext ctx, [CommandArgument] uint messageId) + public void DeleteChatMessage(IInvocationContext ctx, uint messageId) { if (!_manager.GetEntitySystem().Delete(messageId)) { diff --git a/Content.Server/Chat/V2/Commands/NukeChatMessagesCommand.cs b/Content.Server/Chat/V2/Commands/NukeChatMessagesCommand.cs index 3d8b69dd76..07b4cd9796 100644 --- a/Content.Server/Chat/V2/Commands/NukeChatMessagesCommand.cs +++ b/Content.Server/Chat/V2/Commands/NukeChatMessagesCommand.cs @@ -14,7 +14,7 @@ public sealed class NukeChatMessagesCommand : ToolshedCommand [Dependency] private readonly IEntitySystemManager _manager = default!; [CommandImplementation("usernames")] - public void Command([CommandInvocationContext] IInvocationContext ctx, [CommandArgument] string usernamesCsv) + public void Command(IInvocationContext ctx, string usernamesCsv) { var usernames = usernamesCsv.Split(','); diff --git a/Content.Server/Mind/Toolshed/MindCommand.cs b/Content.Server/Mind/Toolshed/MindCommand.cs index 917e6fb7f1..5f82029dc0 100644 --- a/Content.Server/Mind/Toolshed/MindCommand.cs +++ b/Content.Server/Mind/Toolshed/MindCommand.cs @@ -29,19 +29,10 @@ public sealed class MindCommand : ToolshedCommand } [CommandImplementation("control")] - public EntityUid Control( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid target, - [CommandArgument] ValueRef playerRef) + public EntityUid Control(IInvocationContext ctx, [PipedArgument] EntityUid target, ICommonSession player) { _mind ??= GetSys(); - var player = playerRef.Evaluate(ctx); - if (player is null) - { - ctx.ReportError(new NotForServerConsoleError()); - return target; - } if (!_mind.TryGetMind(player, out var mindId, out var mind)) { diff --git a/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs b/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs index 5654c84722..db1e1faad6 100644 --- a/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs +++ b/Content.Server/Polymorph/Toolshed/PolymorphCommand.cs @@ -20,7 +20,7 @@ public sealed class PolymorphCommand : ToolshedCommand [CommandImplementation] public EntityUid? Polymorph( [PipedArgument] EntityUid input, - [CommandArgument] ProtoId protoId + ProtoId protoId ) { _system ??= GetSys(); @@ -34,7 +34,7 @@ public sealed class PolymorphCommand : ToolshedCommand [CommandImplementation] public IEnumerable Polymorph( [PipedArgument] IEnumerable input, - [CommandArgument] ProtoId protoId + ProtoId protoId ) => input.Select(x => Polymorph(x, protoId)).Where(x => x is not null).Select(x => (EntityUid)x!); } diff --git a/Content.Server/Station/Commands/JobsCommand.cs b/Content.Server/Station/Commands/JobsCommand.cs index 1d023c4a84..599a87aac6 100644 --- a/Content.Server/Station/Commands/JobsCommand.cs +++ b/Content.Server/Station/Commands/JobsCommand.cs @@ -30,7 +30,7 @@ public sealed class JobsCommand : ToolshedCommand => stations.SelectMany(Jobs); [CommandImplementation("job")] - public JobSlotRef Job([PipedArgument] EntityUid station, [CommandArgument] Prototype job) + public JobSlotRef Job([PipedArgument] EntityUid station, Prototype job) { _jobs ??= GetSys(); @@ -38,7 +38,7 @@ public sealed class JobsCommand : ToolshedCommand } [CommandImplementation("job")] - public IEnumerable Job([PipedArgument] IEnumerable stations, [CommandArgument] Prototype job) + public IEnumerable Job([PipedArgument] IEnumerable stations, Prototype job) => stations.Select(x => Job(x, job)); [CommandImplementation("isinfinite")] @@ -50,63 +50,41 @@ public sealed class JobsCommand : ToolshedCommand => jobs.Select(x => IsInfinite(x, inverted)); [CommandImplementation("adjust")] - public JobSlotRef Adjust( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] JobSlotRef @ref, - [CommandArgument] ValueRef by - ) + public JobSlotRef Adjust([PipedArgument] JobSlotRef @ref, int by) { _jobs ??= GetSys(); - _jobs.TryAdjustJobSlot(@ref.Station, @ref.Job, by.Evaluate(ctx), true, true); + _jobs.TryAdjustJobSlot(@ref.Station, @ref.Job, by, true, true); return @ref; } [CommandImplementation("adjust")] - public IEnumerable Adjust( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable @ref, - [CommandArgument] ValueRef by - ) - => @ref.Select(x => Adjust(ctx, x, by)); + public IEnumerable Adjust([PipedArgument] IEnumerable @ref, int by) + => @ref.Select(x => Adjust(x, by)); [CommandImplementation("set")] - public JobSlotRef Set( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] JobSlotRef @ref, - [CommandArgument] ValueRef by - ) + public JobSlotRef Set([PipedArgument] JobSlotRef @ref, int by) { _jobs ??= GetSys(); - _jobs.TrySetJobSlot(@ref.Station, @ref.Job, by.Evaluate(ctx), true); + _jobs.TrySetJobSlot(@ref.Station, @ref.Job, by, true); return @ref; } [CommandImplementation("set")] - public IEnumerable Set( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable @ref, - [CommandArgument] ValueRef by - ) - => @ref.Select(x => Set(ctx, x, by)); + public IEnumerable Set([PipedArgument] IEnumerable @ref, int by) + => @ref.Select(x => Set(x, by)); [CommandImplementation("amount")] - public int Amount( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] JobSlotRef @ref - ) + public int Amount([PipedArgument] JobSlotRef @ref) { _jobs ??= GetSys(); _jobs.TryGetJobSlot(@ref.Station, @ref.Job, out var slots); - return (int)(slots ?? 0); + return slots ?? 0; } [CommandImplementation("amount")] - public IEnumerable Amount( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable @ref - ) - => @ref.Select(x => Amount(ctx, x)); + public IEnumerable Amount([PipedArgument] IEnumerable @ref) + => @ref.Select(Amount); } // Used for Toolshed queries. diff --git a/Content.Server/Station/Commands/StationCommand.cs b/Content.Server/Station/Commands/StationCommand.cs index e1013548ac..8fe8c67646 100644 --- a/Content.Server/Station/Commands/StationCommand.cs +++ b/Content.Server/Station/Commands/StationCommand.cs @@ -27,7 +27,7 @@ public sealed class StationsCommand : ToolshedCommand } [CommandImplementation("get")] - public EntityUid Get([CommandInvocationContext] IInvocationContext ctx) + public EntityUid Get(IInvocationContext ctx) { _station ??= GetSys(); @@ -54,7 +54,6 @@ public sealed class StationsCommand : ToolshedCommand public EntityUid? LargestGrid([PipedArgument] EntityUid input) { _station ??= GetSys(); - return _station.GetLargestGrid(Comp(input)); } @@ -80,46 +79,30 @@ public sealed class StationsCommand : ToolshedCommand => input.Select(Config); [CommandImplementation("addgrid")] - public void AddGrid( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] ValueRef grid - ) + public void AddGrid([PipedArgument] EntityUid input, EntityUid grid) { _station ??= GetSys(); - - _station.AddGridToStation(input, grid.Evaluate(ctx)); + _station.AddGridToStation(input, grid); } [CommandImplementation("rmgrid")] - public void RmGrid( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] ValueRef grid - ) + public void RmGrid([PipedArgument] EntityUid input, EntityUid grid) { _station ??= GetSys(); - - _station.RemoveGridFromStation(input, grid.Evaluate(ctx)); + _station.RemoveGridFromStation(input, grid); } [CommandImplementation("rename")] - public void Rename([CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input, - [CommandArgument] ValueRef name - ) + public void Rename([PipedArgument] EntityUid input, string name) { _station ??= GetSys(); - - _station.RenameStation(input, name.Evaluate(ctx)!); + _station.RenameStation(input, name); } [CommandImplementation("rerollBounties")] - public void RerollBounties([CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] EntityUid input) + public void RerollBounties([PipedArgument] EntityUid input) { _cargo ??= GetSys(); - _cargo.RerollBountyDatabase(input); } } diff --git a/Content.Server/StationEvents/BasicStationEventSchedulerSystem.cs b/Content.Server/StationEvents/BasicStationEventSchedulerSystem.cs index bdc9a47e18..a3c2440fe9 100644 --- a/Content.Server/StationEvents/BasicStationEventSchedulerSystem.cs +++ b/Content.Server/StationEvents/BasicStationEventSchedulerSystem.cs @@ -94,7 +94,7 @@ namespace Content.Server.StationEvents /// to even exist) so I think it's fine. /// [CommandImplementation("simulate")] - public IEnumerable<(string, float)> Simulate([CommandArgument] EntityPrototype eventScheduler, [CommandArgument] int rounds, [CommandArgument] int playerCount, [CommandArgument] float roundEndMean, [CommandArgument] float roundEndStdDev) + public IEnumerable<(string, float)> Simulate(EntityPrototype eventScheduler, int rounds, int playerCount, float roundEndMean, float roundEndStdDev) { _stationEvent ??= GetSys(); _entityTable ??= GetSys(); @@ -146,7 +146,7 @@ namespace Content.Server.StationEvents } [CommandImplementation("lsprob")] - public IEnumerable<(string, float)> LsProb([CommandArgument] EntityPrototype eventScheduler) + public IEnumerable<(string, float)> LsProb(EntityPrototype eventScheduler) { _compFac ??= IoCManager.Resolve(); _stationEvent ??= GetSys(); @@ -166,7 +166,7 @@ namespace Content.Server.StationEvents } [CommandImplementation("lsprobtime")] - public IEnumerable<(string, float)> LsProbTime([CommandArgument] EntityPrototype eventScheduler, [CommandArgument] float time) + public IEnumerable<(string, float)> LsProbTime(EntityPrototype eventScheduler, float time) { _compFac ??= IoCManager.Resolve(); _stationEvent ??= GetSys(); @@ -188,7 +188,7 @@ namespace Content.Server.StationEvents } [CommandImplementation("prob")] - public float Prob([CommandArgument] EntityPrototype eventScheduler, [CommandArgument] string eventId) + public float Prob(EntityPrototype eventScheduler, string eventId) { _compFac ??= IoCManager.Resolve(); _stationEvent ??= GetSys(); diff --git a/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs b/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs index f113e49655..ff110a9d9e 100644 --- a/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs +++ b/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs @@ -22,13 +22,9 @@ public sealed class ACmdCommand : ToolshedCommand } [CommandImplementation("caninvoke")] - public bool CanInvoke( - [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] CommandSpec command, - [CommandArgument] ValueRef player - ) + public bool CanInvoke(IInvocationContext ctx, [PipedArgument] CommandSpec command, ICommonSession player) { // Deliberately discard the error. - return ((IPermissionController) _adminManager).CheckInvokable(command, player.Evaluate(ctx), out var err); + return ((IPermissionController) _adminManager).CheckInvokable(command, player, out _); } } diff --git a/Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs b/Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs index 5c1bac6c93..d251d66898 100644 --- a/Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs +++ b/Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs @@ -15,10 +15,10 @@ public sealed class RunVerbAsCommand : ToolshedCommand [CommandImplementation] public IEnumerable RunVerbAs( - [CommandInvocationContext] IInvocationContext ctx, + IInvocationContext ctx, [PipedArgument] IEnumerable input, - [CommandArgument] ValueRef runner, - [CommandArgument] string verb + EntityUid runner, + string verb ) { _verb ??= GetSys(); @@ -26,17 +26,14 @@ public sealed class RunVerbAsCommand : ToolshedCommand foreach (var i in input) { - var runnerNet = runner.Evaluate(ctx); - var runnerEid = EntityManager.GetEntity(runnerNet); - - if (EntityManager.Deleted(runnerEid) && runnerEid.IsValid()) - ctx.ReportError(new DeadEntity(runnerEid)); + if (EntityManager.Deleted(runner) && runner.IsValid()) + ctx.ReportError(new DeadEntity(runner)); if (ctx.GetErrors().Any()) yield break; var eId = EntityManager.GetEntity(i); - var verbs = _verb.GetLocalVerbs(eId, runnerEid, Verb.VerbTypes, true); + var verbs = _verb.GetLocalVerbs(eId, runner, Verb.VerbTypes, true); // if the "verb name" is actually a verb-type, try run any verb of that type. var verbType = Verb.VerbTypes.FirstOrDefault(x => x.Name == verb); @@ -45,7 +42,7 @@ public sealed class RunVerbAsCommand : ToolshedCommand var verbTy = verbs.FirstOrDefault(v => v.GetType() == verbType); if (verbTy != null) { - _verb.ExecuteVerb(verbTy, runnerEid, eId, forced: true); + _verb.ExecuteVerb(verbTy, runner, eId, forced: true); yield return i; } } @@ -54,7 +51,7 @@ public sealed class RunVerbAsCommand : ToolshedCommand { if (verbTy.Text.ToLowerInvariant() == verb) { - _verb.ExecuteVerb(verbTy, runnerEid, eId, forced: true); + _verb.ExecuteVerb(verbTy, runner, eId, forced: true); yield return i; } } diff --git a/Content.Server/Toolshed/Commands/VisualizeCommand.cs b/Content.Server/Toolshed/Commands/VisualizeCommand.cs index 2225bfaf44..41613cab86 100644 --- a/Content.Server/Toolshed/Commands/VisualizeCommand.cs +++ b/Content.Server/Toolshed/Commands/VisualizeCommand.cs @@ -16,7 +16,7 @@ public sealed class VisualizeCommand : ToolshedCommand [CommandImplementation] public void VisualizeEntities( - [CommandInvocationContext] IInvocationContext ctx, + IInvocationContext ctx, [PipedArgument] IEnumerable input ) { diff --git a/Resources/toolshedEngineCommandPerms.yml b/Resources/toolshedEngineCommandPerms.yml index ac7ffddd5f..b9911e9468 100644 --- a/Resources/toolshedEngineCommandPerms.yml +++ b/Resources/toolshedEngineCommandPerms.yml @@ -6,7 +6,6 @@ - physics - player - splat - - emplace - bin - extremes - reduce @@ -19,113 +18,88 @@ - iota - rep - to - - iterate - Flags: DEBUG Commands: - comp - delete - - do + - with + - prototyped - named - paused - - with - - count + - emplace + - do + - iterate - select - where - - prototyped + - count - types - - ecscomp - actor - spawn + - replace - mappos - pos - tp - allcomps - - replace - entitysystemupdateorder - mind - -- Flags: HOST - Commands: - - methods - - ioc - -- Commands: - fuck - - ent - - as - - buildinfo - - help - - explain - - cmd - - stopwatch + - '=>' + - '?' + - 'or?' + - '??' + - rng - self + - sum + - take + - join - search + - first + - unique + - any + - contains - isnull - - help - isempty - - any - - unique - cd - ls - - loc - - vars - - '=>' - - first - - val + - stopwatch + - append + - min + - max + - average - '+' - '-' - '*' - '/' - - 'min' - - 'max' - - '&' - - '|' - - '^' - - 'neg' + - '%' + - '%/' + - '&~' + - '|~' + - '^~' + - '~' - '<' - '>' - '<=' - '>=' - '==' - '!=' - - f - - i - - s - - b - '+/' - '-/' - '*/' - '//' - - join - - append - - '?' - - 'or?' - - '??' - - rng - - 'sum' - - take - - curtick - - curtime - - realtime - - servertime - - more - - '%' - - '%/' - - '&~' - - '|~' - - '^~' - - '~' - - 'abs' - - 'average' - - 'bibytecount' - - 'shortestbitlength' - - 'countleadzeros' - - 'counttrailingzeros' - - 'fpi' - - 'fe' - - 'ftau' - - 'fepsilon' + - '&' + - '|' + - '^' + - neg + - abs + - bibytecount + - shortestbitlength + - countleadzeros + - counttrailingzeros + - fpi + - fe + - ftau + - fepsilon - dpi - de - dtau @@ -181,3 +155,29 @@ - atanpi - pick - tee + +- Flags: HOST + Commands: + - methods + - ioc + +- Commands: + - ent + - f + - i + - s + - b + - as + - var + - vars + - val + - help + - explain + - cmd + - buildinfo + - loc + - curtick + - curtime + - realtime + - servertime + - more -- 2.51.2