Fix bug with map-dependent random settings

Settings like Landscape, Daytime & team placement are map dependent. If
"random" map is chosen, we first must select the map before selecting
these.
This wasn't done correctly and so starting "random" map that picked e.g.
Unknown could fail.

Biomes were already correctly handled.

Reported by: langbart
Fixes #6227

Differential Revision: https://code.wildfiregames.com/D4173
This was SVN commit r25800.
This commit is contained in:
wraitii
2021-06-16 15:52:19 +00:00
parent eafa7fc005
commit 8e26bd0446
3 changed files with 12 additions and 0 deletions
@@ -46,6 +46,10 @@ GameSettings.prototype.Attributes.Daytime = class Daytime extends GameSetting
pickRandomItems()
{
// If the map is random, we need to wait until it is selected.
if (this.settings.map.map === "random")
return true;
if (this.value !== "random")
return false;
this.value = pickRandom(this.data).Id;
@@ -56,6 +56,10 @@ GameSettings.prototype.Attributes.Landscape = class Landscape extends GameSettin
pickRandomItems()
{
// If the map is random, we need to wait until it is selected.
if (this.settings.map.map === "random")
return true;
if (!this.value || !this.value.startsWith("random"))
return false;
@@ -39,6 +39,10 @@ GameSettings.prototype.Attributes.TeamPlacement = class TeamPlacement extends Ga
pickRandomItems()
{
// If the map is random, we need to wait until it is selected.
if (this.settings.map.map === "random")
return true;
if (this.value !== "random")
return false;
this.value = pickRandom(this.available).Id;