Fix UnitAI infinite loop following a16e7c0a56
As reported by Angen and Gurken Khan on the forums, there is a crash
following a16e7c0a56
caused by an infinite loop in UnitAI. The reason is
that IDLE.enter can order us to attack, which can fail, switching us
right away back to idle.
FinishOrder's behaviour allows us to have IDLE as a default state and
lets us not lose a turn when becoming idle, so to keep this behaviour
explicitely check that we are not already in IDLE before switching
states.
Reported by: Angen, Gurken Khan
Commented by: elexis, Itms
Differential Revision: https://code.wildfiregames.com/D1743
This was SVN commit r22059.
This commit is contained in:
parent
3e66aa093b
commit
8bab09d37c
@ -3536,7 +3536,6 @@ UnitAI.prototype.SetNextState = function(state)
|
||||
this.UnitFsm.SetNextState(this, state);
|
||||
};
|
||||
|
||||
|
||||
UnitAI.prototype.DeferMessage = function(msg)
|
||||
{
|
||||
this.UnitFsm.DeferMessage(this, msg);
|
||||
@ -3592,7 +3591,11 @@ UnitAI.prototype.FinishOrder = function()
|
||||
|
||||
this.orderQueue = [];
|
||||
this.order = undefined;
|
||||
this.SetNextState("IDLE");
|
||||
|
||||
// Switch to IDLE as a default state, but only if our current state is not IDLE
|
||||
// as this can trigger infinite loops by entering IDLE repeatedly.
|
||||
if (!this.GetCurrentState().endsWith(".IDLE"))
|
||||
this.SetNextState("IDLE");
|
||||
|
||||
Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user