From cd98d6399abaec56048b43da42ff5faefa7128bb Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 5 Jan 2022 19:54:40 +0200 Subject: [PATCH 38/38] Introduce is_building_sellable() Use it instead of is_wonder() to determine if a building must have zero upkeep. See osdn #43556 Signed-off-by: Marko Lindqvist --- common/city.c | 2 +- common/improvement.c | 14 ++++++++++++-- common/improvement.h | 1 + server/rssanity.c | 5 +++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/common/city.c b/common/city.c index 009c029bf5..1201e4c315 100644 --- a/common/city.c +++ b/common/city.c @@ -1209,7 +1209,7 @@ int city_improvement_upkeep(const struct city *pcity, if (NULL == b) { return 0; } - if (is_wonder(b)) { + if (!is_building_sellable(b)) { return 0; } diff --git a/common/improvement.c b/common/improvement.c index a7cd835ca8..218c8cfda6 100644 --- a/common/improvement.c +++ b/common/improvement.c @@ -1073,7 +1073,8 @@ struct city *city_from_small_wonder(const struct player *pplayer, **************************************************************************/ bool can_sell_building(const struct impr_type *pimprove) { - return (valid_improvement(pimprove) && is_improvement(pimprove)); + return (valid_improvement(pimprove) + && is_building_sellable(pimprove)); } /**********************************************************************//** @@ -1082,7 +1083,16 @@ bool can_sell_building(const struct impr_type *pimprove) bool can_city_sell_building(const struct city *pcity, const struct impr_type *pimprove) { - return (city_has_building(pcity, pimprove) && is_improvement(pimprove)); + return (city_has_building(pcity, pimprove) + && is_building_sellable(pimprove)); +} + +/**********************************************************************//** + Return TRUE iff the building is sellable one. +**************************************************************************/ +bool is_building_sellable(const struct impr_type *pimprove) +{ + return is_improvement(pimprove); } /**********************************************************************//** diff --git a/common/improvement.h b/common/improvement.h index 49c6c48e2c..889917adba 100644 --- a/common/improvement.h +++ b/common/improvement.h @@ -137,6 +137,7 @@ bool can_improvement_go_obsolete(const struct impr_type *pimprove); bool can_sell_building(const struct impr_type *pimprove); bool can_city_sell_building(const struct city *pcity, const struct impr_type *pimprove); +bool is_building_sellable(const struct impr_type *pimprove); enum test_result test_player_sell_building_now(struct player *pplayer, struct city *pcity, const struct impr_type *pimprove); diff --git a/server/rssanity.c b/server/rssanity.c index 8c73094558..cf265ea5ea 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -661,8 +661,9 @@ static bool rs_buildings(void) return FALSE; } - if (is_wonder(pimprove) && pimprove->upkeep != 0) { - ruleset_error(LOG_ERROR, "%s is a wonder with a nonzero upkeep value", + if (!is_building_sellable(pimprove) && pimprove->upkeep != 0) { + ruleset_error(LOG_ERROR, + "%s is a nonsellable building with a nonzero upkeep value", improvement_rule_name(pimprove)); return FALSE; } -- 2.34.1