1
0
forked from mirrors/0ad

Fix handling of fixed ai defined by map after 5ca68a38ef

Gamesetup fails to handle cases with fixed ai 5ca68a38ef.
Removing wrong 'this' and checking for 'undefined' to fix additional
warnings when switching maps.

Differential Revision: D3038
Fixes: #5844

This was SVN commit r24109.
This commit is contained in:
Angen
2020-10-24 12:11:24 +00:00
parent ba1bd070bc
commit a7b4d42032
3 changed files with 9 additions and 5 deletions
@@ -28,7 +28,7 @@ AIGameSettingControls.AIBehavior = class extends AIGameSettingControlDropdown
mapPData && mapPData.AI ?
(mapPData.AIBehavior !== undefined ?
mapPData.AIBehavior :
g_Settings.PlayerDefaults[this.playerIndex + 1].AIBehavior) :
g_Settings.PlayerDefaults[playerIndex + 1].AIBehavior) :
undefined;
}
}
@@ -41,7 +41,9 @@ AIGameSettingControls.AIBehavior = class extends AIGameSettingControlDropdown
if (pData.AI)
{
if (this.fixedAIBehavior[playerIndex] && pData.AIBehavior !== this.fixedAIBehavior[playerIndex])
if (this.fixedAIBehavior[playerIndex] &&
(pData.AIBehavior === undefined ||
pData.AIBehavior !== this.fixedAIBehavior[playerIndex]))
{
pData.AIBehavior = this.fixedAIBehavior[playerIndex];
this.gameSettingsControl.updateGameAttributes();
@@ -28,7 +28,7 @@ AIGameSettingControls.AIDifficulty = class extends AIGameSettingControlDropdown
mapPData && mapPData.AI ?
(mapPData.AIDiff !== undefined ?
mapPData.AIDiff :
g_Settings.PlayerDefaults[this.playerIndex + 1].AIDiff) :
g_Settings.PlayerDefaults[playerIndex + 1].AIDiff) :
undefined;
}
}
@@ -41,7 +41,9 @@ AIGameSettingControls.AIDifficulty = class extends AIGameSettingControlDropdown
if (pData.AI)
{
if (this.fixedAIDiff[playerIndex] !== undefined && pData.AIDiff !== this.fixedAIDiff[playerIndex])
if (this.fixedAIDiff[playerIndex] !== undefined &&
(pData.AIDiff === undefined ||
pData.AIDiff !== this.fixedAIDiff[playerIndex]))
{
pData.AIDiff = this.fixedAIDiff[playerIndex];
this.gameSettingsControl.updateGameAttributes();
@@ -93,7 +93,7 @@ PlayerSettingControls.PlayerAssignment = class extends GameSettingControlDropdow
if (!pData)
return;
if (this.fixedAI && pData.AI != this.fixedAI)
if (this.fixedAI && (pData.AI === undefined || pData.AI != this.fixedAI))
{
pData.AI = this.fixedAI;
this.gameSettingsControl.updateGameAttributes();