New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: CTD when all cargos are disabled by NewGRF, and cargo payment graph opened #9545
Comments
I would expect the game to abort world generation if there are no cargo types available. If there aren't any cargo types there isn't any game to play at all, since you have nothing to transport. |
It's perfect! You can build eye-candy objects all day without the distraction of pointless transportation! :p |
The game crashes in this case due to a division by 0 inside the following function: Lines 2172 to 2180 in 41c40f1
I was able to reproduce the crash on master (2022-02-10) and in jgrpp (0.46.0). The stack trace of the latter crash was used to find the crashing function. Crash files from the former crash: crash20220214021730.zip |
I'm sure there's more places around the code that assumes that at least one cargo type is available too. That function is just the first that happens to be hit here. |
I think the proper fix is to abort map generation if no cargos are available, not to find and fix the crashes. |
This is not a very useful state, but it's nice to not crash. Some parts of the game don't (yet) check for cargo types being redefined, that is out-of-scope here.
This is not a very useful state, but it's nice to not crash. Some parts of the game don't (yet) check for cargo types being redefined, that is out-of-scope here.
Version of OpenTTD
Master (7469f00)
Expected result
When all cargos are disabled by a NewGRF like Feature Disabler GRF, starting a new game without any cargos prompts the following error message on map generation:
I would expect opening the "Cargo payment rates" graph to show an empty graph with no cargos.
Actual result
Opening the "Cargo payment rates" graph causes a crash to desktop.
Steps to reproduce
The text was updated successfully, but these errors were encountered: