Add three options to the autostart CLI.

- a speed option
- a placement option
- a map visibility option
This commit is contained in:
Stan
2025-01-25 14:06:34 +01:00
parent 40fe7df654
commit 288f125178
3 changed files with 43 additions and 1 deletions
@@ -27,6 +27,8 @@
* (default 10 minutes)
* -autostart-reliccount=NUM sets the number of relics for relic victory condition
* (default 2 relics)
* -autostart-visibility=TYPE sets the map visibility (explored, hidden, revealed, allied, allied-explored)
* -autostart-speed=SPEED sets the sim rate speed (default 1, max 2 in normal mode, 20 in observer mode)
*
* -autostart-nonvisual (partly handled in C++) disable any graphics and sounds
* -autostart-disable-replay disable saving of replays (handled in autostart*.js files)
@@ -45,6 +47,7 @@
* -autostart-size=TILES sets random map size in TILES (default 192)
* -autostart-players=NUMBER sets NUMBER of players on random map
* (default 2)
* -autostart-placement=PLACEMENT sets the placement type for a random map
*
* Examples:
* 1) "Bob" will host a 2 player game on the Arcadia map:
@@ -70,6 +73,38 @@ function parseCmdLineArgs(settings, cmdLineArgs)
settings.map.selectMap("maps/" + cmdLineArgs['autostart']);
settings.mapSize.setSize(+(cmdLineArgs['autostart-size'] ?? 192));
settings.biome.setBiome(cmdLineArgs['autostart-biome'] || "random");
settings.playerPlacement.setValue(cmdLineArgs['autostart-placement'] ?? "random");
if ('autostart-visibility' in cmdLineArgs)
{
switch (cmdLineArgs['autostart-visibility'])
{
case 'revealed':
settings.mapExploration.setAllied(true);
settings.mapExploration.setExplored(true);
settings.mapExploration.setRevealed(true);
break;
case 'explored':
settings.mapExploration.setAllied(false);
settings.mapExploration.setExplored(true);
settings.mapExploration.setRevealed(false);
break;
case 'hidden':
settings.mapExploration.setAllied(false);
settings.mapExploration.setExplored(false);
settings.mapExploration.setRevealed(false);
break;
case 'allied':
settings.mapExploration.setAllied(true);
settings.mapExploration.setExplored(false);
settings.mapExploration.setRevealed(false);
break;
case 'allied-explored':
settings.mapExploration.setAllied(true);
settings.mapExploration.setExplored(true);
settings.mapExploration.setRevealed(false);
break;
}
}
settings.playerCount.setNb(+(cmdLineArgs['autostart-players'] ?? 2));
@@ -109,6 +144,9 @@ function parseCmdLineArgs(settings, cmdLineArgs)
if (cmdLineArgs['autostart-aiseed'] != -1)
settings.seeds.AIseed = +(cmdLineArgs['autostart-aiseed'] ?? 0);
if (cmdLineArgs['autostart-speed'])
settings.gameSpeed.setSpeed(+(cmdLineArgs['autostart-speed'] ?? 1));
if (cmdLineArgs['autostart-ceasefire'])
settings.ceasefire.setValue(+(cmdLineArgs['autostart-ceasefire'] ?? 0));
@@ -40,7 +40,7 @@ GameSettings.prototype.Attributes.PlayerPlacement = class PlayerPlacement extend
pickRandomItems()
{
// If the map is random, we need to wait until it is selected.
if (this.settings.map.map === "random" || this.value !== "random")
if (this.settings.map.map === "random" || this.value !== "random" || !this.available)
return false;
this.value = pickRandom(this.available);
+4
View File
@@ -18,10 +18,13 @@ Autostart:
-autostart-team=PLAYER:TEAM sets the team for PLAYER (e.g. 2:2).
-autostart-ceasefire=NUM sets a ceasefire duration NUM (default 0 minutes)
-autostart-nonvisual disable any graphics and sounds
-autostart-visibility=TYPE sets the map visibility (explored, hidden, revealed, allied, allied-explored)
-autostart-speed=SPEED sets the sim rate speed (default 1, max 2 in normal mode, 20 in observer mode)
-autostart-victory=SCRIPTNAME sets the victory conditions with SCRIPTNAME located in simulation/data/settings/victory_conditions/ (default conquest). When the only given SCRIPTNAME is "endless", no victory conditions will apply.
-autostart-wonderduration=NUM sets the victory duration NUM for wonder victory condition (default 10 minutes)
-autostart-relicduration=NUM sets the victory duration NUM for relic victory condition (default 10 minutes)
-autostart-reliccount=NUM sets the number of relics for relic victory condition (default 2 relics)
-autostart-revealed=BOOL sets whether the map should be revealed
-autostart-disable-replay disable saving of replays
Multiplayer:
-autostart-playername=NAME sets local player NAME (default 'anonymous')
@@ -31,6 +34,7 @@ Multiplayer:
Random maps only:
-autostart-size=TILES sets random map size in TILES (default 192)
-autostart-players=NUMBER sets NUMBER of players on random map (default 2)
-autostart-placement=PLACEMENT sets the placement type for a random map
Examples:
1) "Bob" will host a 2 player game on the Arcadia map: