From b3581d11c649402e9b275eb535af813ffebe2288 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 14 Sep 2022 14:05:48 +1000 Subject: [PATCH] Update maploader to support loading onto an existing map (#10748) --- .../Commands/LoadGameMapCommand.cs | 37 +++++++++++++++++-- .../GameTicking/GameTicker.RoundFlow.cs | 2 + 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Content.Server/Administration/Commands/LoadGameMapCommand.cs b/Content.Server/Administration/Commands/LoadGameMapCommand.cs index 156d8147f2..5f8e82796d 100644 --- a/Content.Server/Administration/Commands/LoadGameMapCommand.cs +++ b/Content.Server/Administration/Commands/LoadGameMapCommand.cs @@ -1,8 +1,10 @@ +using System.Linq; using Content.Server.GameTicking; using Content.Server.Maps; using Content.Shared.Administration; using Robust.Server.Maps; using Robust.Shared.Console; +using Robust.Shared.ContentPack; using Robust.Shared.Map; using Robust.Shared.Prototypes; @@ -15,7 +17,7 @@ namespace Content.Server.Administration.Commands public string Description => "Loads the given game map at the given coordinates."; - public string Help => "loadgamemap [ []] "; + public string Help => "loadgamemap [ []] "; public void Execute(IConsoleShell shell, string argStr, string[] args) { @@ -29,11 +31,16 @@ namespace Content.Server.Administration.Commands return; } - if (prototypeManager.TryIndex(args[0], out var gameMap)) + if (prototypeManager.TryIndex(args[1], out var gameMap)) { - if (!int.TryParse(args[1], out var mapId)) return; + if (!int.TryParse(args[0], out var mapId)) + return; + + var loadOptions = new MapLoadOptions() + { + LoadMap = false, + }; - var loadOptions = new MapLoadOptions(); var stationName = args.Length == 5 ? args[4] : null; if (args.Length >= 4 && int.TryParse(args[2], out var x) && int.TryParse(args[3], out var y)) @@ -48,6 +55,28 @@ namespace Content.Server.Administration.Commands shell.WriteError($"The given map prototype {args[0]} is invalid."); } } + + public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + { + switch (args.Length) + { + case 1: + return CompletionResult.FromHint(Loc.GetString("cmd-hint-savemap-id")); + case 2: + var opts = CompletionHelper.PrototypeIDs(); + return CompletionResult.FromHintOptions(opts, Loc.GetString("cmd-hint-savemap-path")); + case 3: + return CompletionResult.FromHint(Loc.GetString("cmd-hint-loadmap-x-position")); + case 4: + return CompletionResult.FromHint(Loc.GetString("cmd-hint-loadmap-y-position")); + case 5: + return CompletionResult.FromHint(Loc.GetString("cmd-hint-loadmap-rotation")); + case 6: + return CompletionResult.FromHint(Loc.GetString("cmd-hint-loadmap-uids")); + } + + return CompletionResult.Empty; + } } [AdminCommand(AdminFlags.Round | AdminFlags.Spawn)] diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 33edd3cbf7..1f597976ab 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -114,6 +114,8 @@ namespace Content.Server.GameTicking /// All loaded entities and grids. public (IReadOnlyList, IReadOnlyList) LoadGameMap(GameMapPrototype map, MapId targetMapId, MapLoadOptions? loadOptions, string? stationName = null) { + // Okay I specifically didn't set LoadMap here because this is typically called onto a new map. + // whereas the command can also be used on an existing map. var loadOpts = loadOptions ?? new MapLoadOptions(); var ev = new PreGameMapLoad(targetMapId, map, loadOpts);