Ticket #3430: ticket3430.patch

File ticket3430.patch, 1.3 KB (added by mimo, 9 years ago)
  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    23402340
    23412341                    // If hunting, try to go to the initial herd position to see if we are more lucky
    23422342                    if (herdPos)
     2343                    {
    23432344                        this.GatherNearPosition(herdPos.x, herdPos.z, resourceType, resourceTemplate);
     2345                        return;
     2346                    }
    23442347
    23452348                    // Nothing else to gather - if we're carrying anything then we should
    23462349                    // drop it off, and if not then we might as well head to the dropsite
     
    35303533    }
    35313534    else
    35323535    {
    3533         this.SetNextState("IDLE");
     3536        // We must switch to the idle state immediately (and not do a simple SetNextState)
     3537        // otherwise we may be in a weird state if a ProcessMessage is triggered (by a MoveStarted
     3538        // or MoveCompleted) when starting a new order and before we have set our new state.
     3539        let index = this.GetCurrentState().indexOf(".");
     3540        if (index != -1)
     3541            this.UnitFsm.SwitchToNextState(this, this.GetCurrentState().slice(0,index+1) + "IDLE");
     3542        else
     3543            this.SetNextState("IDLE");  // should never happen
    35343544
    35353545        Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() });
    35363546