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 2025-11-30 20:13:19 +01:00
parent 0d60bdfd2e
commit 958e6de9d3
No known key found for this signature in database

View file

@ -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']);