Ticket #4291: unitAI_isGarrisoned_broken_v1.patch
File unitAI_isGarrisoned_broken_v1.patch, 5.3 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/session/utility_functions.js
function getTradingTooltip(gain) 110 110 * Returns the entity itself except when garrisoned where it returns its garrisonHolder 111 111 */ 112 112 function getEntityOrHolder(ent) 113 113 { 114 114 var entState = GetEntityState(ent); 115 if (entState && !entState.position && entState.unitAI && entState.unitAI.orders.length && 116 (entState.unitAI.orders[0].type == "Garrison" || entState.unitAI.orders[0].type == "Autogarrison")) 117 return entState.unitAI.orders[0].data.target; 115 if (entState && !entState.position && entState.unitAI) 116 return entState.unitAI.isGarrisoned; 118 117 119 118 return ent; 120 119 } 121 120 122 121 /** -
binaries/data/mods/public/simulation/components/GarrisonHolder.js
GarrisonHolder.prototype.OnGlobalInitGam 736 736 737 737 for (let ent of this.initGarrison) 738 738 { 739 739 let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); 740 740 if (cmpUnitAI && cmpUnitAI.CanGarrison(this.entity) && this.Garrison(ent)) 741 cmpUnitAI.SetGarrisoned( );741 cmpUnitAI.SetGarrisoned(this.entity); 742 742 } 743 743 this.initGarrison = undefined; 744 744 }; 745 745 746 746 Engine.RegisterComponentType(IID_GarrisonHolder, "GarrisonHolder", GarrisonHolder); -
binaries/data/mods/public/simulation/components/GuiInterface.js
GuiInterface.prototype.GetEntityState = 372 372 "hasWorkOrders": cmpUnitAI.HasWorkOrders(), 373 373 "canGuard": cmpUnitAI.CanGuard(), 374 374 "isGuarding": cmpUnitAI.IsGuardOf(), 375 375 "possibleStances": cmpUnitAI.GetPossibleStances(), 376 376 "isIdle":cmpUnitAI.IsIdle(), 377 "isGarrisoned": cmpUnitAI.IsGarrisoned() 377 378 }; 378 379 // Add some information needed for ungarrisoning 379 380 if (cmpUnitAI.IsGarrisoned() && ret.player !== undefined) 380 381 ret.template = "p" + ret.player + "&" + ret.template; 381 382 } -
binaries/data/mods/public/simulation/components/Promotion.js
Promotion.prototype.Promote = function(p 81 81 cmpPromotedUnitAI.SetHeldPosition(pos.x, pos.z); 82 82 if (cmpCurrentUnitAI.GetStanceName()) 83 83 cmpPromotedUnitAI.SwitchToStance(cmpCurrentUnitAI.GetStanceName()); 84 84 85 85 var orders = cmpCurrentUnitAI.GetOrders(); 86 if (cmpCurrentUnitAI.IsGarrisoned())87 cmpPromotedUnitAI.SetGarrisoned(); 86 cmpPromotedUnitAI.SetGarrisoned(cmpCurrentUnitAI.IsGarrisoned()); 87 88 88 if (cmpCurrentUnitPosition.IsInWorld()) // do not cheer if not visibly garrisoned 89 89 cmpPromotedUnitAI.Cheer(); 90 90 cmpPromotedUnitAI.AddOrders(orders); 91 91 92 92 var workOrders = cmpCurrentUnitAI.GetWorkOrders(); -
binaries/data/mods/public/simulation/components/UnitAI.js
UnitAI.prototype.UnitFsmSpec = { 708 708 this.SetNextState("IDLE"); 709 709 return; 710 710 } 711 711 else if (this.IsGarrisoned()) 712 712 { 713 // TODO: when is this called? 714 this.isGarrisoned = msg.data.target; 713 715 this.SetNextState("INDIVIDUAL.AUTOGARRISON"); 714 716 return; 715 717 } 716 718 717 719 // For packable units: … … UnitAI.prototype.UnitFsmSpec = { 741 743 { 742 744 this.SetNextState("IDLE"); 743 745 return; 744 746 } 745 747 748 // TODO: when is this called? 749 this.isGarrisoned = msg.data.target; 750 746 751 this.SetNextState("INDIVIDUAL.AUTOGARRISON"); 747 752 }, 748 753 749 754 "Order.Ungarrison": function() { 750 755 this.FinishOrder(); … … UnitAI.prototype.UnitFsmSpec = { 2997 3002 { 2998 3003 var cmpGarrisonHolder = Engine.QueryInterface(target, IID_GarrisonHolder); 2999 3004 // Check that garrisoning succeeds 3000 3005 if (cmpGarrisonHolder.Garrison(this.entity)) 3001 3006 { 3002 this.isGarrisoned = t rue;3007 this.isGarrisoned = target; 3003 3008 3004 3009 if (this.formationController) 3005 3010 { 3006 3011 var cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); 3007 3012 if (cmpFormation) … … UnitAI.prototype.UnitFsmSpec = { 3078 3083 }, 3079 3084 }, 3080 3085 3081 3086 "AUTOGARRISON": { 3082 3087 "enter": function() { 3083 this.isGarrisoned = true;3084 3088 return false; 3085 3089 }, 3086 3090 3087 3091 "leave": function() { 3088 3092 } … … UnitAI.prototype.IsIdle = function() 3422 3426 UnitAI.prototype.IsGarrisoned = function() 3423 3427 { 3424 3428 return this.isGarrisoned; 3425 3429 }; 3426 3430 3427 UnitAI.prototype.SetGarrisoned = function( )3431 UnitAI.prototype.SetGarrisoned = function(target) 3428 3432 { 3429 this.isGarrisoned = t rue;3433 this.isGarrisoned = target; 3430 3434 }; 3431 3435 3432 3436 UnitAI.prototype.IsFleeing = function() 3433 3437 { 3434 3438 var state = this.GetCurrentState().split(".").pop();