Ticket #1215: patch2.patch
File patch2.patch, 2.5 KB (added by , 12 years ago) |
---|
-
GuiInterface.js
692 692 GuiInterface.prototype.GetTradingDetails = function(player, data) 693 693 { 694 694 var cmpEntityTrader = Engine.QueryInterface(data.trader, IID_Trader); 695 if (!cmpEntityTrader || !cmpEntityTrader.CanTrade(data.target ))695 if (!cmpEntityTrader || !cmpEntityTrader.CanTrade(data.target, data.targetState)) 696 696 return null; 697 697 var firstMarket = cmpEntityTrader.GetFirstMarket(); 698 698 var secondMarket = cmpEntityTrader.GetSecondMarket(); -
Trader.js
159 159 this.preferredGoods = preferredGoods; 160 160 } 161 161 162 Trader.prototype.CanTrade = function(target )162 Trader.prototype.CanTrade = function(target, targetState) 163 163 { 164 // Check that the target is not a foundation 165 if (targetState.foundation) 166 return false; 164 167 var cmpTraderIdentity = Engine.QueryInterface(this.entity, IID_Identity); 165 168 var cmpTargetIdentity = Engine.QueryInterface(target, IID_Identity); 166 169 // Check that the target exists -
UnitAI.js
2430 2430 this.AddOrder("ReturnResource", { "target": target }, queued); 2431 2431 }; 2432 2432 2433 UnitAI.prototype.SetupTradeRoute = function(target, queued )2433 UnitAI.prototype.SetupTradeRoute = function(target, queued, targetState) 2434 2434 { 2435 if (!this.CanTrade(target ))2435 if (!this.CanTrade(target, targetState)) 2436 2436 { 2437 2437 this.WalkToTarget(target, queued); 2438 2438 return; … … 2468 2468 2469 2469 UnitAI.prototype.PerformTradeAndMoveToNextMarket = function(currentMarket, nextMarket, nextFsmStateName) 2470 2470 { 2471 if (!this.CanTrade(currentMarket ))2471 if (!this.CanTrade(currentMarket, currentMarket)) 2472 2472 { 2473 2473 this.StopTrading(); 2474 2474 return; … … 2724 2724 return true; 2725 2725 }; 2726 2726 2727 UnitAI.prototype.CanTrade = function(target )2727 UnitAI.prototype.CanTrade = function(target, targetState) 2728 2728 { 2729 2729 // Formation controllers should always respond to commands 2730 2730 // (then the individual units can make up their own minds) … … 2733 2733 2734 2734 // Verify that we're able to respond to Trade commands 2735 2735 var cmpTrader = Engine.QueryInterface(this.entity, IID_Trader); 2736 if (!cmpTrader || !cmpTrader.CanTrade(target ))2736 if (!cmpTrader || !cmpTrader.CanTrade(target, targetState)) 2737 2737 return false; 2738 2738 2739 2739 return true;