freeciv21
freeciv21 copied to clipboard
Provide more detail in the city dialog about how unit upkeep is calculated
Describe the bug Client doesn't properly show unit upkeep in city dialog.
To Reproduce Steps to reproduce the behavior:
- Open a game
- Lookup the upkeep of a unit in game help
- Open a city dialog
- Hover over a unit and notice the client doesn't give proper stats
- See error
Expected behavior Upkeep icons and proper stats shown
Screenshots
Platform and version (please complete the following information):
- OS: Linux
- Freeciv21 version: 3.1-alpha.3
- Ruleset/Longturn game (if applicable): Sim
Additional context None
Let me add to the mix the government help, that usually reads as:
- Each city can support up to 2 units for free; further units each cost 1 gold per turn.
Not all units have the same upkeep in the help.
Summarizing what is shown:
- The help dialog shows the values in
utype->upkeep
andutype->happy_cost
- The upkeep list shows
punit->upkeep
for food/shield/gold (unit_upkeep_astr
incommon/unit.cpp
)
When computing upkeep (city_units_upkeep
in server/citytools.cpp
), the cost of each unit is calculated in utype_upkeep_cost(utype, player, output_type)
. This works as follows:
- The base upkeep is taken from
utype->upkeep
- If the unit is a Fanatic and
EFT_FANATICS
is active, upkeep is zeroed out - If the unit type has the
UTYF_SHIELD2GOLD
flag and the effectEFT_SHIELD2GOLD_FACTOR
is > 0:- Any gold upkeep is replaced with shield upkeep *
EFT_SHIELD2GOLD_FACTOR
- Shield upkeep is zeroed
- Any gold upkeep is replaced with shield upkeep *
- The result is multiplied with the value of the effect
EFT_UPKEEP_FACTOR
Every city gets free support for a number of units. This is controlled by EFT_UNIT_UPKEEP_FREE_PER_CITY
.
Sim05 numbers for EFT_UNIT_UPKEEP_FREE_PER_CITY
:
Government | Gold | Shields | Food |
---|---|---|---|
Anarchy | 99 | 99 | 100 |
Tribal | 99 | 99 | 100 |
Despotism | 2 | 2 | 6 |
Fundamentalism | 2 | 1 | 6 |
Communism | 2 | 1 | 3 |
Monarchy | 2 | 1 | 5 |
Others | 0 | 0 | 3 |
Cities get one more free unit free of food support at even sizes between 2 and 30 except at size 10.
Sim05 has two effects with EFT_SHIELD2GOLD_FACTOR
, one for Raiders and one for Bowmen. They are irrelevant for the current case.
From the numbers above and the issue description, we are in the "Others" case with two units free of food upkeep, not costing any shields (even in the base upkeep) but costing one gold each. A similar logic must explain the lack of unhappy citizens.
:arrow_right: Unit upkeep is more complicated than can be represented in the unit type help summary :arrow_right: What is shown is (most likely) correct :arrow_right: Suggest to reclassify as a doc bug (documenting the above logic) or GUI feature request (for more detailed explanations)
@jwrober thoughts on the above analysis?
The challenge is that is really hard for a regular player to fully understand this when looking at units in the city dialog. What if we add some kind of extra text to the pop up when hovering over a unit? Something similar to what we do on the citizens tab in city dialog. The text would give upkeep information taking into account the varying effects from Government, Wonders, Improvements, etc.
Sounds like a good idea
Heck add UWT to the text while we are at it
Heck add UWT to the text while we are at it
#309 ?
Good catch. Yes I think that is it.