From e866c963b986d7cc816b3917bc604821d3489da2 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 4 Feb 2023 13:11:06 +0200 Subject: [PATCH 30/30] Stop assuming that VUT_CITYSTATUS is about CITYS_OWNED_BY_ORIGINAL - Correct havior of dai_can_requirement_be_met_in_city() - Allow multiple active VUT_CITYSTATUS requirements, as they might be of different values See osdn #45562 Signed-off-by: Marko Lindqvist --- ai/default/daieffects.c | 21 +++++++++++---------- server/rssanity.c | 7 +++++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ai/default/daieffects.c b/ai/default/daieffects.c index 557c91f287..26df3aaf88 100644 --- a/ai/default/daieffects.c +++ b/ai/default/daieffects.c @@ -813,16 +813,17 @@ bool dai_can_requirement_be_met_in_city(const struct requirement *preq, return FALSE; case VUT_CITYSTATUS: - /* FIXME: update */ - if (pcity == NULL || pcity->original == NULL) { - return preq->present; - } - if (preq->present) { - return city_owner(pcity) == pcity->original; - } else { - return city_owner(pcity) != pcity->original; + if (pcity != NULL) { + if (preq->source.value.citystatus == CITYS_OWNED_BY_ORIGINAL + && pcity->original != NULL) { + if (preq->present) { + return city_owner(pcity) == pcity->original; + } else { + return city_owner(pcity) != pcity->original; + } + } } - + break; case VUT_TERRAIN: case VUT_TERRAINCLASS: case VUT_TERRAINALTER: @@ -852,7 +853,6 @@ bool dai_can_requirement_be_met_in_city(const struct requirement *preq, /* No way to add once lost. */ return !preq->present; - case VUT_NATION: case VUT_NATIONGROUP: case VUT_AI_LEVEL: @@ -897,5 +897,6 @@ bool dai_can_requirement_be_met_in_city(const struct requirement *preq, /* No sensible implementation possible with data available. */ break; } + return TRUE; } diff --git a/server/rssanity.c b/server/rssanity.c index 044dd967ec..b77937e677 100644 --- a/server/rssanity.c +++ b/server/rssanity.c @@ -335,7 +335,6 @@ static bool sanity_check_req_set(rs_conversion_logger logger, case VUT_TERRAINALTER: /* Local range only */ case VUT_STYLE: case VUT_IMPR_GENUS: - case VUT_CITYSTATUS: case VUT_ORIGINAL_OWNER: /* City range -> only one original owner */ /* There can be only one requirement of these types (with current * range limitations) @@ -431,7 +430,11 @@ static bool sanity_check_req_set(rs_conversion_logger logger, /* Can have multiple requirements of these types */ case VUT_MINLATITUDE: case VUT_MAXLATITUDE: - /* Can have multiple requirements at different ranges */ + /* Can have multiple requirements at different ranges. + * TODO: Compare to number of legal ranges? */ + break; + case VUT_CITYSTATUS: + /* Could check "CITYS_LAST * number of ranges" ? */ break; case VUT_COUNT: /* Should never be in requirement vector */ -- 2.39.1