From 52a04eb7370bd1c4ee3f87b3af237023bb7c4eff Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 27 Feb 2023 01:57:10 +0200 Subject: [PATCH 17/17] Fix clang analyzer div by zero warn From api_methods_city_inspire_partisans() See osdn #47465 Signed-off-by: Marko Lindqvist --- common/scriptcore/api_game_methods.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/common/scriptcore/api_game_methods.c b/common/scriptcore/api_game_methods.c index b72da8d3a4..106b91a473 100644 --- a/common/scriptcore/api_game_methods.c +++ b/common/scriptcore/api_game_methods.c @@ -251,14 +251,8 @@ int api_methods_city_inspire_partisans(lua_State *L, City *self, } else { if (game.info.citizen_partisans_pct > 0) { if (is_server()) { - int own = citizens_nation_get(self, inspirer->slot); - int total = 0; - - /* Not citizens_foreign_iterate() as city has already changed hands. - * old owner would be considered foreign and new owner not. */ - citizens_iterate(self, pslot, nat) { - total += nat; - } citizens_iterate_end; + citizens own = citizens_nation_get(self, inspirer->slot); + citizens total = city_size_get(self); if ((own * 100 / total) >= game.info.citizen_partisans_pct) { inspired = TRUE; -- 2.39.2