1
0
forked from 0ad/0ad

Added check for the existence of a resource somewhere on the map

This was SVN commit r10742.
This commit is contained in:
Jonathan Waller 2011-12-16 10:46:20 +00:00
parent 81372522f3
commit 78d50b4149

View File

@ -287,12 +287,14 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events){
this.resourceMaps[resource] = new Map(gameState); this.resourceMaps[resource] = new Map(gameState);
var supplies = gameState.findResourceSupplies(); var supplies = gameState.findResourceSupplies();
for (var i in supplies[resource]){ if (supplies[resource]){
var current = supplies[resource][i]; for (var i in supplies[resource]){
var x = Math.round(current.position[0] / gameState.cellSize); var current = supplies[resource][i];
var z = Math.round(current.position[1] / gameState.cellSize); var x = Math.round(current.position[0] / gameState.cellSize);
var strength = Math.round(current.entity.resourceSupplyMax()/decreaseFactor[resource]); var z = Math.round(current.position[1] / gameState.cellSize);
this.resourceMaps[resource].addInfluence(x, z, radius[resource], strength); var strength = Math.round(current.entity.resourceSupplyMax()/decreaseFactor[resource]);
this.resourceMaps[resource].addInfluence(x, z, radius[resource], strength);
}
} }
} }
// Look for destroy events and subtract the entities original influence from the resourceMap // Look for destroy events and subtract the entities original influence from the resourceMap