From 5137f7f3e951009905c28bad51cee68def07c7fa Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 28 Apr 2021 17:04:45 +0300 Subject: [PATCH 19/19] Consider tradeworldrelpct when calculating one time bonus See osdn #42097 Signed-off-by: Marko Lindqvist --- common/traderoutes.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/common/traderoutes.c b/common/traderoutes.c index 5ad8bad0bc..3149a4b367 100644 --- a/common/traderoutes.c +++ b/common/traderoutes.c @@ -465,13 +465,22 @@ int get_caravan_enter_city_trade_bonus(const struct city *pc1, if (game.info.caravan_bonus_style == CBS_CLASSIC) { /* Should this be real_map_distance? */ - tb = map_distance(pc1->tile, pc2->tile) + 10; + int distance = map_distance(pc1->tile, pc2->tile); + int weighted_distance = ((100 - game.info.trade_world_rel_pct) * distance + + game.info.trade_world_rel_pct + * (distance * 40 / MAX(wld.map.xsize, wld.map.ysize))) / 100; + + tb = weighted_distance + 10; tb = (tb * (pc1->surplus[O_TRADE] + pc2->surplus[O_TRADE])) / 24; } else if (game.info.caravan_bonus_style == CBS_LOGARITHMIC) { /* Logarithmic bonus */ - bonus = pow(log(real_map_distance(pc1->tile, pc2->tile) + 20 - + max_trade_prod(pc1) + max_trade_prod(pc2)) * 2, 2); - tb = (int)bonus; + int distance = real_map_distance(pc1->tile, pc2->tile); + int weighted_distance = ((100 - game.info.trade_world_rel_pct) * distance + + game.info.trade_world_rel_pct + * (distance * 40 / MAX(wld.map.xsize, wld.map.ysize))) / 100; + + tb = pow(log(weighted_distance + 20 + + max_trade_prod(pc1) + max_trade_prod(pc2)) * 2, 2); } if (pgood != NULL) { -- 2.30.2