From 93feda779db4835f4a55f0831833dac582f27c83 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 15 May 2022 04:53:02 +0300 Subject: [PATCH 40/40] can_build_extra_base(): Check irrigation/mine_time Make sure that the target tile irrigation/mine_time does not prevent building the extra. See osdn #44591 Signed-off-by: Marko Lindqvist --- common/extras.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/common/extras.c b/common/extras.c index ce15d2e24b..31cca0029b 100644 --- a/common/extras.c +++ b/common/extras.c @@ -373,12 +373,16 @@ bool can_build_extra_base(const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile) { + struct terrain *pterr; + if (!extra_can_be_built(pextra, ptile)) { return FALSE; } + pterr = tile_terrain(ptile); + if (is_extra_caused_by(pextra, EC_BASE)) { - if (tile_terrain(ptile)->base_time == 0) { + if (pterr->base_time == 0) { return FALSE; } if (tile_city(ptile) != NULL && extra_base_get(pextra)->border_sq >= 0) { @@ -386,8 +390,21 @@ bool can_build_extra_base(const struct extra_type *pextra, } } + /* Even if it's a multi-cause extra, just having Build Road as one of the + * causes makes it to require that road_time != 0. + * Correct functioning of EC_PLACE extras depend on this. */ if (is_extra_caused_by(pextra, EC_ROAD) - && tile_terrain(ptile)->road_time == 0) { + && pterr->road_time == 0) { + return FALSE; + } + + if (is_extra_caused_by(pextra, EC_IRRIGATION) + && pterr->irrigation_time == 0) { + return FALSE; + } + + if (is_extra_caused_by(pextra, EC_MINE) + && pterr->mining_time == 0) { return FALSE; } -- 2.35.1