From 8e91cdb7dd9fa0ff9c3e31189560c41147baf76c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 15 Jan 2022 00:44:58 +0200 Subject: [PATCH 43/43] Add support for Self-Provided goods Good requirement for a good with Self-Provided flag is true also in the city producing the good, not only ones importing it. See osdn #43532 Signed-off-by: Marko Lindqvist --- common/requirements.c | 4 +++- common/traderoutes.c | 2 +- common/traderoutes.h | 4 +++- data/alien/game.ruleset | 4 ++++ data/civ1/game.ruleset | 4 ++++ data/civ2/game.ruleset | 4 ++++ data/classic/game.ruleset | 4 ++++ data/goldkeep/game.ruleset | 4 ++++ data/granularity/game.ruleset | 4 ++++ data/multiplayer/game.ruleset | 4 ++++ data/ruledit/comments-3.2.txt | 4 ++++ data/sandbox/game.ruleset | 4 ++++ data/stub/game.ruleset | 4 ++++ data/webperimental/game.ruleset | 4 ++++ fc_version | 2 +- 15 files changed, 52 insertions(+), 4 deletions(-) diff --git a/common/requirements.c b/common/requirements.c index 4e1eaa2f43..b32b61e57c 100644 --- a/common/requirements.c +++ b/common/requirements.c @@ -1950,7 +1950,9 @@ static enum fc_tristate is_goods_type_in_range(const struct tile *target_tile, if (!target_city) { return TRI_MAYBE; } - return BOOL_TO_TRISTATE(city_receives_goods(target_city, pgood)); + return BOOL_TO_TRISTATE(city_receives_goods(target_city, pgood) + || (goods_has_flag(pgood, GF_SELF_PROVIDED) + && goods_can_be_provided(target_city, pgood, NULL))); case REQ_RANGE_CADJACENT: case REQ_RANGE_ADJACENT: case REQ_RANGE_TRADEROUTE: diff --git a/common/traderoutes.c b/common/traderoutes.c index bc6112b8fb..5783c0d97f 100644 --- a/common/traderoutes.c +++ b/common/traderoutes.c @@ -655,7 +655,7 @@ bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag) /*********************************************************************//** Can the city provide goods. *************************************************************************/ -bool goods_can_be_provided(struct city *pcity, struct goods_type *pgood, +bool goods_can_be_provided(const struct city *pcity, struct goods_type *pgood, struct unit *punit) { const struct unit_type *ptype; diff --git a/common/traderoutes.h b/common/traderoutes.h index 0e13344770..b832112045 100644 --- a/common/traderoutes.h +++ b/common/traderoutes.h @@ -164,6 +164,8 @@ do { \ #define SPECENUM_VALUE0NAME "Bidirectional" #define SPECENUM_VALUE1 GF_DEPLETES #define SPECENUM_VALUE1NAME "Depletes" +#define SPECENUM_VALUE2 GF_SELF_PROVIDED +#define SPECENUM_VALUE2NAME "Self-Provided" #define SPECENUM_COUNT GF_COUNT #define SPECENUM_BITVECTOR bv_goods_flags #include "specenum_gen.h" @@ -200,7 +202,7 @@ struct goods_type *goods_by_translated_name(const char *name); bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag); -bool goods_can_be_provided(struct city *pcity, struct goods_type *pgood, +bool goods_can_be_provided(const struct city *pcity, struct goods_type *pgood, struct unit *punit); struct goods_type *goods_from_city_to_unit(struct city *src, struct unit *punit); bool city_receives_goods(const struct city *pcity, diff --git a/data/alien/game.ruleset b/data/alien/game.ruleset index ea2ecde0e9..b15a0651c6 100644 --- a/data/alien/game.ruleset +++ b/data/alien/game.ruleset @@ -1540,6 +1540,10 @@ goods_selection = "Arrival" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/civ1/game.ruleset b/data/civ1/game.ruleset index 9b1b31968f..5ab280c6db 100644 --- a/data/civ1/game.ruleset +++ b/data/civ1/game.ruleset @@ -1357,6 +1357,10 @@ goods_selection = "Arrival" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/civ2/game.ruleset b/data/civ2/game.ruleset index 1e61df06fd..302955afca 100644 --- a/data/civ2/game.ruleset +++ b/data/civ2/game.ruleset @@ -1602,6 +1602,10 @@ goods_selection = "Arrival" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/classic/game.ruleset b/data/classic/game.ruleset index df94b3ce95..fcd924f24e 100644 --- a/data/classic/game.ruleset +++ b/data/classic/game.ruleset @@ -1847,6 +1847,10 @@ goods_selection = "Arrival" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/goldkeep/game.ruleset b/data/goldkeep/game.ruleset index c6511af48b..fe880eee1e 100644 --- a/data/goldkeep/game.ruleset +++ b/data/goldkeep/game.ruleset @@ -1929,6 +1929,10 @@ goods_selection = "Leaving" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/granularity/game.ruleset b/data/granularity/game.ruleset index 10c6a38395..63605a5950 100644 --- a/data/granularity/game.ruleset +++ b/data/granularity/game.ruleset @@ -842,6 +842,10 @@ goods_selection = "Leaving" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/multiplayer/game.ruleset b/data/multiplayer/game.ruleset index 15ae984229..e77139196a 100644 --- a/data/multiplayer/game.ruleset +++ b/data/multiplayer/game.ruleset @@ -1807,6 +1807,10 @@ goods_selection = "Arrival" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/ruledit/comments-3.2.txt b/data/ruledit/comments-3.2.txt index 1895632743..25a10c01ff 100644 --- a/data/ruledit/comments-3.2.txt +++ b/data/ruledit/comments-3.2.txt @@ -1076,6 +1076,10 @@ goods = "\ ; - \"Depletes\" = Trade route gets cancelled when the source city cannot provide\n\ ; goods any more. Bidirectional routes gets cancelled if either\n\ ; one of the involved cities cannot provide goods.\n\ +; - \"Self-Provided\" = Good requirement (in requirement lists of other rules)\n\ +; is fullfilled also for the city exporting, or capable of exporting,\n\ +; the good. Otherwise it would be true only for cities importing the\n\ +; good from elsewhere.\n\ ; helptext = Optional help text string; should escape all raw\n\ ; newlines so that xgettext parsing works\n\ ;\n\ diff --git a/data/sandbox/game.ruleset b/data/sandbox/game.ruleset index a13ad14932..f80300c595 100644 --- a/data/sandbox/game.ruleset +++ b/data/sandbox/game.ruleset @@ -3387,6 +3387,10 @@ goods_selection = "Leaving" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/stub/game.ruleset b/data/stub/game.ruleset index 19ae36bfd7..19ed6fba27 100644 --- a/data/stub/game.ruleset +++ b/data/stub/game.ruleset @@ -703,6 +703,10 @@ goods_selection = "Leaving" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/data/webperimental/game.ruleset b/data/webperimental/game.ruleset index fca17e09ce..fe8e22857f 100644 --- a/data/webperimental/game.ruleset +++ b/data/webperimental/game.ruleset @@ -2099,6 +2099,10 @@ goods_selection = "Leaving" ; - "Depletes" = Trade route gets cancelled when the source city cannot provide ; goods any more. Bidirectional routes gets cancelled if either ; one of the involved cities cannot provide goods. +; - "Self-Provided" = Good requirement (in requirement lists of other rules) +; is fullfilled also for the city exporting, or capable of exporting, +; the good. Otherwise it would be true only for cities importing the +; good from elsewhere. ; helptext = Optional help text string; should escape all raw ; newlines so that xgettext parsing works ; diff --git a/fc_version b/fc_version index f45190250b..2b4cb0c3f4 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.Jan.11b" +NETWORK_CAPSTRING="+Freeciv.Devel-3.2-2022.Jan.15" FREECIV_DISTRIBUTOR="" -- 2.34.1