Bug #1654
closedtech upkeep seems to overflow at 2^16
0%
Description
I have a game on a rather large map and a ruleset with tech upkeep.
I have a save-game where I produce 65532 bulbs of which 64464 are required for tech upkeep, resulting in a net plus of 1068 bulbs. Everything works as expected. (see screenshot stat_a.png)
When increasing research income via city settings, I get 65730 bulbs, still requiring 64464 as upkeep, resulting in a net plus of 1266 bulbs. Still, everything is fine. Note that the research income is above 2^16. (see stat_b.png)
After researching one more tech and further increasing research income there seems to be a problemn. My research income is now 69581 bulbs (which is correct) but my upkeep cost is now reduced to 2720, resulting in a net plus of 66861 bulbs. I assume, the correct value for the upkeep cost would be 68256 (2720 + 65536) and the actual number I get seems to be the result of an overflow. (see stat_c.png)
Two according savegames are attached. The first (year 2296) with the initial setting (both numbers below 2^16) and the second (year 2298) with the bug (both numbers above 2^16 but the upkeep is wrong).
The game identifies as:
Dies ist Freeciv Version 3.0.6, gui-gtk-3.22-Klient.
Built against gtk+ 3.24.36, using 3.24.38
Built against glib 2.74.5, using 2.74.6
Files