1
0
forked from mirrors/0ad

Fix AI+Player from persistent settings (again)

Reintroduced in fa3b341b57, as I changed the execution order of onLoad.

This fixes the problem by explicitly handling this case, which should
avoid accidentally reintroducing the problem.

Differential Revision: https://code.wildfiregames.com/D3724
This was SVN commit r25103.
This commit is contained in:
wraitii
2021-03-22 16:57:10 +00:00
parent c87229aa48
commit a048271806
2 changed files with 8 additions and 0 deletions
@@ -74,7 +74,14 @@ class GameSettingsController
{
let settings = this.persistentMatchSettings.loadFile();
if (settings)
{
this.parseSettings(settings);
// If the new settings led to AI & players conflict, remove the AI.
for (let guid in g_PlayerAssignments)
if (g_PlayerAssignments[guid].player !== -1 &&
g_GameSettings.playerAI.get(g_PlayerAssignments[guid].player - 1))
g_GameSettings.playerAI.set(g_PlayerAssignments[guid].player - 1, undefined);
}
}
this.updateLayout();
@@ -70,6 +70,7 @@ PlayerSettingControls.PlayerAssignment = class PlayerAssignment extends GameSett
if (this.assignedGUID === newGUID)
return;
this.assignedGUID = newGUID;
// Remove the AI from the slot if there was one.
if (this.assignedGUID && g_GameSettings.playerAI.get(this.playerIndex))
{
g_GameSettings.playerAI.setAI(this.playerIndex, undefined);