Ticket #2353: work_orders_under_alert.3.patch

File work_orders_under_alert.3.patch, 2.2 KB (added by Itms, 10 years ago)
  • binaries/data/mods/public/simulation/components/GarrisonHolder.js

     
    247247    Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added" : [entity], "removed": [] });
    248248   
    249249    var cmpUnitAI = Engine.QueryInterface(entity, IID_UnitAI);
    250     if (cmpUnitAI && cmpUnitAI.GetAlertRaiser())
     250    if (cmpUnitAI && cmpUnitAI.IsUnderAlert())
    251251        Engine.PostMessage(cmpUnitAI.GetAlertRaiser(), MT_UnitGarrisonedAfterAlert, {"holder": this.entity, "unit": entity});
    252252   
    253253    return true;
  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    30673067
    30683068UnitAI.prototype.IsUnderAlert = function()
    30693069{
    3070     return this.alertGarrisoningTarget != undefined;
     3070    return this.alertRaiser != undefined;
    30713071};
    30723072
    30733073UnitAI.prototype.ResetAlert = function()
    30743074{
    30753075    this.alertGarrisoningTarget = undefined;
     3076    this.alertRaiser = undefined;
    30763077};
    30773078
     3079UnitAI.prototype.GetAlertRaiser = function()
     3080{
     3081    return this.alertRaiser;
     3082};
     3083
    30783084UnitAI.prototype.IsFormationController = function()
    30793085{
    30803086    return (this.template.FormationController == "true");
     
    35703576
    35713577UnitAI.prototype.UpdateWorkOrders = function(type)
    35723578{
     3579    // Under alert, remembered work orders won't be forgotten
     3580    if (this.IsUnderAlert())
     3581        return;
     3582   
    35733583    var isWorkType = function(type){
    35743584        return (type == "Gather" || type == "Trade" || type == "Repair" || type == "ReturnResource");
    35753585    };
    35763586   
    3577     // If we are being reaffected to a work order, forgot the previous ones
     3587    // If we are being re-affected to a work order, forget the previous ones
    35783588    if (isWorkType(type))
    35793589    {
    35803590        this.workOrders = [];
     
    36563666    this.workOrders = orders;
    36573667};
    36583668
    3659 UnitAI.prototype.GetAlertRaiser = function()
    3660 {
    3661     return this.alertRaiser;
    3662 };
    3663 
    36643669UnitAI.prototype.TimerHandler = function(data, lateness)
    36653670{
    36663671    // Reset the timer