From b14a69ab0a2ad4eb3ba04fc291370c31ede85e8a Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 3 Dec 2022 10:03:25 +0200 Subject: [PATCH 42/42] AI: Assert continent number sanity in dai_data_phase_begin() See osdn #45867 Signed-off-by: Marko Lindqvist --- ai/default/daidata.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ai/default/daidata.c b/ai/default/daidata.c index ee6dc35e89..d96632bb27 100644 --- a/ai/default/daidata.c +++ b/ai/default/daidata.c @@ -211,20 +211,19 @@ void dai_data_phase_begin(struct ai_type *ait, struct player *pplayer, if (unit_has_type_flag(punit, UTYF_SETTLERS)) { Continent_id cont = tile_continent(ptile); - /* We have to check that continent id is in a legal range, - * as this currently gets sometimes called with inconsistent - * data regarding continent numbers. - * Even if the id is in legal range, it's possible that it - * doesn't really refer to the correct continent, but as that's - * so rare situation, for now we just ignore the possibility - * in constructing these statistics. */ if (is_ocean_tile(ptile)) { if (cont <= 0 && -cont <= adv->num_oceans) { ai->stats.ocean_workers[(int)-cont]++; + } else { + /* Always fails */ + fc_assert(cont <= 0 && -cont <= adv->num_oceans); } } else { if (cont >= 0 && cont <= adv->num_continents) { ai->stats.workers[(int)cont]++; + } else { + /* Always fails */ + fc_assert(cont >= 0 && cont <= adv->num_continents); } } } -- 2.35.1