From 9d39dfe33017c18357544e09209dff2b4ba8e4e9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist <cazfi74@gmail.com> Date: Thu, 22 Apr 2021 04:18:25 +0300 Subject: [PATCH 49/49] Support Small Wonder Visibility value "Embassy" See osdn #42051 Signed-off-by: Marko Lindqvist <cazfi74@gmail.com> --- common/fc_types.h | 2 ++ common/improvement.c | 10 +++++++++- common/improvement.h | 3 ++- data/alien/game.ruleset | 5 +++-- data/civ1/game.ruleset | 5 +++-- data/civ2/game.ruleset | 5 +++-- data/civ2civ3/game.ruleset | 5 +++-- data/classic/game.ruleset | 5 +++-- data/goldkeep/game.ruleset | 5 +++-- data/granularity/game.ruleset | 5 +++-- data/multiplayer/game.ruleset | 5 +++-- data/sandbox/game.ruleset | 5 +++-- data/stub/game.ruleset | 5 +++-- data/webperimental/game.ruleset | 5 +++-- fc_version | 2 +- server/plrhand.c | 3 ++- 16 files changed, 49 insertions(+), 26 deletions(-) diff --git a/common/fc_types.h b/common/fc_types.h index 19f83057c8..fa3c97bcfb 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -1227,6 +1227,8 @@ enum setting_default_level { SETDEF_INTERNAL, SETDEF_RULESET, SETDEF_CHANGED }; #define SPECENUM_VALUE0NAME "Always" #define SPECENUM_VALUE1 WV_NEVER #define SPECENUM_VALUE1NAME "Never" +#define SPECENUM_VALUE2 WV_EMBASSY +#define SPECENUM_VALUE2NAME "Embassy" #include "specenum_gen.h" #ifdef __cplusplus diff --git a/common/improvement.c b/common/improvement.c index 15e17e6488..3b04de355f 100644 --- a/common/improvement.c +++ b/common/improvement.c @@ -919,10 +919,15 @@ struct city *city_from_wonder(const struct player *pplayer, /**********************************************************************//** Can the player see wonder owned by the other player? + + Embassy can be passed as parameter so that caller can make the somewhat + costly embassy detection just once even when calling this multiple + times (e.g. for number of different wonders) **************************************************************************/ bool wonder_visible_to_player(const struct impr_type *wonder, const struct player *pplayer, - const struct player *owner) + const struct player *owner, + enum fc_tristate embassy) { if (pplayer == owner) { /* Can see all own wonders, @@ -940,6 +945,9 @@ bool wonder_visible_to_player(const struct impr_type *wonder, return TRUE; case WV_NEVER: return FALSE; + case WV_EMBASSY: + return embassy == TRI_YES + || (embassy == TRI_MAYBE && team_has_embassy(pplayer->team, owner)); } fc_assert(FALSE); diff --git a/common/improvement.h b/common/improvement.h index ede5e27550..c9f1054945 100644 --- a/common/improvement.h +++ b/common/improvement.h @@ -165,7 +165,8 @@ struct city *city_from_wonder(const struct player *pplayer, const struct impr_type *pimprove); bool wonder_visible_to_player(const struct impr_type *wonder, const struct player *pplayer, - const struct player *owner); + const struct player *owner, + enum fc_tristate embassy); bool great_wonder_is_built(const struct impr_type *pimprove); bool great_wonder_is_destroyed(const struct impr_type *pimprove); diff --git a/data/alien/game.ruleset b/data/alien/game.ruleset index 552579db97..b7c3eb080d 100644 --- a/data/alien/game.ruleset +++ b/data/alien/game.ruleset @@ -189,8 +189,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/civ1/game.ruleset b/data/civ1/game.ruleset index be74e497e1..909508f25a 100644 --- a/data/civ1/game.ruleset +++ b/data/civ1/game.ruleset @@ -175,8 +175,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/civ2/game.ruleset b/data/civ2/game.ruleset index 4552217830..2de7f1c16c 100644 --- a/data/civ2/game.ruleset +++ b/data/civ2/game.ruleset @@ -171,8 +171,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/civ2civ3/game.ruleset b/data/civ2civ3/game.ruleset index 65818310d3..6195190f0c 100644 --- a/data/civ2civ3/game.ruleset +++ b/data/civ2civ3/game.ruleset @@ -192,8 +192,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/classic/game.ruleset b/data/classic/game.ruleset index 697db27097..252970789a 100644 --- a/data/classic/game.ruleset +++ b/data/classic/game.ruleset @@ -185,8 +185,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/goldkeep/game.ruleset b/data/goldkeep/game.ruleset index 11a3ea574b..bd46bf0682 100644 --- a/data/goldkeep/game.ruleset +++ b/data/goldkeep/game.ruleset @@ -190,8 +190,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/granularity/game.ruleset b/data/granularity/game.ruleset index 2474ec5b57..ec909e01de 100644 --- a/data/granularity/game.ruleset +++ b/data/granularity/game.ruleset @@ -181,8 +181,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/multiplayer/game.ruleset b/data/multiplayer/game.ruleset index 1522eeaa31..4ead0e3281 100644 --- a/data/multiplayer/game.ruleset +++ b/data/multiplayer/game.ruleset @@ -188,8 +188,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/sandbox/game.ruleset b/data/sandbox/game.ruleset index 5ff8c08361..e98136908f 100644 --- a/data/sandbox/game.ruleset +++ b/data/sandbox/game.ruleset @@ -190,8 +190,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/stub/game.ruleset b/data/stub/game.ruleset index 185d06ea9f..18625111ed 100644 --- a/data/stub/game.ruleset +++ b/data/stub/game.ruleset @@ -173,8 +173,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/data/webperimental/game.ruleset b/data/webperimental/game.ruleset index 9d95beaba0..d36ebcfc66 100644 --- a/data/webperimental/game.ruleset +++ b/data/webperimental/game.ruleset @@ -189,8 +189,9 @@ airlift_to_always_enabled = TRUE [wonder_visibility] ; When do opponents know which city, if any, has built the Small Wonder -; "Always" - Information is always sent -; "Never" - Information is never sent +; "Always" - Information is always sent +; "Never" - Information is never sent +; "Embassy" - Information is sent when team has an embassy with Wonder owner small_wonders = "Always" [illness] diff --git a/fc_version b/fc_version index 926c2f3853..474e34814c 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-2021.Apr.20" +NETWORK_CAPSTRING="+Freeciv.Devel-3.2-2021.Apr.22" FREECIV_DISTRIBUTOR="" diff --git a/server/plrhand.c b/server/plrhand.c index 529f696143..1f39f920de 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -1314,7 +1314,8 @@ static void package_player_info(struct player *plr, for (imp = 0; imp < B_LAST; imp++) { if (plr->wonders[imp] != WONDER_NOT_BUILT) { if (wonder_visible_to_player(improvement_by_number(imp), - receiver, plr)) { + receiver, plr, + info_level >= INFO_EMBASSY ? TRI_YES : TRI_NO)) { packet->wonders[imp] = plr->wonders[imp]; } else { packet->wonders[imp] = WONDER_NOT_BUILT; -- 2.30.2