fixes Petra trying to keep going with a canceled attack

This was SVN commit r15092.
This commit is contained in:
mimo 2014-05-02 11:03:24 +00:00
parent 15f56cd984
commit b8e9bae75e
2 changed files with 18 additions and 15 deletions

View File

@ -165,6 +165,8 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
{
// we have a barracks and we want to rush, rush.
var attackPlan = new m.AttackPlan(gameState, this.Config, this.totalNumber, "Rush");
if (!attackPlan.failed)
{
if (this.Config.debug > 0)
warn("Headquarters: Rushing plan " + this.totalNumber + " with maxRushes " + this.maxRushes);
this.rushNumber++;
@ -172,6 +174,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
this.upcomingAttacks["Rush"].push(attackPlan);
}
}
}
// if we have a barracks, there's no water, we're at age >= 1 and we've decided to attack.
else if (gameState.countEntitiesByType(gameState.applyCiv("structures/{civ}_barracks"), true) >= 1
&& (this.startedAttacks["Attack"].length + this.startedAttacks["HugeAttack"].length < Math.round(gameState.getPopulationMax()/100))
@ -215,6 +218,8 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
{
// prepare a raid against this target
var attackPlan = new m.AttackPlan(gameState, this.Config, this.totalNumber, "Raid", target.owner(), target);
if (!attackPlan.failed)
{
if (this.Config.debug > 0)
warn("Headquarters: Raiding plan " + this.totalNumber);
this.raidNumber++;
@ -223,6 +228,7 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
}
}
}
}
};
m.AttackManager.prototype.pausePlan = function(gameState, planName)

View File

@ -358,12 +358,9 @@ m.AttackPlan.prototype.updatePreparation = function(gameState, events)
// We still have time left to recruit units and do stuffs.
this.trainMoreUnits(gameState);
Engine.ProfileStop();
// can happen for now ?? really ?? should have been fixed now
// may happen if we have no more training facilities and build orders are canceled
if (this.buildOrder.length === 0)
{
warn("Should never happen plan incomplete but no more buildOrder ???");
return 0; // will abort the plan, should return something else
}
return 0; // will abort the plan
return 1;
}