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

Loading old TTD save crashes game (station / oil rig related) #8108

Closed
James103 opened this issue May 4, 2020 · 2 comments
Closed

Loading old TTD save crashes game (station / oil rig related) #8108

James103 opened this issue May 4, 2020 · 2 comments

Comments

@James103
Copy link
Contributor

James103 commented May 4, 2020

Version of OpenTTD

Release: 1.10.1
Nightly: 20200426

Expected result

In both versions, the savegame loads correctly.

Actual result (Release):

The game loads normally, but crashes after a few days if you demolish the bridge located at tile 0x299A (154, 41).
Crash log (after demolishing everything): crash_oil_rig_1.zip
Crash log (after demolishing bridge at 0x299A): crash_floating_train.zip

Additionally, demolishing the bridge at tile 0x4181 (129, 65) causes the train on it to perpetually say "No Power".

Actual result (Nightly):

The game asserts here:

assert(st->facilities == (FACIL_AIRPORT | FACIL_DOCK) && st->airport.type == AT_OILRIG);

This is called during the station-based tileloop at
DeleteOilRig(t);

Crash log: crash_oil_rig_nightly.zip

Steps to Reproduce

  1. In a release version, load the attached savegame.

  2. Pause the game.

  3. Give yourself a few billion.

  4. Demolish everything.

  5. Wait up to 30 days.

  6. Crash

  7. In a nightly version, load the attached savegame.

  8. Crash

Savegame

#3601 - TRT01.zip

@SamuXarick
Copy link
Contributor

SamuXarick commented May 4, 2020

I commented out the assert, and I get a crash about "vector iterators incompatible", when loading the savegame, here:

for (auto tile = _animated_tiles.begin(); tile < _animated_tiles.end(); /* Nothing */) {
/* Remove if tile is not animated */
bool remove = _tile_type_procs[GetTileType(*tile)]->animate_tile_proc == nullptr;
/* and remove if duplicate */
for (auto j = _animated_tiles.begin(); !remove && j < tile; j++) {
remove = *tile == *j;
}
if (remove) {
DeleteAnimatedTile(*tile);
} else {
tile++;
}
}

At the part where it says if (remove) { DeleteAnimatedTile(*tile); } else { tile++; },
It iterates the first time. Then iter++ at the line just down there, is not called. because remove is true. So it then crashes with iterator incompatible next loop. PS: Only crashes in debug build, not release build.

SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue May 4, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue May 4, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue May 4, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue May 4, 2020
SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue May 4, 2020
@Yexo Yexo closed this as completed in c01803c May 4, 2020
@SamuXarick
Copy link
Contributor

The floating train crash requires Settings > Limitations > When paused allow: All actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants