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
Updated by Marco Schuler 9 days ago
forgot to mention the OS and the source of FreeCiv:
I'm on Debian bookworm with all updates and use the distribution provided version of FreeCiv
Updated by Marko Lindqvist 9 days ago
- Category set to General
The overflow seems to be only in the network protocol, so only client side (display to the player) has the wrong value. Server side should still use the correct value.
There's a message from the server in the chat window:
Trying to put 68256 into 16 bits; it will result 2720 at receiving side.
Updated by Marko Lindqvist 9 days ago
- File 0030-Protocol-Make-tech_upkeep-a-32-bit-value.patch 0030-Protocol-Make-tech_upkeep-a-32-bit-value.patch added
- File 0010-Protocol-Make-tech_upkeep-a-32-bit-value.patch 0010-Protocol-Make-tech_upkeep-a-32-bit-value.patch added
- File 0009-Protocol-Make-tech_upkeep-a-32-bit-value.patch 0009-Protocol-Make-tech_upkeep-a-32-bit-value.patch added
- Status changed from New to In Review
- Assignee set to Marko Lindqvist
- Target version set to 3.1.6