mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
Let states execute their leave handlers on OnDestroy. Fixes #1999. Patch by mimo.
This was SVN commit r13501.
This commit is contained in:
parent
49b3b0ee9a
commit
2fcd52b657
2 changed files with 3 additions and 12 deletions
|
|
@ -2564,18 +2564,9 @@ UnitAI.prototype.OnOwnershipChanged = function(msg)
|
|||
|
||||
UnitAI.prototype.OnDestroy = function()
|
||||
{
|
||||
// Clean up any timers that are now obsolete
|
||||
this.StopTimer();
|
||||
// Switch to an empty state to let states execute their leave handlers.
|
||||
UnitFsm.SwitchToNextState(this, "");
|
||||
|
||||
// clear up the ResourceSupply gatherer count.
|
||||
if (this.gatheringTarget)
|
||||
{
|
||||
var cmpSupply = Engine.QueryInterface(this.gatheringTarget, IID_ResourceSupply);
|
||||
if (cmpSupply)
|
||||
cmpSupply.RemoveGatherer(this.entity);
|
||||
delete this.gatheringTarget;
|
||||
}
|
||||
|
||||
// Clean up range queries
|
||||
var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
if (this.losRangeQuery)
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ FSM.prototype.SwitchToNextState = function(obj, nextStateName)
|
|||
}
|
||||
|
||||
// Check if we should exit and enter the current state due to the reenter parameter. If so we go up 1 level
|
||||
if (obj.fsmReenter && equalPrefix === toState.length)
|
||||
if (obj.fsmReenter && equalPrefix > 0 && equalPrefix === toState.length)
|
||||
--equalPrefix;
|
||||
|
||||
for (var i = fromState.length-1; i >= equalPrefix; --i)
|
||||
|
|
|
|||
Loading…
Reference in a new issue