Clang analyzer giver div by zero warning about player_distance_to_player() line "return MAX(dists / cities, 1);"
There's no bug in there. It's just that the compiler cannot know that "city_list_size(pplayer->cities) == 0" check earlier makes sure that city_list_iterate() makes at least one iteration. Anyway, we should silence the warning, and doing that even speeds up the function.
Clang analyzer giver div by zero warning about player_distance_to_player() line "return MAX(dists / cities, 1);"
There's no bug in there. It's just that the compiler cannot know that "city_list_size(pplayer->cities) == 0" check earlier makes sure that city_list_iterate() makes at least one iteration. Anyway, we should silence the warning, and doing that even speeds up the function.