From 32693b00b6adf8d2bf603e93b69c324528c913f3 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 7 Feb 2022 20:23:18 +0200 Subject: [PATCH 42/42] Add minimum trade route output ruleset setting Requested by ddeanbrown See osdn #43011 Signed-off-by: Marko Lindqvist --- common/networking/packets.def | 1 + common/traderoutes.c | 16 ++++++++++++++-- data/alien/game.ruleset | 4 ++++ data/civ1/game.ruleset | 4 ++++ data/civ2/game.ruleset | 4 ++++ data/civ2civ3/game.ruleset | 4 ++++ data/classic/game.ruleset | 4 ++++ data/goldkeep/game.ruleset | 4 ++++ data/granularity/game.ruleset | 4 ++++ data/multiplayer/game.ruleset | 4 ++++ data/sandbox/game.ruleset | 4 ++++ data/stub/game.ruleset | 4 ++++ data/webperimental/game.ruleset | 4 ++++ fc_version | 2 +- server/ruleset.c | 11 ++++++++--- tools/ruleutil/rulesave.c | 3 +++ 16 files changed, 71 insertions(+), 6 deletions(-) diff --git a/common/networking/packets.def b/common/networking/packets.def index 49569f6e2e..be927a97a9 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -512,6 +512,7 @@ PACKET_GAME_INFO = 16; sc, is-info UINT8 forced_science; UINT8 fulltradesize; UINT8 trade_world_rel_pct; + UINT8 min_trade_route_val; GOODS_SELECTION goods_selection; /* True if at least one civilization has researched a tech */ UINT16 global_advance_count; diff --git a/common/traderoutes.c b/common/traderoutes.c index 5783c0d97f..7d30dd3b2c 100644 --- a/common/traderoutes.c +++ b/common/traderoutes.c @@ -358,11 +358,23 @@ int trade_base_between_cities(const struct city *pc1, const struct city *pc2) int trade_from_route(const struct city *pc1, const struct trade_route *route, int base) { + int val; + if (route->dir == RDIR_TO) { - return base * route->goods->to_pct / 100; + val = base * route->goods->to_pct / 100; + + if (route->goods->to_pct > 0) { + val = MAX(val, game.info.min_trade_route_val); + } + } else { + val = base * route->goods->from_pct / 100; + + if (route->goods->from_pct > 0) { + val = MAX(val, game.info.min_trade_route_val); + } } - return base * route->goods->from_pct / 100; + return val; } /*********************************************************************//** diff --git a/data/alien/game.ruleset b/data/alien/game.ruleset index ab1f38002d..1e3e983264 100644 --- a/data/alien/game.ruleset +++ b/data/alien/game.ruleset @@ -1511,6 +1511,10 @@ settings = "TeamIC", 300, "Cancel", "Both" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/civ1/game.ruleset b/data/civ1/game.ruleset index 50cf861c27..266a2d14bd 100644 --- a/data/civ1/game.ruleset +++ b/data/civ1/game.ruleset @@ -1328,6 +1328,10 @@ settings = "TeamIC", 400, "Cancel", "Gold" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/civ2/game.ruleset b/data/civ2/game.ruleset index 71613ce447..c8794a85fc 100644 --- a/data/civ2/game.ruleset +++ b/data/civ2/game.ruleset @@ -1573,6 +1573,10 @@ settings = "TeamIC", 400, "Cancel", "Both" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/civ2civ3/game.ruleset b/data/civ2civ3/game.ruleset index ab7d57c064..1d15c3c1ba 100644 --- a/data/civ2civ3/game.ruleset +++ b/data/civ2civ3/game.ruleset @@ -2023,6 +2023,10 @@ settings = "TeamIC", 200, "Cancel", "Gold" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/classic/game.ruleset b/data/classic/game.ruleset index 103a02f7b1..84383121a1 100644 --- a/data/classic/game.ruleset +++ b/data/classic/game.ruleset @@ -1818,6 +1818,10 @@ settings = "TeamIC", 400, "Cancel", "Both" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/goldkeep/game.ruleset b/data/goldkeep/game.ruleset index ce29fecfcf..c9881be4ea 100644 --- a/data/goldkeep/game.ruleset +++ b/data/goldkeep/game.ruleset @@ -1900,6 +1900,10 @@ settings = "TeamIC", 400, "Cancel", "Both" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/granularity/game.ruleset b/data/granularity/game.ruleset index 61119585df..143342cc34 100644 --- a/data/granularity/game.ruleset +++ b/data/granularity/game.ruleset @@ -813,6 +813,10 @@ settings = "TeamIC", 0, "Cancel", "None" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/multiplayer/game.ruleset b/data/multiplayer/game.ruleset index 858eb32c4a..bc528cb1df 100644 --- a/data/multiplayer/game.ruleset +++ b/data/multiplayer/game.ruleset @@ -1778,6 +1778,10 @@ settings = "TeamIC", 0, "Cancel", "Both" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/sandbox/game.ruleset b/data/sandbox/game.ruleset index 6393de774a..72a630098b 100644 --- a/data/sandbox/game.ruleset +++ b/data/sandbox/game.ruleset @@ -3359,6 +3359,10 @@ settings = "TeamIC", 200, "Cancel", "Gold" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/stub/game.ruleset b/data/stub/game.ruleset index 42ebeeab44..c98eda6d79 100644 --- a/data/stub/game.ruleset +++ b/data/stub/game.ruleset @@ -674,6 +674,10 @@ settings = "TeamIC", 0, "Cancel", "None" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/data/webperimental/game.ruleset b/data/webperimental/game.ruleset index b66a460e66..7f753557ba 100644 --- a/data/webperimental/game.ruleset +++ b/data/webperimental/game.ruleset @@ -2071,6 +2071,10 @@ settings = "TeamIC", 400, "Cancel", "Both" } +; Minimum trade a trade route produces, as long as the good has nonzero income +; for the relevant direction (from_pct / to_pct) +min_trade_route_val = 0 + ; When are goods for the trade route chosen. ; "Leaving" - Goods to carry are assigned to unit when it`s built, or it changes homecity ; "Arrival" - Goods are chosen when trade route is established, when unit arrives to destination diff --git a/fc_version b/fc_version index 8175284af4..8a491be557 100755 --- a/fc_version +++ b/fc_version @@ -56,7 +56,7 @@ DEFAULT_FOLLOW_TAG=S3_2 # - No new mandatory capabilities can be added to the release branch; doing # so would break network capability of supposedly "compatible" releases. # -NETWORK_CAPSTRING="+Freeciv.Devel-3.2-2022.Feb.03" +NETWORK_CAPSTRING="+Freeciv.Devel-3.2-2022.Feb.07" FREECIV_DISTRIBUTOR="" diff --git a/server/ruleset.c b/server/ruleset.c index 0b5a746fcf..63c548e86e 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -7438,9 +7438,14 @@ static bool load_ruleset_game(struct section_file *file, bool act, } if (ok) { - const char *str = secfile_lookup_str_default(file, - goods_selection_method_name(RS_DEFAULT_GOODS_SELECTION), - "trade.goods_selection"); + const char *str; + + game.info.min_trade_route_val + = secfile_lookup_int_default(file, 0, "trade.min_trade_route_val"); + + str = secfile_lookup_str_default(file, + goods_selection_method_name(RS_DEFAULT_GOODS_SELECTION), + "trade.goods_selection"); game.info.goods_selection = goods_selection_method_by_name(str, fc_strcasecmp); diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index f6080bd936..7cdfe00dc4 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -1639,6 +1639,9 @@ static bool save_game_ruleset(const char *filename, const char *name) } } + save_default_int(sfile, game.info.min_trade_route_val, + 0, "trade.min_trade_route_val", NULL); + if (game.info.goods_selection != RS_DEFAULT_GOODS_SELECTION) { secfile_insert_str(sfile, goods_selection_method_name(game.info.goods_selection), "trade.goods_selection"); -- 2.34.1