fixes petra javascript warnings

This was SVN commit r15543.
This commit is contained in:
mimo 2014-07-21 16:19:59 +00:00
parent a9048fa43d
commit 9d505f2fd1

View File

@ -1404,21 +1404,24 @@ m.AttackPlan.prototype.Abort = function(gameState)
{
// Do not use QuickIter with forEach when forEach removes elements
this.unitCollection.preventQuickIter();
// If the attack was started, and we are on the same land as the rallyPoint, go back there
var rallyPoint = this.rallyPoint;
var planIndex = gameState.ai.accessibility.getAccessValue(this.position);
var withdrawal = (this.isStarted() && !this.overseas);
this.unitCollection.forEach(function(ent) {
ent.stopMoving();
if (withdrawal)
ent.move(rallyPoint[0], rallyPoint[1]);
if (ent.hasClass("CitizenSoldier") && ent.getMetadata(PlayerID, "role") !== "worker")
{
ent.setMetadata(PlayerID, "role", "worker");
ent.setMetadata(PlayerID, "subrole", undefined);
}
ent.setMetadata(PlayerID, "plan", -1);
});
if (this.unitCollection.length)
{
// If the attack was started, and we are on the same land as the rallyPoint, go back there
var rallyPoint = this.rallyPoint;
var planIndex = gameState.ai.accessibility.getAccessValue(this.position);
var withdrawal = (this.isStarted() && !this.overseas);
this.unitCollection.forEach(function(ent) {
ent.stopMoving();
if (withdrawal)
ent.move(rallyPoint[0], rallyPoint[1]);
if (ent.hasClass("CitizenSoldier") && ent.getMetadata(PlayerID, "role") !== "worker")
{
ent.setMetadata(PlayerID, "role", "worker");
ent.setMetadata(PlayerID, "subrole", undefined);
}
ent.setMetadata(PlayerID, "plan", -1);
});
}
for (var unitCat in this.unitStat) {
delete this.unitStat[unitCat];