From 674cdae166a56897af173954fc308524fcb770d1 Mon Sep 17 00:00:00 2001 From: wraitii Date: Sat, 13 Feb 2021 10:08:10 +0000 Subject: [PATCH] Fix issues with formation + packing. - e7e218a3bc contained a small mistake: this.order wasn't cleared when clearing the orderqueue, which led to a broken codepath in PushOrderFront. - Since 71a61d5f50, formation orders their members to reform in IDLE. This will automatically pack any unpacked siege. Reported by: langbart Tested by: langbart Fixes #6018 Differential Revision: https://code.wildfiregames.com/D3561 This was SVN commit r24895. --- .../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 bdbf0f08e6..e9345a5381 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -231,6 +231,14 @@ UnitAI.prototype.UnitFsmSpec = { if (this.CanPack()) { + // If the controller is IDLE, this is just the regular reformation timer. + // In that case we don't actually want to move, as that would unpack us. + let cmpControllerAI = Engine.QueryInterface(this.GetFormationController(), IID_UnitAI); + if (cmpControllerAI.IsIdle()) + { + this.FinishOrder(); + return; + } this.PushOrderFront("Pack", { "force": true }); return; } @@ -4172,7 +4180,10 @@ UnitAI.prototype.ReplaceOrder = function(type, data) // (this is needed to support queued no-formation orders). let idx = this.orderQueue.findIndex(o => o.type == "LeaveFormation"); if (idx === -1) + { this.orderQueue = []; + this.order = undefined; + } else this.orderQueue.splice(0, idx); this.PushOrderFront(type, data);