Index: binaries/data/mods/public/simulation/components/Market.js
===================================================================
--- binaries/data/mods/public/simulation/components/Market.js	(révision 18106)
+++ binaries/data/mods/public/simulation/components/Market.js	(copie de travail)
@@ -8,10 +8,13 @@ Market.prototype.Schema =
 					"<value>land</value>" +
 					"<value>naval</value>" +
 				"</choice>" +
 			"</oneOrMore>" +
 		"</list>" +
+	"</element>" +
+	"<element name='InternationalBonus' a:help='Additional part of the gain donated when two different players trade'>" +
+		"<ref name='nonNegativeDecimal'/>" +
 	"</element>";
 
 Market.prototype.Init = function()
 {
 	this.traders = new Set();	// list of traders with a route on this market
@@ -26,10 +29,15 @@ Market.prototype.AddTrader = function(en
 Market.prototype.RemoveTrader = function(ent)
 {
 	this.traders.delete(ent);
 };
 
+Market.prototype.GetInternationalBonus = function()
+{
+	return ApplyValueModificationsToEntity("Market/InternationalBonus", +this.template.InternationalBonus, this.entity);
+}
+
 Market.prototype.HasType = function(type)
 {
 	return this.tradeType.has(type);
 };
 
Index: binaries/data/mods/public/simulation/components/Trader.js
===================================================================
--- binaries/data/mods/public/simulation/components/Trader.js	(révision 18106)
+++ binaries/data/mods/public/simulation/components/Trader.js	(copie de travail)
@@ -10,14 +10,13 @@ const RESOURCES = ["food", "wood", "ston
 function Trader() {}
 
 Trader.prototype.Schema =
 	"<a:help>Lets the unit generate resouces while moving between markets (or docks in case of water trading).</a:help>" +
 	"<a:example>" +
-		"<MaxDistance>2.0</MaxDistance>" +
-		"<GainMultiplier>1.0</GainMultiplier>" +
+		"<GainMultiplier>0.75</GainMultiplier>" +
 	"</a:example>" +
-	"<element name='GainMultiplier' a:help='Additional gain multiplier'>" +
+	"<element name='GainMultiplier' a:help='Trader gain for a 100m distance'>" +
 		"<ref name='positiveDecimal'/>" +
 	"</element>";
 
 Trader.prototype.Init = function()
 {
@@ -131,10 +130,15 @@ Trader.prototype.GetFirstMarket = functi
 Trader.prototype.GetSecondMarket = function()
 {
 	return this.markets[1] || null;
 };
 
+Trader.prototype.GetTraderGainMultiplier = function()
+{
+	return ApplyValueModificationsToEntity("Trader/GainMultiplier", +this.template.GainMultiplier, this.entity);
+}
+
 Trader.prototype.HasBothMarkets = function()
 {
 	return this.markets.length >= 2;
 };
 
Index: binaries/data/mods/public/simulation/data/technologies/trade_commercial_treaty.json
===================================================================
--- binaries/data/mods/public/simulation/data/technologies/trade_commercial_treaty.json	(nonexistent)
+++ binaries/data/mods/public/simulation/data/technologies/trade_commercial_treaty.json	(copie de travail)
@@ -0,0 +1,13 @@
+{
+	"genericName": "Commercial Treaty",
+	"description": "Improve the international trading profit.",
+	"cost": { "food": 0, "wood": 0, "stone": 0, "metal": 100 },
+	"requirements": { "tech": "phase_town" },
+	"requirementsTooltip": "Unlocked in Town Phase.",
+	"icon": "sibylline_books.png",
+	"researchTime": 40,
+	"tooltip": "Market +10% International Bonus.",
+	"modifications": [{ "value": "Market/InternationalBonus", "add": 0.10 }],
+	"affects": ["Market"],
+	"soundComplete": "interface/alarm/alarm_upgradearmory.xml"
+}
Index: binaries/data/mods/public/simulation/helpers/TraderGain.js
===================================================================
--- binaries/data/mods/public/simulation/helpers/TraderGain.js	(révision 18106)
+++ binaries/data/mods/public/simulation/helpers/TraderGain.js	(copie de travail)
@@ -1,69 +1,68 @@
-// This constant used to adjust gain value depending on distance
-const DISTANCE_FACTOR = 1 / 115;
-
-// Additional gain (applying to each market) for trading performed between markets of different players, in percents
-const INTERNATIONAL_TRADING_ADDITION = 25;
-
-// If trader undefined, the trader owner is supposed to be the same as the first market
-function CalculateTraderGain(firstMarket, secondMarket, template, trader)
+function CalculateTraderGain(firstMarket, secondMarket, traderTemplate, trader)
 {
-	var gain = {};
-
-	var cmpFirstMarketPosition = Engine.QueryInterface(firstMarket, IID_Position);
-	var cmpSecondMarketPosition = Engine.QueryInterface(secondMarket, IID_Position);
+	let cmpFirstMarketPosition = Engine.QueryInterface(firstMarket, IID_Position);
+	let cmpSecondMarketPosition = Engine.QueryInterface(secondMarket, IID_Position);
 	if (!cmpFirstMarketPosition || !cmpFirstMarketPosition.IsInWorld() ||
-	    !cmpSecondMarketPosition || !cmpSecondMarketPosition.IsInWorld())
+	   !cmpSecondMarketPosition || !cmpSecondMarketPosition.IsInWorld())
 		return null;
-	var firstMarketPosition = cmpFirstMarketPosition.GetPosition2D();
-	var secondMarketPosition = cmpSecondMarketPosition.GetPosition2D();
+	let firstMarketPosition = cmpFirstMarketPosition.GetPosition2D();
+	let secondMarketPosition = cmpSecondMarketPosition.GetPosition2D();
 
-	// Calculate ordinary Euclidean distance between markets.
-	// We don't use pathfinder, because ordinary distance looks more fair.
-	var distance = firstMarketPosition.distanceTo(secondMarketPosition);
-	// We calculate gain as square of distance to encourage trading between remote markets
-	gain.traderGain = Math.pow(distance * DISTANCE_FACTOR, 2);
-	if (template && template.GainMultiplier)
-	{
-		if (trader)
-			gain.traderGain *= ApplyValueModificationsToEntity("Trader/GainMultiplier", +template.GainMultiplier, trader);
-		else	// called from the gui with modifications already applied
-			gain.traderGain *= template.GainMultiplier;
-	}
-	// If trader undefined, the trader owner is supposed to be the same as the first market
-	var cmpOwnership = trader ? Engine.QueryInterface(trader, IID_Ownership) : Engine.QueryInterface(firstMarket, IID_Ownership);
-	if (!cmpOwnership)
+	let cmpMarket1Player = QueryOwnerInterface(firstMarket);
+	let cmpMarket2Player = QueryOwnerInterface(secondMarket);
+	if (!cmpMarket1Player || !cmpMarket2Player)
 		return null;
-	gain.traderOwner = cmpOwnership.GetOwner();
 
-	// If markets belong to different players, add gain from international trading
-	var ownerFirstMarket = Engine.QueryInterface(firstMarket, IID_Ownership).GetOwner();
-	var ownerSecondMarket = Engine.QueryInterface(secondMarket, IID_Ownership).GetOwner();
-	if (ownerFirstMarket != ownerSecondMarket)
+	let cmpMarket1 = Engine.QueryInterface(firstMarket, IID_Market);
+	let cmpMarket2 = Engine.QueryInterface(secondMarket, IID_Market);
+	if (!cmpMarket1 || !cmpMarket2)
+		return null;
+
+	let gainMultiplier;
+	if (trader)
 	{
-		gain.market1Gain = gain.traderGain * ApplyValueModificationsToEntity("Trade/International", INTERNATIONAL_TRADING_ADDITION, firstMarket) / 100;
-		gain.market1Owner = ownerFirstMarket;
-		gain.market2Gain = gain.traderGain * ApplyValueModificationsToEntity("Trade/International", INTERNATIONAL_TRADING_ADDITION, secondMarket) / 100;
-		gain.market2Owner = ownerSecondMarket;
+		let cmpTrader = Engine.QueryInterface(trader, IID_Trader);
+		if (!cmpTrader)
+			return null;
+		gainMultiplier = cmpTrader.GetTraderGainMultiplier();
 	}
-
-	// Add potential trade multipliers and roundings
-	var cmpPlayer = trader ? QueryOwnerInterface(trader) : QueryOwnerInterface(firstMarket);
-	if (cmpPlayer)
-		gain.traderGain *= cmpPlayer.GetTradeRateMultiplier();
-	gain.traderGain = Math.round(gain.traderGain);
-
-	if (ownerFirstMarket != ownerSecondMarket)
+	//called from the gui, modifications already applied
+	else
 	{
-		if ((cmpPlayer = QueryOwnerInterface(firstMarket)))
-			gain.market1Gain *= cmpPlayer.GetTradeRateMultiplier();
-		gain.market1Gain = Math.round(gain.market1Gain);
-
-		if ((cmpPlayer = QueryOwnerInterface(secondMarket)))
-			gain.market2Gain *= cmpPlayer.GetTradeRateMultiplier();
-		gain.market2Gain = Math.round(gain.market2Gain);
+		if (!traderTemplate || !traderTemplate.GainMultiplier)
+			return null;
+		gainMultiplier = traderTemplate.GainMultiplier / 10000;
 	}
 
-	return gain;
+		let gain = {};
+
+		// Calculate ordinary Euclidean distance between markets.
+		// We don't use pathfinder, because ordinary distance looks more fair.
+		let distanceSq = firstMarketPosition.distanceToSquared(secondMarketPosition);
+		// We calculate gain as square of distance to encourage trading between remote markets
+		gain.traderGain = distanceSq * gainMultiplier;
+
+		gain.market1Owner = cmpMarket1Player.GetPlayerID();
+		gain.market2Owner = cmpMarket2Player.GetPlayerID();
+		// If trader undefined, the trader owner is supposed to be the same as the first market
+		let cmpPlayer = trader ? QueryOwnerInterface(trader) : cmpMarket1Player;
+		if (!cmpPlayer)
+			return null;
+		gain.traderOwner = cmpPlayer.GetPlayerID();
+		// Add potential player trade multipliers
+		let playerBonus = cmpPlayer.GetTradeRateMultiplier();
+		// If markets belong to different players, add gain from international trading
+		if (gain.market1Owner != gain.market2Owner)
+		{	let market1PlayerBonus = cmpMarket1Player.GetTradeRateMultiplier();
+			let market2PlayerBonus = cmpMarket2Player.GetTradeRateMultiplier();
+			let internationalBonus1 = cmpMarket1.GetInternationalBonus();
+			let internationalBonus2 = cmpMarket2.GetInternationalBonus();
+			gain.market1Gain = Math.round(gain.traderGain * internationalBonus1 * market1PlayerBonus);
+			gain.market2Gain = Math.round(gain.traderGain * internationalBonus2 * market2PlayerBonus);
+		}
+		gain.traderGain = Math.round(gain.traderGain * playerBonus);
+
+		return gain;
 }
 
 Engine.RegisterGlobal("CalculateTraderGain", CalculateTraderGain);
Index: binaries/data/mods/public/simulation/templates/structures/cart_dock.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/cart_dock.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/structures/cart_dock.xml	(copie de travail)
@@ -17,10 +17,13 @@
     <GenericName>Commercial Port</GenericName>
     <SpecificName>Namel</SpecificName>
     <History>The Carthaginians were famous for their sea trade. Carthage itself had an entire harbor dedicated to nothing more than commercial sea trade.</History>
     <Tooltip>Construct fishing boats to gather meat and merchant ships to trade with other docks.</Tooltip>
   </Identity>
+  <Market>
+    <InternationalBonus op="add">0.1</InternationalBonus>
+  </Market>
   <Obstruction>
     <Static width="30.0" depth="19.0"/>
   </Obstruction>
   <ProductionQueue>
     <Technologies datatype="tokens">
Index: binaries/data/mods/public/simulation/templates/structures/cart_market.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/structures/cart_market.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/structures/cart_market.xml	(copie de travail)
@@ -10,10 +10,13 @@
   <Identity>
     <Civ>cart</Civ>
     <SpecificName>Šūq</SpecificName>
     <History>Carthaginian markets were probably just big sheds or structures surrounding a ?market? area or in a wharf area of a port.</History>
   </Identity>
+  <Market>
+    <InternationalBonus op="add">0.1</InternationalBonus>
+  </Market>
   <Obstruction>
     <Static width="27.0" depth="20.0"/>
   </Obstruction>
   <VisualActor>
     <Actor>structures/carthaginians/market.xml</Actor>
Index: binaries/data/mods/public/simulation/templates/template_formation.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_formation.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/template_formation.xml	(copie de travail)
@@ -39,8 +39,8 @@
     <FormationController>true</FormationController>
     <WalkSpeed>1.0</WalkSpeed>
     <PassabilityClass>large</PassabilityClass>
   </UnitMotion>
   <Trader>
-    <GainMultiplier>1.0</GainMultiplier>
+    <GainMultiplier>0.75</GainMultiplier>
   </Trader>
 </Entity>
Index: binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml	(copie de travail)
@@ -32,10 +32,11 @@
     <stone>25</stone>
     <metal>25</metal>
   </Loot>
   <Market>
     <TradeType>land</TradeType>
+    <InternationalBonus>0.2</InternationalBonus>
   </Market>
   <Obstruction>
     <Static width="30.0" depth="26.0"/>
   </Obstruction>
   <Sound>
@@ -57,10 +58,11 @@
       unlock_shared_dropsites
       trade_convoys_speed
       trade_convoys_armor
       trade_gain_01
       trade_gain_02
+      trade_commercial_treaty
     </Technologies>
     <Entities datatype="tokens">
       units/{civ}_support_trader
     </Entities>
   </ProductionQueue>
Index: binaries/data/mods/public/simulation/templates/template_structure_military_dock.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_structure_military_dock.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/template_structure_military_dock.xml	(copie de travail)
@@ -34,10 +34,11 @@
     <stone>0</stone>
     <metal>0</metal>
   </Loot>
   <Market>
     <TradeType>land naval</TradeType>
+    <InternationalBonus>0.2</InternationalBonus>
   </Market>
   <Obstruction>
     <Static width="18.0" depth="18.0"/>
   </Obstruction>
   <Position>
Index: binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_merchant.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_merchant.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_merchant.xml	(copie de travail)
@@ -43,11 +43,11 @@
     <BarWidth>6.0</BarWidth>
     <BarHeight>0.5</BarHeight>
     <HeightOffset>6.0</HeightOffset>
   </StatusBars>
   <Trader>
-    <GainMultiplier>1.0</GainMultiplier>
+    <GainMultiplier>0.75</GainMultiplier>
   </Trader>
   <UnitAI>
     <DefaultStance>passive</DefaultStance>
     <CanGuard>false</CanGuard>
   </UnitAI>
Index: binaries/data/mods/public/simulation/templates/template_unit_support_trader.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit_support_trader.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/template_unit_support_trader.xml	(copie de travail)
@@ -37,11 +37,11 @@
       <gather_rock>resource/mining/pickaxe.xml</gather_rock>
       <gather_ore>resource/mining/mining.xml</gather_ore>
     </SoundGroups>
   </Sound>
   <Trader>
-    <GainMultiplier>1.0</GainMultiplier>
+    <GainMultiplier>0.75</GainMultiplier>
   </Trader>
   <UnitAI>
     <CanGuard>false</CanGuard>
   </UnitAI>
   <UnitMotion>
Index: binaries/data/mods/public/simulation/templates/units/cart_ship_merchant.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/units/cart_ship_merchant.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/units/cart_ship_merchant.xml	(copie de travail)
@@ -11,11 +11,11 @@
     <Tooltip>Trade between docks. Garrison a Trader aboard for additional profit (+20% for each garrisoned). Gather profitable aquatic treasures. Carthaginians have +25% sea trading bonus.</Tooltip>
     <Icon>units/cart_ship_merchant.png</Icon>
     <RequiredTechnology>phase_village</RequiredTechnology>
   </Identity>
   <Trader>
-    <GainMultiplier>1.25</GainMultiplier>
+    <GainMultiplier op="mul">1.25</GainMultiplier>
   </Trader>
   <VisualActor>
     <Actor>structures/carthaginians/merchant_ship.xml</Actor>
   </VisualActor>
 </Entity>
Index: binaries/data/mods/public/simulation/templates/units/pers_support_trader.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/units/pers_support_trader.xml	(révision 18106)
+++ binaries/data/mods/public/simulation/templates/units/pers_support_trader.xml	(copie de travail)
@@ -19,11 +19,11 @@
       <order_walk>actor/fauna/movement/camel.xml</order_walk>
       <death>actor/fauna/death/death_camel.xml</death>
     </SoundGroups>
   </Sound>
   <Trader>
-    <GainMultiplier>1.25</GainMultiplier>
+    <GainMultiplier op="mul">1.25</GainMultiplier>
   </Trader>
   <VisualActor>
     <Actor>units/persians/trader.xml</Actor>
   </VisualActor>
 </Entity>
