From fd14419bc05d33e8371a7939b00a1517507e2204 Mon Sep 17 00:00:00 2001 From: mimo Date: Thu, 22 Feb 2018 18:42:45 +0000 Subject: [PATCH] petra: fix an index access + some cleanup This was SVN commit r21324. --- binaries/data/mods/public/simulation/ai/petra/headquarters.js | 4 ++-- binaries/data/mods/public/simulation/ai/petra/worker.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/binaries/data/mods/public/simulation/ai/petra/headquarters.js b/binaries/data/mods/public/simulation/ai/petra/headquarters.js index 00d8f84772..13a9f76a2e 100644 --- a/binaries/data/mods/public/simulation/ai/petra/headquarters.js +++ b/binaries/data/mods/public/simulation/ai/petra/headquarters.js @@ -753,7 +753,7 @@ m.HQ.prototype.bulkPickWorkers = function(gameState, baseRef, number) if (!accessIndex) return false; // sorting bases by whether they are on the same accessindex or not. - let baseBest = this.baseManagers.slice().sort(function (a,b) { + let baseBest = this.baseManagers.slice().sort((a,b) => { if (a.accessIndex == accessIndex && b.accessIndex != accessIndex) return -1; else if (b.accessIndex == accessIndex && a.accessIndex != accessIndex) @@ -765,7 +765,7 @@ m.HQ.prototype.bulkPickWorkers = function(gameState, baseRef, number) let workers = new API3.EntityCollection(gameState.sharedScript); for (let base of baseBest) { - if (base.ID === baseRef.ID) + if (base.ID == baseRef.ID) continue; base.pickBuilders(gameState, workers, needed); if (workers.length < number) diff --git a/binaries/data/mods/public/simulation/ai/petra/worker.js b/binaries/data/mods/public/simulation/ai/petra/worker.js index 63136cf6e6..09fac0c281 100644 --- a/binaries/data/mods/public/simulation/ai/petra/worker.js +++ b/binaries/data/mods/public/simulation/ai/petra/worker.js @@ -576,7 +576,7 @@ m.Worker.prototype.startGathering = function(gameState) // Try to help building one if any accessible foundation available let foundations = gameState.getOwnFoundations().toEntityArray(); let shouldBuild = this.ent.isBuilder() && foundations.some(function(foundation) { - if (!foundation || foundation.getMetadata(PlayerID, "access") !== access) + if (!foundation || m.getLandAccess(gameState, foundation) != access) return false; let structure = gameState.getBuiltTemplate(foundation.templateName()); if (structure.resourceDropsiteTypes() && structure.resourceDropsiteTypes().indexOf(resource) !== -1)