Skip to content
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

Crash or load errors when loading old save games after previous save/load #6540

Closed
DorpsGek opened this issue Mar 4, 2017 · 1 comment
Closed
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Mar 4, 2017

JGR opened the ticket and wrote:

In src/saveload/station_sl.cpp there are a number of static globals used for loading, which are read depending on the savegame version.
In particular, _num_flows is read if the version is >= 183, and written in the save code, but is never cleared otherwise.
It is unconditionally read in the STNN load code shortly after it is conditionally read, and used to conditionally control reading more bytes from the chunk.
If it happens to be non-zero when loading a savegame version < 183, the loader gets out of sync with the save game state and aborts due to chunk length mismatches or similar.
As this leaves the game state in a mess it crashes when trying to load the title game afterwards.
_num_flows can be left non-zero if the last station in the pool has 1 or more flows for cargo 31.

The _cargo_source_xy, _cargo_days, and _cargo_feeder_share variables have similar but less severe issues.

A possible fix is attached.
I haven't looked extensively for similar issues in other parts of the savegame code.

Loading the first savegame attached and then the second one should trigger the bug.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/6540
@DorpsGek
Copy link
Member Author

DorpsGek commented Mar 5, 2017

fonsinchen closed the ticket.

Reason for closing: Fixed

in r27770


This comment was imported from FlySpray: https://bugs.openttd.org/task/6540

@DorpsGek DorpsGek closed this as completed Mar 5, 2017
@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant