Adjust mapping command order (#6929)

This commit is contained in:
metalgearsloth
2022-03-01 21:11:22 +11:00
committed by GitHub
parent 60dccc829a
commit 85736bfd6b

View File

@@ -17,14 +17,13 @@ namespace Content.Server.GameTicking.Commands
public string Command => "mapping"; public string Command => "mapping";
public string Description => "Creates and teleports you to a new uninitialized map for 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} <MapID> <Path>";
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var player = shell.Player as IPlayerSession; if (shell.Player is not IPlayerSession player)
if (player == null)
{ {
shell.WriteLine("Only players can use this command"); shell.WriteError("Only players can use this command");
return; return;
} }
@@ -42,11 +41,11 @@ namespace Content.Server.GameTicking.Commands
MapId mapId; MapId mapId;
// Get the map ID to use // 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; return;
} }
@@ -62,11 +61,13 @@ namespace Content.Server.GameTicking.Commands
mapId = mapManager.NextMapId(); mapId = mapManager.NextMapId();
} }
DebugTools.Assert(args.Length <= 2);
// either load a map or create a new one. // either load a map or create a new one.
if (args.Length == 0) if (args.Length <= 1)
shell.ExecuteCommand($"addmap {mapId} false"); shell.ExecuteCommand($"addmap {mapId} false");
else else
shell.ExecuteCommand($"loadmap {mapId} \"{CommandParsing.Escape(args[0])}\""); shell.ExecuteCommand($"loadmap {mapId} \"{CommandParsing.Escape(args[1])}\"");
// was the map actually created? // was the map actually created?
if (!mapManager.MapExists(mapId)) if (!mapManager.MapExists(mapId))
@@ -89,8 +90,8 @@ namespace Content.Server.GameTicking.Commands
shell.RemoteExecuteCommand("showsubfloorforever"); shell.RemoteExecuteCommand("showsubfloorforever");
mapManager.SetMapPaused(mapId, true); mapManager.SetMapPaused(mapId, true);
if (args.Length != 0) if (args.Length == 2)
shell.WriteLine($"Created uninitialized map from file {args[0]} with id {mapId}."); shell.WriteLine($"Created uninitialized map from file {args[1]} with id {mapId}.");
else else
shell.WriteLine($"Created a new uninitialized map with id {mapId}."); shell.WriteLine($"Created a new uninitialized map with id {mapId}.");
} }