From cdac9e3ea23ddaa9fa13a607414dd17d88c01f5a Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 8 Apr 2023 16:47:06 +0300 Subject: [PATCH 36/36] AI: Make cost values in dai_log_path() unsigned Overflow reported by alain_bkr See osdn #47746 Signed-off-by: Marko Lindqvist --- ai/default/aitools.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ai/default/aitools.c b/ai/default/aitools.c index c656be0438..f8ba97d05c 100644 --- a/ai/default/aitools.c +++ b/ai/default/aitools.c @@ -374,13 +374,13 @@ void dai_log_path(struct unit *punit, struct pf_path *path, struct pf_parameter *parameter) { const struct pf_position *last = pf_path_last_position(path); - const int cc = PF_TURN_FACTOR * last->total_MC - + parameter->move_rate * last->total_EC; - const int tc = cc / (PF_TURN_FACTOR *parameter->move_rate); + const unsigned cc = PF_TURN_FACTOR * last->total_MC + + parameter->move_rate * last->total_EC; + const unsigned tc = cc / (PF_TURN_FACTOR * parameter->move_rate); - UNIT_LOG(LOG_DEBUG, punit, "path L=%d T=%d(%d) MC=%d EC=%d CC=%d", - path->length - 1, last->turn, tc, - last->total_MC, last->total_EC, cc); + UNIT_LOG(LOG_DEBUG, punit, "path L=%d T=%d(%u) MC=%u EC=%u CC=%u", + path->length - 1, last->turn, tc, + last->total_MC, last->total_EC, cc); } /**********************************************************************//** -- 2.39.2