HomeWildfire Games

Fix segfault from a formation infinite loop.

Description

Fix segfault from a formation infinite loop.

#5932 reported a segfault. The direct cause is an infinite loop in Order.Repair in a formation controller.
There are multiple issues at play here, but the core problem is that the controller has been marked for destruction, but remains alive over the turn and UnitAI timers can fire. This leads to an unexpected state that triggers an infinite loop.

To avoid this problem, immediately switch the formation controller to a clean state when it's being disbanded.

Fixes #5932

Differential Revision: https://code.wildfiregames.com/D3410