From f01806772ff3aff27eae40880a6a2af28db800ea Mon Sep 17 00:00:00 2001 From: quantumstate Date: Wed, 2 May 2012 19:50:48 +0000 Subject: [PATCH] Fixed changes from [11719] for case where ent is not set. Thanks to leper. This was SVN commit r11723. --- .../data/mods/public/simulation/ai/qbot/economy.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/binaries/data/mods/public/simulation/ai/qbot/economy.js b/binaries/data/mods/public/simulation/ai/qbot/economy.js index de20ea9862..659ec71657 100644 --- a/binaries/data/mods/public/simulation/ai/qbot/economy.js +++ b/binaries/data/mods/public/simulation/ai/qbot/economy.js @@ -233,10 +233,9 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events){ if (e.type === "Destroy") { if (e.msg.entityObj){ var ent = e.msg.entityObj; - var pos = ent.position(); - if (ent && pos && ent.resourceSupplyType() && ent.resourceSupplyType().generic === resource){ - var x = Math.round(pos[0] / gameState.cellSize); - var z = Math.round(pos[1] / gameState.cellSize); + if (ent && ent.position() && ent.resourceSupplyType() && ent.resourceSupplyType().generic === resource){ + var x = Math.round(ent.position()[0] / gameState.cellSize); + var z = Math.round(ent.position()[1] / gameState.cellSize); var strength = Math.round(ent.resourceSupplyMax()/decreaseFactor[resource]); this.resourceMaps[resource].addInfluence(x, z, radius[resource], -strength); } @@ -244,10 +243,9 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events){ }else if (e.type === "Create") { if (e.msg.entityObj){ var ent = e.msg.entityObj; - var pos = ent.position(); - if (ent && pos && ent.resourceSupplyType() && ent.resourceSupplyType().generic === resource){ - var x = Math.round(pos[0] / gameState.cellSize); - var z = Math.round(pos[1] / gameState.cellSize); + if (ent && ent.position() && ent.resourceSupplyType() && ent.resourceSupplyType().generic === resource){ + var x = Math.round(ent.position()[0] / gameState.cellSize); + var z = Math.round(ent.position()[1] / gameState.cellSize); var strength = Math.round(ent.resourceSupplyMax()/decreaseFactor[resource]); this.resourceMaps[resource].addInfluence(x, z, radius[resource], strength); }