diff --git a/binaries/data/mods/public/simulation/ai/petra/attackManager.js b/binaries/data/mods/public/simulation/ai/petra/attackManager.js index 9fe8c446cd..4cc699ad23 100644 --- a/binaries/data/mods/public/simulation/ai/petra/attackManager.js +++ b/binaries/data/mods/public/simulation/ai/petra/attackManager.js @@ -165,11 +165,14 @@ 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 (this.Config.debug > 0) - warn("Headquarters: Rushing plan " + this.totalNumber + " with maxRushes " + this.maxRushes); - this.rushNumber++; - this.totalNumber++; - this.upcomingAttacks["Rush"].push(attackPlan); + if (!attackPlan.failed) + { + if (this.Config.debug > 0) + warn("Headquarters: Rushing plan " + this.totalNumber + " with maxRushes " + this.maxRushes); + this.rushNumber++; + this.totalNumber++; + 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. @@ -215,11 +218,14 @@ 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 (this.Config.debug > 0) - warn("Headquarters: Raiding plan " + this.totalNumber); - this.raidNumber++; - this.totalNumber++; - this.upcomingAttacks["Raid"].push(attackPlan); + if (!attackPlan.failed) + { + if (this.Config.debug > 0) + warn("Headquarters: Raiding plan " + this.totalNumber); + this.raidNumber++; + this.totalNumber++; + this.upcomingAttacks["Raid"].push(attackPlan); + } } } } diff --git a/binaries/data/mods/public/simulation/ai/petra/attackPlan.js b/binaries/data/mods/public/simulation/ai/petra/attackPlan.js index 6d231fc4b6..b73672034b 100644 --- a/binaries/data/mods/public/simulation/ai/petra/attackPlan.js +++ b/binaries/data/mods/public/simulation/ai/petra/attackPlan.js @@ -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; }