From e7e218a3bc3621e5e835f3e868fbc57250d91caf Mon Sep 17 00:00:00 2001 From: wraitii Date: Wed, 10 Feb 2021 19:23:39 +0000 Subject: [PATCH] Fix no-formation orders after several formation orders. When giving several queued formation-walk orders, then a queued non-formation order (such as gathering), the gather order would be silently dropped. This did not happen if only one formation-walk order was given, which is why this issue was not noticed in 59d0885d68 To fix it, explicitly only drop pre-"leave formation" orders in the queue for formation members. Reported By: faction02 Differential Revision: https://code.wildfiregames.com/D3550 This was SVN commit r24869. --- .../data/mods/public/simulation/components/UnitAI.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 36e5b03aa1..bdbf0f08e6 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -4166,6 +4166,17 @@ UnitAI.prototype.ReplaceOrder = function(type, data) else this.orderQueue = [packingOrder, order]; } + else if (this.IsFormationMember()) + { + // Don't replace orders after a LeaveFormation order + // (this is needed to support queued no-formation orders). + let idx = this.orderQueue.findIndex(o => o.type == "LeaveFormation"); + if (idx === -1) + this.orderQueue = []; + else + this.orderQueue.splice(0, idx); + this.PushOrderFront(type, data); + } else { this.orderQueue = [];