1
0
forked from 0ad/0ad

prevent error when an animal changes ownership

This was SVN commit r14720.
This commit is contained in:
mimo 2014-02-01 17:55:27 +00:00
parent 94a240737c
commit e21f052803

View File

@ -3202,8 +3202,10 @@ UnitAI.prototype.OnOwnershipChanged = function(msg)
// If the unit isn't being created or dying, reset stance and clear orders (if not garrisoned). // If the unit isn't being created or dying, reset stance and clear orders (if not garrisoned).
if (msg.to != -1 && msg.from != -1) if (msg.to != -1 && msg.from != -1)
{ {
// Switch to an empty state to let states execute their leave handlers. // Switch to a virgin state to let states execute their leave handlers.
UnitFsm.SwitchToNextState(this, ""); var index = this.GetCurrentState().indexOf(".");
if (index != -1)
UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index));
this.SetStance(this.template.DefaultStance); this.SetStance(this.template.DefaultStance);
if(!this.isGarrisoned) if(!this.isGarrisoned)