diff --git a/Content.Client/Commands/DebugCommands.cs b/Content.Client/Commands/DebugCommands.cs index 8ba7a3a975..aa9eef2a94 100644 --- a/Content.Client/Commands/DebugCommands.cs +++ b/Content.Client/Commands/DebugCommands.cs @@ -90,11 +90,11 @@ namespace Content.Client.Commands { public string Command => "mapping"; public string Description => "Creates and teleports you to a new uninitialized map for mapping."; - public string Help => $"Usage: {Command} "; + public string Help => $"Usage: {Command} / {Command} "; public bool Execute(IDebugConsole console, params string[] args) { - if (args.Length != 2) + if (args.Length == 0) { console.AddLine(Help); return false; diff --git a/Content.Server/GameTicking/GameTickerCommands.cs b/Content.Server/GameTicking/GameTickerCommands.cs index 7210653321..4d553fa68c 100644 --- a/Content.Server/GameTicking/GameTickerCommands.cs +++ b/Content.Server/GameTicking/GameTickerCommands.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Content.Server.Interfaces.GameTicking; using Content.Server.Players; using Content.Shared.Maps; @@ -321,7 +322,7 @@ namespace Content.Server.GameTicking { public string Command => "mapping"; public string Description => "Creates and teleports you to a new uninitialized map for mapping."; - public string Help => $"Usage: {Command} "; + public string Help => $"Usage: {Command} / {Command} "; public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) { @@ -331,18 +332,45 @@ namespace Content.Server.GameTicking return; } - if (args.Length != 2) + var mapManager = IoCManager.Resolve(); + int mapId; + string mapName; + + switch (args.Length) { - shell.SendText(player, Help); - return; + case 1: + if (player.AttachedEntity == null) + { + shell.SendText(player, "The map name argument cannot be omitted if you have no entity."); + return; + } + + mapId = (int) mapManager.NextMapId(); + mapName = args[0]; + break; + case 2: + if (!int.TryParse(args[0], out var id)) + { + shell.SendText(player, $"{args[0]} is not a valid integer."); + return; + } + + mapId = id; + mapName = args[1]; + break; + default: + shell.SendText(player, Help); + return; } - shell.ExecuteCommand(player, $"addmap {args[0]} false"); - shell.ExecuteCommand(player, $"loadbp {args[0]} \"{CommandParsing.Escape(args[1])}\""); + shell.ExecuteCommand(player, $"addmap {mapId} false"); + shell.ExecuteCommand(player, $"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\""); shell.ExecuteCommand(player, $"aghost"); - shell.ExecuteCommand(player, $"tp 0 0 {args[0]}"); + shell.ExecuteCommand(player, $"tp 0 0 {mapId}"); - shell.SendText(player, $"Created unloaded map from file {args[1]} with id {args[0]}. Use \"savebp 4 foo.yml\" to save it."); + var newGridId = mapManager.GetAllGrids().Max(g => (int) g.Index); + + shell.SendText(player, $"Created unloaded map from file {mapName} with id {mapId}. Use \"savebp {newGridId} foo.yml\" to save the new grid as a map."); } }