1
0
forked from 0ad/0ad

Stop rearranging formations for orders carried out individually. Fixes #1476.

This was SVN commit r11934.
This commit is contained in:
leper 2012-06-03 23:00:36 +00:00
parent da719b883c
commit 4ee4f16793
2 changed files with 17 additions and 0 deletions

View File

@ -10,6 +10,7 @@ Formation.prototype.Init = function()
this.members = []; // entity IDs currently belonging to this formation
this.columnar = false; // whether we're travelling in column (vs box) formation
this.formationName = "Line Closed";
this.rearrange = true; // whether we should rearrange all formation members
};
Formation.prototype.GetMemberCount = function()
@ -29,6 +30,15 @@ Formation.prototype.GetPrimaryMember = function()
return this.members[0];
};
/**
* Set whether we should rearrange formation members if
* units are removed from the formation.
*/
Formation.prototype.SetRearrange = function(rearrange)
{
this.rearrange = rearrange;
};
/**
* Initialise the members of this formation.
* Must only be called once.
@ -71,6 +81,9 @@ Formation.prototype.RemoveMembers = function(ents)
return;
}
if (!this.rearrange)
return;
this.ComputeMotionParameters();
// Rearrange the remaining members

View File

@ -493,6 +493,9 @@ var UnitFsmSpec = {
}
var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
// We don't want to rearrange the formation if the individual units are carrying
// out a task and one of the members dies/leaves the formation.
cmpFormation.SetRearrange(false);
cmpFormation.CallMemberFunction("Repair", [msg.data.target, msg.data.autocontinue, false]);
this.SetNextState("REPAIR");
@ -532,6 +535,7 @@ var UnitFsmSpec = {
"WALKING": {
"MoveStarted": function(msg) {
var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
cmpFormation.SetRearrange(true);
cmpFormation.MoveMembersIntoFormation(true);
},