From 4ef80d26aa9e39728c50dfc8a54e7c80da38d68d Mon Sep 17 00:00:00 2001 From: wraitii Date: Sat, 11 Jan 2014 18:14:13 +0000 Subject: [PATCH] Proper fix for the gatherer count. Fix an AI bug. Thanks to Gameboy and Gildas for reporting. This was SVN commit r14571. --- binaries/data/mods/public/gui/session/selection_details.js | 4 ++-- .../data/mods/public/simulation/ai/aegis/defence-helper.js | 2 +- .../mods/public/simulation/components/ResourceSupply.js | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/binaries/data/mods/public/gui/session/selection_details.js b/binaries/data/mods/public/gui/session/selection_details.js index ce5345975e..2820782bf9 100644 --- a/binaries/data/mods/public/gui/session/selection_details.js +++ b/binaries/data/mods/public/gui/session/selection_details.js @@ -158,12 +158,12 @@ function displaySingle(entState, template) Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " "; Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = "Number of builders"; } - else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints)) + else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints) && player !== 0) { Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; - Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.resourceSupply.gatherers[entState.player-1].length + " / " + entState.resourceSupply.maxGatherers + " "; + Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.resourceSupply.gatherers[player-1].length + " / " + entState.resourceSupply.maxGatherers + " "; Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = "Current/max gatherers"; } else diff --git a/binaries/data/mods/public/simulation/ai/aegis/defence-helper.js b/binaries/data/mods/public/simulation/ai/aegis/defence-helper.js index ce756cebd9..382d454188 100755 --- a/binaries/data/mods/public/simulation/ai/aegis/defence-helper.js +++ b/binaries/data/mods/public/simulation/ai/aegis/defence-helper.js @@ -449,7 +449,7 @@ m.Army.prototype.getState = function (gameState) // check if we should remain at state 2 or drift away m.Army.prototype.checkDangerosity = function (gameState) { - this.territoryMap = Map.createTerritoryMap(gameState); + this.territoryMap = m.createTerritoryMap(gameState); // right now we'll check if our position is "enemy" or not. if (this.territoryMap.getOwner(this.position) !== PlayerID) this.state = 1; diff --git a/binaries/data/mods/public/simulation/components/ResourceSupply.js b/binaries/data/mods/public/simulation/components/ResourceSupply.js index 649f2015a5..78852737d2 100644 --- a/binaries/data/mods/public/simulation/components/ResourceSupply.js +++ b/binaries/data/mods/public/simulation/components/ResourceSupply.js @@ -148,10 +148,8 @@ ResourceSupply.prototype.RemoveGatherer = function(gathererID, player) // this can happen if the unit is dead if (player === undefined || player === -1) { - var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); - var numPlayers = cmpPlayerManager.GetNumPlayers(); - for (var i = 0; i < numPlayers; ++i) - this.RemoveGatherer(gathererID, i); + for (var i = 0; i < this.gatherers.length; ++i) + this.RemoveGatherer(gathererID, i+1); } else {