From 85736bfd6befa690f971095f960229be748c8427 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 1 Mar 2022 21:11:22 +1100 Subject: [PATCH] Adjust mapping command order (#6929) --- .../GameTicking/Commands/MappingCommand.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Content.Server/GameTicking/Commands/MappingCommand.cs b/Content.Server/GameTicking/Commands/MappingCommand.cs index e5401299d5..426edb50b0 100644 --- a/Content.Server/GameTicking/Commands/MappingCommand.cs +++ b/Content.Server/GameTicking/Commands/MappingCommand.cs @@ -17,14 +17,13 @@ namespace Content.Server.GameTicking.Commands public string Command => "mapping"; public string Description => "Creates and teleports you to a new uninitialized map for mapping."; - public string Help => $"Usage: {Command} [mapname] [id]"; + public string Help => $"Usage: {Command} "; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player as IPlayerSession; - if (player == null) + if (shell.Player is not IPlayerSession player) { - shell.WriteLine("Only players can use this command"); + shell.WriteError("Only players can use this command"); return; } @@ -42,11 +41,11 @@ namespace Content.Server.GameTicking.Commands MapId mapId; // Get the map ID to use - if (args.Length == 2) + if (args.Length is 1 or 2) { - if (!int.TryParse(args[1], out var id)) + if (!int.TryParse(args[0], out var id)) { - shell.WriteError($"{args[1]} is not a valid integer."); + shell.WriteError($"{args[0]} is not a valid integer."); return; } @@ -62,11 +61,13 @@ namespace Content.Server.GameTicking.Commands mapId = mapManager.NextMapId(); } + DebugTools.Assert(args.Length <= 2); + // either load a map or create a new one. - if (args.Length == 0) + if (args.Length <= 1) shell.ExecuteCommand($"addmap {mapId} false"); else - shell.ExecuteCommand($"loadmap {mapId} \"{CommandParsing.Escape(args[0])}\""); + shell.ExecuteCommand($"loadmap {mapId} \"{CommandParsing.Escape(args[1])}\""); // was the map actually created? if (!mapManager.MapExists(mapId)) @@ -89,8 +90,8 @@ namespace Content.Server.GameTicking.Commands shell.RemoteExecuteCommand("showsubfloorforever"); mapManager.SetMapPaused(mapId, true); - if (args.Length != 0) - shell.WriteLine($"Created uninitialized map from file {args[0]} with id {mapId}."); + if (args.Length == 2) + shell.WriteLine($"Created uninitialized map from file {args[1]} with id {mapId}."); else shell.WriteLine($"Created a new uninitialized map with id {mapId}."); }