From d59f6e2c554afd4df2dec8284dd5bffe412d86d5 Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Mon, 20 Mar 2023 23:36:40 +0100 Subject: [PATCH] Fix military upkeep tooltip There was probably a call to city_refresh_from_main_map when it was written (or I was using a governor). See #1859. --- client/text.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/client/text.cpp b/client/text.cpp index a86227f867..b9baf0d1f9 100644 --- a/client/text.cpp +++ b/client/text.cpp @@ -1884,30 +1884,33 @@ QString text_happiness_units(const struct city *pcity) } // And finally how many unhappy we get in this city - int count = 0; + int count = 0, happy_upkeep = 0; unit_list_iterate(pcity->units_supported, punit) { int dummy = 0; - if (city_unit_unhappiness(punit, &dummy) > 0) { + if (auto n = city_unit_unhappiness(punit, &dummy); n > 0) { count++; + happy_upkeep += n; } } unit_list_iterate_end; str += QStringLiteral("

"); if (count > 0) { - // TRANS: "This city supports %1 agressive military units, resulting in X - // unhappy citizens." (first part) + // TRANS: "This city supports %1 agressive military units, resulting in + // up to X unhappy citizens." (first part) str += QString(PL_("This city supports %1 agressive military unit, ", "This city supports %1 agressive military units, ", count)) .arg(count); - // TRANS: "This city supports %1 agressive military units, resulting in X - // unhappy citizens." (second part) - str += QString(PL_("resulting in %1 additional unhappy citizen.", - "resulting in %1 additional unhappy citizens.", - pcity->unit_happy_upkeep)) - .arg(pcity->unit_happy_upkeep); + // TRANS: "This city supports X agressive military units, resulting in up + // to %1 unhappy citizens." (second part) + str += + QString( + PL_("resulting in up to %1 additional unhappy citizen.", + "resulting in up to %1 additional unhappy citizens.", + happy_upkeep)) + .arg(happy_upkeep); } else { str += _("Currently, military units do not cause additional unhappiness " "in this city.");