Skip to content

Commit

Permalink
Fix military upkeep tooltip
Browse files Browse the repository at this point in the history
There was probably a call to city_refresh_from_main_map when it was written (or
I was using a governor).

See #1859.
  • Loading branch information
lmoureaux authored and jwrober committed Mar 25, 2023
1 parent 9413acb commit d59f6e2
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions client/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("</p><p>");
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 <b>%1 additional unhappy citizen.</b>",
"resulting in <b>%1 additional unhappy citizens.</b>",
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 <b>%1 additional unhappy citizen.</b>",
"resulting in up to <b>%1 additional unhappy citizens.</b>",
happy_upkeep))
.arg(happy_upkeep);
} else {
str += _("Currently, military units do not cause additional unhappiness "
"in this city.");
Expand Down

0 comments on commit d59f6e2

Please sign in to comment.