]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Toolshed refactor (#33598)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Sat, 21 Dec 2024 06:45:48 +0000 (17:45 +1100)
committerGitHub <noreply@github.com>
Sat, 21 Dec 2024 06:45:48 +0000 (17:45 +1100)
* Content changes for engine toolshed PR

* add contains command

* more permissive commands

19 files changed:
Content.IntegrationTests/Tests/Toolshed/AdminTest.cs
Content.IntegrationTests/Tests/Toolshed/LocTest.cs
Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs
Content.Server/Access/AddAccessLogCommand.cs
Content.Server/Administration/Toolshed/MarkedCommand.cs
Content.Server/Administration/Toolshed/RejuvenateCommand.cs
Content.Server/Administration/Toolshed/SolutionCommand.cs
Content.Server/Administration/Toolshed/TagCommand.cs
Content.Server/Chat/V2/Commands/DeleteChatMessageCommand.cs
Content.Server/Chat/V2/Commands/NukeChatMessagesCommand.cs
Content.Server/Mind/Toolshed/MindCommand.cs
Content.Server/Polymorph/Toolshed/PolymorphCommand.cs
Content.Server/Station/Commands/JobsCommand.cs
Content.Server/Station/Commands/StationCommand.cs
Content.Server/StationEvents/BasicStationEventSchedulerSystem.cs
Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs
Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs
Content.Server/Toolshed/Commands/VisualizeCommand.cs
Resources/toolshedEngineCommandPerms.yml

index 040b09beeccff2c2bc5a07b9fa107a3aa5b5e7ad..ecb11fc1ba4f5e97445d7a39f22a68348fbc859e 100644 (file)
@@ -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<ToolshedManager>();
+        var admin = Server.ResolveDependency<IAdminManager>();
+        var ignored = new HashSet<Assembly>()
+            {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<CommandSpec>) 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()}");
+                }
+            });
         });
     }
 }
index 2b5553ad7ddd4237fc8f29ffc4eb454ba30e86a9..fb210eba50599e9a9e2679ddf00235f51bf0452e 100644 (file)
@@ -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<ILocalizationManager>();
+        var toolMan = Server.ResolveDependency<ToolshedManager>();
+        var locStrings = new HashSet<string>();
+
+        var ignored = new HashSet<Assembly>()
+            {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<CommandSpec>)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()}");
+                }
+            });
         });
     }
 }
index 7de81fb3dc2517b72bd1e3614885e50a48a69294..6fc27e168cf34a726d6d7e135af804ccf51ebe30 100644 (file)
@@ -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<string> GetVars()
+    {
+        return Variables.Keys;
+    }
+
     public Dictionary<string, object?> Variables { get; } = new();
 
     protected void ExpectError(Type err)
index 8b3aebb16b45c833cf1b782757a510317f22babb..f55a9b8f1eba017113cbe84d070d9669700d66fe 100644 (file)
@@ -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<string> accessor)
+    public void AddAccessLog(IInvocationContext ctx, EntityUid input, float seconds, string accessor)
     {
         var accessReader = EnsureComp<AccessReaderComponent>(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<string> accessor)
+    public void AddAccessLogPiped(IInvocationContext ctx, [PipedArgument] EntityUid input, float seconds, string accessor)
     {
         AddAccessLog(ctx, input, seconds, accessor);
     }
index b9e39cb82da8af3f155ffa0a38b262ecef87439d..54d45a352de781bcad1ad829c274145d20d50ecb 100644 (file)
@@ -7,7 +7,7 @@ namespace Content.Server.Administration.Toolshed;
 public sealed class MarkedCommand : ToolshedCommand
 {
     [CommandImplementation]
-    public IEnumerable<EntityUid> Marked([CommandInvocationContext] IInvocationContext ctx)
+    public IEnumerable<EntityUid> Marked(IInvocationContext ctx)
     {
         var res = (IEnumerable<EntityUid>?)ctx.ReadVar("marked");
         res ??= Array.Empty<EntityUid>();
index 61b0d6213aa29e24b8686e4f5d6a6d87510186d8..3925badc589d3a8d6c09d3f0de610596c2b1f524 100644 (file)
@@ -23,7 +23,7 @@ public sealed class RejuvenateCommand : ToolshedCommand
     }
 
     [CommandImplementation]
-    public void Rejuvenate([CommandInvocationContext] IInvocationContext ctx)
+    public void Rejuvenate(IInvocationContext ctx)
     {
         _rejuvenate ??= GetSys<RejuvenateSystem>();
         if (ExecutingEntity(ctx) is not { } ent)
index f8c9bdd5c7fdf2e992999f3291de3b9374330b2d..c529bcd16d2a74e00a7fe146ff66381d8904e7d8 100644 (file)
@@ -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<string> name
-        )
+    public SolutionRef? Get([PipedArgument] EntityUid input, string name)
     {
         _solutionContainer ??= GetSys<SharedSolutionContainerSystem>();
 
-        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<SolutionRef> Get(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] IEnumerable<EntityUid> input,
-        [CommandArgument] ValueRef<string> name
-    )
+    public IEnumerable<SolutionRef> Get([PipedArgument] IEnumerable<EntityUid> input, string name)
     {
-        return input.Select(x => Get(ctx, x, name)).Where(x => x is not null).Cast<SolutionRef>();
+        return input.Select(x => Get(x, name)).Where(x => x is not null).Cast<SolutionRef>();
     }
 
     [CommandImplementation("adjreagent")]
     public SolutionRef AdjReagent(
-            [CommandInvocationContext] IInvocationContext ctx,
             [PipedArgument] SolutionRef input,
-            [CommandArgument] Prototype<ReagentPrototype> name,
-            [CommandArgument] ValueRef<FixedPoint2> amountRef
+            ProtoId<ReagentPrototype> proto,
+            FixedPoint2 amount
         )
     {
         _solutionContainer ??= GetSys<SharedSolutionContainerSystem>();
 
-        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<SolutionRef> AdjReagent(
-            [CommandInvocationContext] IInvocationContext ctx,
             [PipedArgument] IEnumerable<SolutionRef> input,
-            [CommandArgument] Prototype<ReagentPrototype> name,
-            [CommandArgument] ValueRef<FixedPoint2> amountRef
+            ProtoId<ReagentPrototype> name,
+            FixedPoint2 amount
         )
-        => input.Select(x => AdjReagent(ctx, x, name, amountRef));
+        => input.Select(x => AdjReagent(x, name, amount));
 }
 
 public readonly record struct SolutionRef(Entity<SolutionComponent> Solution)
index 4c6f790e49392485d2aee933868ebbf21a8b5712..a751b8591451b4f932c29354d9cef8848fbac469 100644 (file)
@@ -36,82 +36,50 @@ public sealed class TagCommand : ToolshedCommand
     }
 
     [CommandImplementation("add")]
-    public EntityUid Add(
-            [CommandInvocationContext] IInvocationContext ctx,
-            [PipedArgument] EntityUid input,
-            [CommandArgument] ValueRef<string, Prototype<TagPrototype>> @ref
-        )
+    public EntityUid Add([PipedArgument] EntityUid input, ProtoId<TagPrototype> tag)
     {
         _tag ??= GetSys<TagSystem>();
-        _tag.AddTag(input, @ref.Evaluate(ctx)!);
+        _tag.AddTag(input, tag);
         return input;
     }
 
     [CommandImplementation("add")]
-    public IEnumerable<EntityUid> Add(
-            [CommandInvocationContext] IInvocationContext ctx,
-            [PipedArgument] IEnumerable<EntityUid> input,
-            [CommandArgument] ValueRef<string, Prototype<TagPrototype>> @ref
-        )
-        => input.Select(x => Add(ctx, x, @ref));
+    public IEnumerable<EntityUid> Add([PipedArgument] IEnumerable<EntityUid> input, ProtoId<TagPrototype> tag)
+        => input.Select(x => Add(x, tag));
 
     [CommandImplementation("rm")]
-    public EntityUid Rm(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] EntityUid input,
-        [CommandArgument] ValueRef<string, Prototype<TagPrototype>> @ref
-    )
+    public EntityUid Rm([PipedArgument] EntityUid input, ProtoId<TagPrototype> tag)
     {
         _tag ??= GetSys<TagSystem>();
-        _tag.RemoveTag(input, @ref.Evaluate(ctx)!);
+        _tag.RemoveTag(input, tag);
         return input;
     }
 
     [CommandImplementation("rm")]
-    public IEnumerable<EntityUid> Rm(
-            [CommandInvocationContext] IInvocationContext ctx,
-            [PipedArgument] IEnumerable<EntityUid> input,
-            [CommandArgument] ValueRef<string, Prototype<TagPrototype>> @ref
-        )
-        => input.Select(x => Rm(ctx, x, @ref));
+    public IEnumerable<EntityUid> Rm([PipedArgument] IEnumerable<EntityUid> input, ProtoId<TagPrototype> tag)
+        => input.Select(x => Rm(x, tag));
 
     [CommandImplementation("addmany")]
-    public EntityUid AddMany(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] EntityUid input,
-        [CommandArgument] ValueRef<IEnumerable<string>, IEnumerable<string>> @ref
-    )
+    public EntityUid AddMany([PipedArgument] EntityUid input, IEnumerable<ProtoId<TagPrototype>> tags)
     {
         _tag ??= GetSys<TagSystem>();
-        _tag.AddTags(input, (IEnumerable<ProtoId<TagPrototype>>)@ref.Evaluate(ctx)!);
+        _tag.AddTags(input, tags);
         return input;
     }
 
     [CommandImplementation("addmany")]
-    public IEnumerable<EntityUid> AddMany(
-            [CommandInvocationContext] IInvocationContext ctx,
-            [PipedArgument] IEnumerable<EntityUid> input,
-            [CommandArgument] ValueRef<IEnumerable<string>, IEnumerable<string>> @ref
-        )
-        => input.Select(x => AddMany(ctx, x, @ref));
+    public IEnumerable<EntityUid> AddMany([PipedArgument] IEnumerable<EntityUid> input, IEnumerable<ProtoId<TagPrototype>> tags)
+        => input.Select(x => AddMany(x, tags.ToArray()));
 
     [CommandImplementation("rmmany")]
-    public EntityUid RmMany(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] EntityUid input,
-        [CommandArgument] ValueRef<IEnumerable<string>, IEnumerable<string>> @ref
-    )
+    public EntityUid RmMany([PipedArgument] EntityUid input, IEnumerable<ProtoId<TagPrototype>> tags)
     {
         _tag ??= GetSys<TagSystem>();
-        _tag.RemoveTags(input, (IEnumerable<ProtoId<TagPrototype>>)@ref.Evaluate(ctx)!);
+        _tag.RemoveTags(input, tags);
         return input;
     }
 
     [CommandImplementation("rmmany")]
-    public IEnumerable<EntityUid> RmMany(
-            [CommandInvocationContext] IInvocationContext ctx,
-            [PipedArgument] IEnumerable<EntityUid> input,
-            [CommandArgument] ValueRef<IEnumerable<string>, IEnumerable<string>> @ref
-        )
-        => input.Select(x => RmMany(ctx, x, @ref));
+    public IEnumerable<EntityUid> RmMany([PipedArgument] IEnumerable<EntityUid> input, IEnumerable<ProtoId<TagPrototype>> tags)
+        => input.Select(x => RmMany(x, tags.ToArray()));
 }
index 1f9203d299f3ff48340acc0b61e63b3a66307ce0..2aeb899829230bdb72593c960d1941ab113b8055 100644 (file)
@@ -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<ChatRepositorySystem>().Delete(messageId))
         {
index 3d8b69dd765222f3ab4553b5f584b447ee5af7bf..07b4cd97968963fc94cf167a14d10744e16e13ac 100644 (file)
@@ -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(',');
 
index 917e6fb7f1ad66207894f9cbc56c4da988635eed..5f82029dc0b36206875e37317044e2183a015d52 100644 (file)
@@ -29,19 +29,10 @@ public sealed class MindCommand : ToolshedCommand
     }
 
     [CommandImplementation("control")]
-    public EntityUid Control(
-            [CommandInvocationContext] IInvocationContext ctx,
-            [PipedArgument] EntityUid target,
-            [CommandArgument] ValueRef<ICommonSession> playerRef)
+    public EntityUid Control(IInvocationContext ctx, [PipedArgument] EntityUid target, ICommonSession player)
     {
         _mind ??= GetSys<SharedMindSystem>();
 
-        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))
         {
index 5654c84722f7a3b27f89e1e0a55a4ce2d6a148af..db1e1faad6b0e981d0f9b4585bc11a1a57668801 100644 (file)
@@ -20,7 +20,7 @@ public sealed class PolymorphCommand : ToolshedCommand
     [CommandImplementation]
     public EntityUid? Polymorph(
             [PipedArgument] EntityUid input,
-            [CommandArgument] ProtoId<PolymorphPrototype> protoId
+            ProtoId<PolymorphPrototype> protoId
         )
     {
         _system ??= GetSys<PolymorphSystem>();
@@ -34,7 +34,7 @@ public sealed class PolymorphCommand : ToolshedCommand
     [CommandImplementation]
     public IEnumerable<EntityUid> Polymorph(
             [PipedArgument] IEnumerable<EntityUid> input,
-            [CommandArgument] ProtoId<PolymorphPrototype> protoId
+            ProtoId<PolymorphPrototype> protoId
         )
         => input.Select(x => Polymorph(x, protoId)).Where(x => x is not null).Select(x => (EntityUid)x!);
 }
index 1d023c4a844fc7e9d9080b4245623d4093d1cd23..599a87aac6c3eff8fbea005d0d237268b859d853 100644 (file)
@@ -30,7 +30,7 @@ public sealed class JobsCommand : ToolshedCommand
         => stations.SelectMany(Jobs);
 
     [CommandImplementation("job")]
-    public JobSlotRef Job([PipedArgument] EntityUid station, [CommandArgument] Prototype<JobPrototype> job)
+    public JobSlotRef Job([PipedArgument] EntityUid station, Prototype<JobPrototype> job)
     {
         _jobs ??= GetSys<StationJobsSystem>();
 
@@ -38,7 +38,7 @@ public sealed class JobsCommand : ToolshedCommand
     }
 
     [CommandImplementation("job")]
-    public IEnumerable<JobSlotRef> Job([PipedArgument] IEnumerable<EntityUid> stations, [CommandArgument] Prototype<JobPrototype> job)
+    public IEnumerable<JobSlotRef> Job([PipedArgument] IEnumerable<EntityUid> stations, Prototype<JobPrototype> 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<int> by
-        )
+    public JobSlotRef Adjust([PipedArgument] JobSlotRef @ref, int by)
     {
         _jobs ??= GetSys<StationJobsSystem>();
-        _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<JobSlotRef> Adjust(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] IEnumerable<JobSlotRef> @ref,
-        [CommandArgument] ValueRef<int> by
-    )
-        => @ref.Select(x => Adjust(ctx, x, by));
+    public IEnumerable<JobSlotRef> Adjust([PipedArgument] IEnumerable<JobSlotRef> @ref, int by)
+        => @ref.Select(x => Adjust(x, by));
 
 
     [CommandImplementation("set")]
-    public JobSlotRef Set(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] JobSlotRef @ref,
-        [CommandArgument] ValueRef<int> by
-    )
+    public JobSlotRef Set([PipedArgument] JobSlotRef @ref, int by)
     {
         _jobs ??= GetSys<StationJobsSystem>();
-        _jobs.TrySetJobSlot(@ref.Station, @ref.Job, by.Evaluate(ctx), true);
+        _jobs.TrySetJobSlot(@ref.Station, @ref.Job, by, true);
         return @ref;
     }
 
     [CommandImplementation("set")]
-    public IEnumerable<JobSlotRef> Set(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] IEnumerable<JobSlotRef> @ref,
-        [CommandArgument] ValueRef<int> by
-    )
-        => @ref.Select(x => Set(ctx, x, by));
+    public IEnumerable<JobSlotRef> Set([PipedArgument] IEnumerable<JobSlotRef> @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<StationJobsSystem>();
         _jobs.TryGetJobSlot(@ref.Station, @ref.Job, out var slots);
-        return (int)(slots ?? 0);
+        return slots ?? 0;
     }
 
     [CommandImplementation("amount")]
-    public IEnumerable<int> Amount(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] IEnumerable<JobSlotRef> @ref
-    )
-        => @ref.Select(x => Amount(ctx, x));
+    public IEnumerable<int> Amount([PipedArgument] IEnumerable<JobSlotRef> @ref)
+        => @ref.Select(Amount);
 }
 
 // Used for Toolshed queries.
index e1013548ac8c610d50563829e2cc3d0a443d7a30..8fe8c67646d540e46774969c05719c946220fd06 100644 (file)
@@ -27,7 +27,7 @@ public sealed class StationsCommand : ToolshedCommand
     }
 
     [CommandImplementation("get")]
-    public EntityUid Get([CommandInvocationContext] IInvocationContext ctx)
+    public EntityUid Get(IInvocationContext ctx)
     {
         _station ??= GetSys<StationSystem>();
 
@@ -54,7 +54,6 @@ public sealed class StationsCommand : ToolshedCommand
     public EntityUid? LargestGrid([PipedArgument] EntityUid input)
     {
         _station ??= GetSys<StationSystem>();
-
         return _station.GetLargestGrid(Comp<StationDataComponent>(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<EntityUid> grid
-        )
+    public void AddGrid([PipedArgument] EntityUid input, EntityUid grid)
     {
         _station ??= GetSys<StationSystem>();
-
-        _station.AddGridToStation(input, grid.Evaluate(ctx));
+        _station.AddGridToStation(input, grid);
     }
 
     [CommandImplementation("rmgrid")]
-    public void RmGrid(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] EntityUid input,
-        [CommandArgument] ValueRef<EntityUid> grid
-    )
+    public void RmGrid([PipedArgument] EntityUid input, EntityUid grid)
     {
         _station ??= GetSys<StationSystem>();
-
-        _station.RemoveGridFromStation(input, grid.Evaluate(ctx));
+        _station.RemoveGridFromStation(input, grid);
     }
 
     [CommandImplementation("rename")]
-    public void Rename([CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] EntityUid input,
-        [CommandArgument] ValueRef<string> name
-    )
+    public void Rename([PipedArgument] EntityUid input, string name)
     {
         _station ??= GetSys<StationSystem>();
-
-        _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<CargoSystem>();
-
         _cargo.RerollBountyDatabase(input);
     }
 }
index bdc9a47e1867222b55d4227ac4d9413f939f366a..a3c2440fe93e8f58a2bd9f0935187647b7c97163 100644 (file)
@@ -94,7 +94,7 @@ namespace Content.Server.StationEvents
         ///     to even exist) so I think it's fine.
         /// </remarks>
         [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<EventManagerSystem>();
             _entityTable ??= GetSys<EntityTableSystem>();
@@ -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<IComponentFactory>();
             _stationEvent ??= GetSys<EventManagerSystem>();
@@ -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<IComponentFactory>();
             _stationEvent ??= GetSys<EventManagerSystem>();
@@ -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<IComponentFactory>();
             _stationEvent ??= GetSys<EventManagerSystem>();
index f113e496555cfb37c45a81829c99a0c22c8fc005..ff110a9d9edfe257a02e5ce9eaad9f6c4aff7dcc 100644 (file)
@@ -22,13 +22,9 @@ public sealed class ACmdCommand : ToolshedCommand
     }
 
     [CommandImplementation("caninvoke")]
-    public bool CanInvoke(
-        [CommandInvocationContext] IInvocationContext ctx,
-        [PipedArgument] CommandSpec command,
-        [CommandArgument] ValueRef<ICommonSession> 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 _);
     }
 }
index 5c1bac6c93b4ff5f54e34e2455523340d997c2a9..d251d668981fccfc468f21dd0190b19996b770d4 100644 (file)
@@ -15,10 +15,10 @@ public sealed class RunVerbAsCommand : ToolshedCommand
 
     [CommandImplementation]
     public IEnumerable<NetEntity> RunVerbAs(
-            [CommandInvocationContext] IInvocationContext ctx,
+            IInvocationContext ctx,
             [PipedArgument] IEnumerable<NetEntity> input,
-            [CommandArgument] ValueRef<NetEntity> runner,
-            [CommandArgument] string verb
+            EntityUid runner,
+            string verb
         )
     {
         _verb ??= GetSys<SharedVerbSystem>();
@@ -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;
                 }
             }
index 2225bfaf4474787159ea44912efe7214fa618dcd..41613cab86b55ce34663299b8593c624d822e189 100644 (file)
@@ -16,7 +16,7 @@ public sealed class VisualizeCommand : ToolshedCommand
 
     [CommandImplementation]
     public void VisualizeEntities(
-            [CommandInvocationContext] IInvocationContext ctx,
+            IInvocationContext ctx,
             [PipedArgument] IEnumerable<EntityUid> input
         )
     {
index ac7ffddd5f91d2c0b0d4a8d25d55987819881025..b9911e9468db1de67f2b4fdfbfc2cf4093b0d2cf 100644 (file)
@@ -6,7 +6,6 @@
     - physics
     - player
     - splat
-    - emplace
     - bin
     - extremes
     - reduce
     - 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
     - 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