From 8addf36ba8ef41e72f3ad8ffafcb547ce29d421d Mon Sep 17 00:00:00 2001 From: wraitii Date: Sat, 23 Jan 2021 08:07:56 +0000 Subject: [PATCH] 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. --- .../data/mods/public/simulation/components/UnitAI.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 5b71f721b0..5081fa7974 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -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); }