mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
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:
parent
0d60bdfd2e
commit
958e6de9d3
1 changed files with 14 additions and 5 deletions
|
|
@ -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']);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue