mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-09-15 14:52:26 +02:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using Content.Shared.Administration;
|
|
using Content.Shared.CCVar;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.EntitySerialization.Systems;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Server.Administration.Commands;
|
|
|
|
[AdminCommand(AdminFlags.Server)]
|
|
public sealed partial class PersistenceSave : LocalizedEntityCommands
|
|
{
|
|
[Dependency] private IConfigurationManager _config = default!;
|
|
[Dependency] private SharedMapSystem _map = default!;
|
|
[Dependency] private MapLoaderSystem _mapLoader = default!;
|
|
|
|
public override string Command => "persistencesave";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length < 1 || args.Length > 2)
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
|
return;
|
|
}
|
|
|
|
if (!int.TryParse(args[0], out var intMapId))
|
|
{
|
|
shell.WriteError(Loc.GetString("cmd-parse-failure-integer", ("arg", args[0])));
|
|
return;
|
|
}
|
|
|
|
var mapId = new MapId(intMapId);
|
|
if (!_map.MapExists(mapId))
|
|
{
|
|
shell.WriteError(Loc.GetString("cmd-savemap-not-exist"));
|
|
return;
|
|
}
|
|
|
|
var saveFilePath = (args.Length > 1 ? args[1] : null) ?? _config.GetCVar(CCVars.GameMap);
|
|
if (string.IsNullOrWhiteSpace(saveFilePath))
|
|
{
|
|
shell.WriteError(Loc.GetString("cmd-persistencesave-no-path", ("cvar", nameof(CCVars.GameMap))));
|
|
return;
|
|
}
|
|
|
|
_mapLoader.TrySaveMap(mapId, new ResPath(saveFilePath));
|
|
shell.WriteLine(Loc.GetString("cmd-savemap-success"));
|
|
}
|
|
}
|