"); + str += text_happiness_cities_rules(pplayer, base_content, basis, step, + depends_on_empire_size); + + // Now add the status of this city. + str += QStringLiteral("
"); + auto max_content = player_base_citizen_happiness(city_owner(pcity)); + if (!game.info.angrycitizen) { + // No angry citizens: max_content can't go negative + max_content = CLIP(0, max_content, MAX_CITY_SIZE); + } + // If the penalty is enabled, explain it. + if (depends_on_empire_size) { + str += text_happiness_cities_apply_rules(cities, max_content); + } + + auto size = city_size_get(pcity); + str += QStringLiteral(" "); + str += text_happiness_cities_content(size, max_content); + + // Finally, add something about building more cities. + if (depends_on_empire_size) { + str += QStringLiteral(" "); + str += text_happiness_more_cities(base_content, basis, step, max_content, + size, cities); + } + + return str + QStringLiteral("
"); } /** diff --git a/client/text.h b/client/text.h index 764cc493c0..7cab783a9f 100644 --- a/client/text.h +++ b/client/text.h @@ -46,7 +46,7 @@ const QString act_sel_action_tool_tip(const struct action *paction, QString text_happiness_buildings(const struct city *pcity); const QString text_happiness_nationality(const struct city *pcity); -const QString text_happiness_cities(const struct city *pcity); +QString text_happiness_cities(const struct city *pcity); const QString text_happiness_luxuries(const struct city *pcity); const QString text_happiness_units(const struct city *pcity); QString text_happiness_wonders(const struct city *pcity); diff --git a/common/city.cpp b/common/city.cpp index 046d877a4e..81e32203b1 100644 --- a/common/city.cpp +++ b/common/city.cpp @@ -2055,7 +2055,7 @@ int city_granary_size(int city_size) A positive number is a number of content citizens. A negative number is a number of angry citizens (a city never starts with both). */ -static int player_base_citizen_happiness(const struct player *pplayer) +int player_base_citizen_happiness(const struct player *pplayer) { int cities = city_list_size(pplayer->cities); int content = get_player_bonus(pplayer, EFT_CITY_UNHAPPY_SIZE); @@ -2069,7 +2069,7 @@ static int player_base_citizen_happiness(const struct player *pplayer) if (cities > basis) { content--; - if (step != 0) { + if (step > 0) { /* the first penalty is at (basis + 1) cities; the next is at (basis + step + 1), _not_ (basis + step) */ content -= (cities - basis - 1) / step; diff --git a/common/city.h b/common/city.h index 817316997d..f718455c9e 100644 --- a/common/city.h +++ b/common/city.h @@ -532,6 +532,7 @@ void city_size_set(struct city *pcity, citizens size); citizens city_specialists(const struct city *pcity); +int player_base_citizen_happiness(const struct player *pplayer); citizens player_content_citizens(const struct player *pplayer); citizens player_angry_citizens(const struct player *pplayer);