1
0
forked from 0ad/0ad

Fix error in GATHERING when disbanding formation while members gather.

Since 59d0885d68, there is a "LeaveFormation" order to support
queued-disbanding. However, I misread the code paths and FinishOrder()
isn't always called.
This fixes that oversight.

Reported by: Freagarach
Differential Revision: https://code.wildfiregames.com/D3450
This was SVN commit r24771.
This commit is contained in:
wraitii 2021-01-23 08:07:56 +00:00
parent 7b6ff0745a
commit 8addf36ba8

View File

@ -213,7 +213,12 @@ UnitAI.prototype.UnitFsmSpec = {
// Formation handlers:
"FormationLeave": function(msg) {
// ignore when we're not in FORMATIONMEMBER
// Overloaded by FORMATIONMEMBER
// We end up here if LeaveFormation was called when the entity
// was executing an order in an individual state, so we must
// discard the order now that it has been executed.
if (this.order && this.order.type === "LeaveFormation")
this.FinishOrder();
},
// Called when being told to walk as part of a formation
@ -259,7 +264,8 @@ UnitAI.prototype.UnitFsmSpec = {
if (cmpFormation)
{
cmpFormation.SetRearrange(false);
// Calls FinishOrder();
// Triggers FormationLeave, which ultimately will FinishOrder,
// discarding this order.
cmpFormation.RemoveMembers([this.entity]);
cmpFormation.SetRearrange(true);
}