forked from mirrors/0ad
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>
(cherry picked from commit 958e6de9d3)
Signed-off-by: phosit <phosit@autistici.org>
This commit is contained in:
@@ -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']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user