forked from mirrors/0ad
Read correctly 0/false values from map files in gamesetup
After 34138a7764, if map specifies 0 as value in certain settings, this
value is ignored.
Fixing that by explicitly checking for undefined.
Differential Revision: D2982
Reviewed by: Freagarach
This was SVN commit r24037.
This commit is contained in:
+4
-3
@@ -2,10 +2,11 @@ GameSettingControls.ExploredMap = class extends GameSettingControlCheckbox
|
||||
{
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.ExploreMap || undefined;
|
||||
mapData.settings.ExploreMap !== undefined)
|
||||
mapValue = mapData.settings.ExploreMap;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.ExploreMap)
|
||||
{
|
||||
|
||||
+5
-4
@@ -2,11 +2,12 @@ GameSettingControls.LastManStanding = class extends GameSettingControlCheckbox
|
||||
{
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
!mapData.settings.LockTeams &&
|
||||
mapData.settings.LastManStanding;
|
||||
mapData.settings.LastManStanding !== undefined)
|
||||
mapValue = !mapData.settings.LockTeams &&
|
||||
mapData.settings.LastManStanding;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.LastManStanding)
|
||||
{
|
||||
|
||||
+5
-4
@@ -2,11 +2,12 @@ GameSettingControls.LockedTeams = class extends GameSettingControlCheckbox
|
||||
{
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
!mapData.settings.LockTeams &&
|
||||
mapData.settings.LastManStanding;
|
||||
mapData.settings.LockTeams !== undefined)
|
||||
mapValue = !mapData.settings.LockTeams &&
|
||||
mapData.settings.LastManStanding;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.LastManStanding)
|
||||
{
|
||||
|
||||
+4
-3
@@ -7,10 +7,11 @@ GameSettingControls.Nomad = class extends GameSettingControlCheckbox
|
||||
if (!available)
|
||||
return;
|
||||
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.Nomad;
|
||||
mapData.settings.Nomad !== undefined)
|
||||
mapValue = mapData.settings.Nomad;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.Nomad)
|
||||
{
|
||||
|
||||
+4
-3
@@ -4,12 +4,13 @@ GameSettingControls.RegicideGarrison = class extends GameSettingControlCheckbox
|
||||
{
|
||||
this.setEnabled(g_GameAttributes.mapType != "scenario");
|
||||
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.VictoryConditions &&
|
||||
mapData.settings.VictoryConditions.indexOf(this.RegicideName) != -1 &&
|
||||
mapData.settings.RegicideGarrison;
|
||||
mapData.settings.RegicideGarrison !== undefined)
|
||||
mapValue = mapData.settings.RegicideGarrison;
|
||||
|
||||
if (mapValue !== undefined || !g_GameAttributes.settings || mapValue == g_GameAttributes.settings.RegicideGarrison)
|
||||
return;
|
||||
|
||||
+4
-3
@@ -2,10 +2,11 @@ GameSettingControls.RevealedMap = class extends GameSettingControlCheckbox
|
||||
{
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.RevealMap || undefined;
|
||||
mapData.settings.RevealMap !== undefined)
|
||||
mapValue = mapData.settings.RevealMap;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.RevealMap)
|
||||
{
|
||||
|
||||
+4
-3
@@ -2,10 +2,11 @@ GameSettingControls.Spies = class extends GameSettingControlCheckbox
|
||||
{
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.DisableSpies;
|
||||
mapData.settings.DisableSpies !== undefined)
|
||||
mapValue = mapData.settings.DisableSpies;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.DisableSpies)
|
||||
{
|
||||
|
||||
+4
-3
@@ -2,10 +2,11 @@ GameSettingControls.Treasures = class extends GameSettingControlCheckbox
|
||||
{
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.DisableTreasures;
|
||||
mapData.settings.DisableTreasures !== undefined)
|
||||
mapValue = mapData.settings.DisableTreasures;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.DisableTreasures)
|
||||
{
|
||||
|
||||
+4
-3
@@ -2,10 +2,11 @@ GameSettingControls.WorldPopulation = class extends GameSettingControlCheckbox
|
||||
{
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.WorldPopulation || undefined;
|
||||
mapData.settings.WorldPopulation !== undefined)
|
||||
mapValue = mapData.settings.WorldPopulation;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.WorldPopulation)
|
||||
{
|
||||
|
||||
+3
-1
@@ -9,7 +9,9 @@ GameSettingControls.GameSpeed = class extends GameSettingControlDropdown
|
||||
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue = mapData && mapData.gameSpeed || undefined;
|
||||
let mapValue;
|
||||
if (mapData && mapData.gameSpeed !== undefined)
|
||||
mapValue = mapData.gameSpeed;
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.gameSpeed)
|
||||
{
|
||||
g_GameAttributes.gameSpeed = mapValue;
|
||||
|
||||
+4
-3
@@ -17,10 +17,11 @@ GameSettingControls.MapSize = class extends GameSettingControlDropdown
|
||||
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.Size || undefined;
|
||||
mapData.settings.Size !== undefined)
|
||||
mapValue = mapData.settings.Size;
|
||||
|
||||
if (g_GameAttributes.mapType == "random" && mapValue !== undefined && mapValue != g_GameAttributes.settings.Size)
|
||||
{
|
||||
|
||||
+4
-3
@@ -14,10 +14,11 @@ GameSettingControls.PopulationCap = class extends GameSettingControlDropdown
|
||||
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.PopulationCap || undefined;
|
||||
mapData.settings.PopulationCap !== undefined)
|
||||
mapValue = mapData.settings.PopulationCap;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.PopulationCap)
|
||||
{
|
||||
|
||||
+4
-3
@@ -24,10 +24,11 @@ GameSettingControls.StartingResources = class extends GameSettingControlDropdown
|
||||
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.StartingResources || undefined;
|
||||
mapData.settings.StartingResources !== undefined)
|
||||
mapValue = mapData.settings.StartingResources;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.StartingResources)
|
||||
{
|
||||
|
||||
+4
-3
@@ -12,10 +12,11 @@ GameSettingControls.WorldPopulationCap = class extends GameSettingControlDropdow
|
||||
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.WorldPopulationCap || undefined;
|
||||
mapData.settings.WorldPopulationCap !== undefined)
|
||||
mapValue = mapData.settings.WorldPopulationCap;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.WorldPopulationCap)
|
||||
{
|
||||
|
||||
+4
-3
@@ -9,10 +9,11 @@ GameSettingControls.Ceasefire = class extends GameSettingControlSlider
|
||||
|
||||
onMapChange(mapData)
|
||||
{
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.Ceasefire || undefined;
|
||||
mapData.settings.Ceasefire !== undefined)
|
||||
mapValue = mapData.settings.Ceasefire;
|
||||
|
||||
if (mapValue !== undefined && mapValue != g_GameAttributes.settings.Ceasefire)
|
||||
{
|
||||
|
||||
+4
-3
@@ -12,12 +12,13 @@ GameSettingControls.RelicCount = class extends GameSettingControlSlider
|
||||
{
|
||||
this.setEnabled(g_GameAttributes.mapType != "scenario");
|
||||
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.VictoryConditions &&
|
||||
mapData.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) != -1 &&
|
||||
mapData.settings.RelicCount || undefined;
|
||||
mapData.settings.RelicCount !== undefined)
|
||||
mapValue = mapData.settings.RelicCount;
|
||||
|
||||
if (mapValue === undefined || mapValue == g_GameAttributes.settings.RelicCount)
|
||||
return;
|
||||
|
||||
+4
-3
@@ -12,12 +12,13 @@ GameSettingControls.RelicDuration = class extends GameSettingControlSlider
|
||||
{
|
||||
this.setEnabled(g_GameAttributes.mapType != "scenario");
|
||||
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.VictoryConditions &&
|
||||
mapData.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) != -1 &&
|
||||
mapData.settings.RelicDuration || undefined;
|
||||
mapData.settings.RelicDuration !== undefined)
|
||||
mapValue = mapData.settings.RelicDuration;
|
||||
|
||||
if (mapValue === undefined || mapValue == g_GameAttributes.settings.RelicDuration)
|
||||
return;
|
||||
|
||||
+4
-3
@@ -12,12 +12,13 @@ GameSettingControls.WonderDuration = class extends GameSettingControlSlider
|
||||
{
|
||||
this.setEnabled(g_GameAttributes.mapType != "scenario");
|
||||
|
||||
let mapValue =
|
||||
mapData &&
|
||||
let mapValue;
|
||||
if (mapData &&
|
||||
mapData.settings &&
|
||||
mapData.settings.VictoryConditions &&
|
||||
mapData.settings.VictoryConditions.indexOf(this.NameWonderVictory) != -1 &&
|
||||
mapData.settings.WonderDuration || undefined;
|
||||
mapData.settings.WonderDuration !== undefined)
|
||||
mapValue = mapData.settings.WonderDuration;
|
||||
|
||||
if (mapValue === undefined || mapValue == g_GameAttributes.settings.WonderDuration)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user