Fixed changes from [11719] for case where ent is not set. Thanks to leper.
This was SVN commit r11723.
This commit is contained in:
parent
303191b0ad
commit
f01806772f
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user