Possible infrastructure count overflow leading to negative infrastructure maintenance costs #7665
Labels
bug
Something isn't working
needs triage
This issue needs further investigation before it becomes actionable
Version of OpenTTD
Tested on 20190707-master-g1e723934a1 and 20200509-master-g61e1a45100, though bug probably present since the dawn of OpenTTD
Expected result
When you have more than 2,147,483,647 road pieces, then the infrastructure count should just keep on going up with no overflow.
Actual result
When you have more than 2,147,483,647 road pieces, the infrastructure count in the company window does not overflow right away, but in the infrastructure detail window, it does. Additionally, without NewGRFs and with default settings, the amount you are paying for road infrastructure maintenance yearly (proportional to approximately [count]^1.5) flips from positive £32.654 trillion to negative £32.654 trillion.
EDIT: At 4,294,967,296 road pieces (and all multiples thereof), the infrastructure count in the company window DOES overflow, going back to 0. In both cases, the cause is that all infrastructure counts are stored as 32-bit integers (uint32 in the company window, signed int32 for infrastructure details window and infrastructure cost calculation).
Savegame to test/reproduce
Sharkey & Co., 3002-07-20D (overflow).zip
(This uses a custom AI, which you can get below in step 4.)
Steps to reproduce
The text was updated successfully, but these errors were encountered: