forked from 0ad/0ad
fix the test when changing markets, fixes #3838
This was SVN commit r17918.
This commit is contained in:
parent
3025b4b8e3
commit
81948477df
@ -75,7 +75,7 @@ Trader.prototype.SetTargetMarket = function(target, source)
|
||||
return false;
|
||||
if (!cmpTargetIdentity.HasClass("Market") && !cmpTargetIdentity.HasClass("NavalMarket"))
|
||||
return false;
|
||||
var marketsChanged = true;
|
||||
|
||||
if (source)
|
||||
{
|
||||
// Establish a trade route with both markets in one go.
|
||||
@ -98,7 +98,7 @@ Trader.prototype.SetTargetMarket = function(target, source)
|
||||
// If we have only one market and target is different from it,
|
||||
// set the target as second one
|
||||
if (target == this.markets[0])
|
||||
marketsChanged = false;
|
||||
return false;
|
||||
else
|
||||
{
|
||||
this.index = 0;
|
||||
@ -113,12 +113,9 @@ Trader.prototype.SetTargetMarket = function(target, source)
|
||||
this.index = 0;
|
||||
this.markets = [target];
|
||||
}
|
||||
if (marketsChanged)
|
||||
{
|
||||
// Drop carried goods
|
||||
this.goods.amount = null;
|
||||
}
|
||||
return marketsChanged;
|
||||
// Drop carried goods if markets were changed
|
||||
this.goods.amount = null;
|
||||
return true;
|
||||
};
|
||||
|
||||
Trader.prototype.GetFirstMarket = function()
|
||||
|
@ -5244,7 +5244,8 @@ UnitAI.prototype.PerformTradeAndMoveToNextMarket = function(currentMarket)
|
||||
|
||||
let cmpTrader = Engine.QueryInterface(this.entity, IID_Trader);
|
||||
cmpTrader.PerformTrade(currentMarket);
|
||||
if (!cmpTrader.GetGoods().amount.traderGain)
|
||||
let amount = cmpTrader.GetGoods().amount;
|
||||
if (!amount || !amount.traderGain)
|
||||
{
|
||||
this.StopTrading();
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user