Cleanly fail autostart for invalid map type

As for any invalid argument reject them and cleanly exit with failure
status.

Fixes: #7687
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser committed 2026-01-29 20:03:56 +01:00
1 parent 0d60bdfd2e
commit 958e6de9d3
1 file changed
+14 -5
@@ -66,11 +66,20 @@ function parseCmdLineArgs(settings, cmdLineArgs)
{
// eslint-disable-next-line dot-notation
const mapType = cmdLineArgs['autostart'].substring(0, cmdLineArgs['autostart'].indexOf('/'));
settings.map.setType({
"scenarios": "scenario",
"random": "random",
"skirmishes": "skirmish",
}[mapType]);
switch (mapType)
{
case "random":
settings.map.setType("random");
break;
case "scenarios":
settings.map.setType("scenario");
break;
case "skirmishes":
settings.map.setType("skirmish");
break;
default:
throw new Error(`Unknown map type ${mapType}`);
}
// eslint-disable-next-line dot-notation
settings.map.selectMap("maps/" + cmdLineArgs['autostart']);