From c183d650a0dad7ed530f1a53661658f8fdaa03e9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 31 Jul 2022 15:06:03 +0300 Subject: [PATCH 55/55] dai_spend_gold(): Refactor checks for choice want - Fixed choice tracking - Made floating point want handling more robust - Fixed clang analyzer warning See osdn #45275 Signed-off-by: Marko Lindqvist --- ai/default/daicity.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ai/default/daicity.c b/ai/default/daicity.c index a6c319318e..f1359ca5cd 100644 --- a/ai/default/daicity.c +++ b/ai/default/daicity.c @@ -558,22 +558,20 @@ static void dai_spend_gold(struct ai_type *ait, struct player *pplayer) if (acity_data->choice.want > bestchoice.want && ai_fuzzy(pplayer, TRUE)) { - bestchoice.value = acity_data->choice.value; - bestchoice.want = acity_data->choice.want; - bestchoice.type = acity_data->choice.type; + adv_choice_copy(&bestchoice, &(acity_data->choice)); pcity = acity; } } city_list_iterate_end; /* We found nothing, so we're done */ - if (bestchoice.want == 0) { + if (pcity == NULL) { break; } city_data = def_ai_city_data(pcity, ait); /* Not dealing with this city a second time */ - city_data->choice.want = 0; + city_data->choice.want = -1; ADV_CHOICE_ASSERT(bestchoice); -- 2.35.1