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 waypoints from savegame version 72 causes crash #7587

Closed
James103 opened this issue May 12, 2019 · 6 comments
Closed

Loading old waypoints from savegame version 72 causes crash #7587

James103 opened this issue May 12, 2019 · 6 comments

Comments

@James103
Copy link
Contributor

@James103 James103 commented May 12, 2019

Version of OpenTTD

1.9.1 stable

Expected result

The savegame loads and simulates normally.

Actual result

The savegame "Sundinghattan Transport, 10th Dec 2110.sav" (#1131) always crashes on load (after a few game ticks) with "NOT_REACHED triggered at line 2711 of d:\a\1\s\src\rail_cmd.cpp". Crash files have been attached.

This is probably caused by an invalid rail track tile being accessed.

Steps to reproduce

Load the attached savegame and wait a few game ticks.

@LordAro

This comment has been minimized.

Copy link
Member

@LordAro LordAro commented May 12, 2019

Purely for informational purposes, can you try with latest master as well? There's been some changes in that area - #7544 comes to mind

@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented May 12, 2019

The same savegame, loaded in the latest master (20190511) crashes immediately on load, but with a different assertion (Assertion failed at line 113 of d:\a\1\s\src\core\pool_type.hpp: index < this->first_unused). Crash files have been attached.

@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented May 19, 2019

When I try to load the "Sundinghattan Transport, 10th Dec 2110.sav" save game using the 2019-05-16 (or later) version of OpenTTD master, the game crashes (Assertion failed at line 212 of d:\a\1\s\src\rail_map.h: IsPlainRailTile(t)), but says that the NewGRF "total_town_replacement_set-3.02a\ttrs3w.grf" with GRFID 56430001 and MD5 checksum AF3E0A1E6EF0B98DB966594578D1775B was not found and a compatible NewGRF was loaded, therefore no additional crash info has been generated.

Do you have the exact version of the following NewGRF that I need to load the saved game and possibly allow crash info to be generated?
image

@LordAro

This comment has been minimized.

Copy link
Member

@LordAro LordAro commented Jan 2, 2020

Investigation shows that it's crashing on tile 50011, which looks like it's a RailTileType of RAIL_TILE_WAYPOINT. This type was later removed when waypoints were reorganised to be more like stations. I managed to compile 0.6.x and load the save successfully:

Nothing special about the waypoint on first glance...

With bisecting, I nailed down the crash to 2646a99 . There is a change in afterload.cpp in there...

@LordAro

This comment has been minimized.

Copy link
Member

@LordAro LordAro commented Jan 3, 2020

The issue is, as far as I can tell, that at that point in the loading sequence waypoint still has tiletype of MP_RAILWAY (rather than station) and then causes SetTrackReservation to fall over

@LordAro

This comment has been minimized.

Copy link
Member

@LordAro LordAro commented Jan 3, 2020

With the following diff I was able to load the save in current master: (Though the game crashes somewhere in YAPF after running for a few ticks - possibly because there's a depot tile pretending to be a railtrack)

diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 47d2c7b03c..cb3e05e5c3 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1951,8 +1951,10 @@ bool AfterLoadGame()
                                        /* Clear PBS reservation on track */
                                        if (IsRailDepot(t)) {
                                                SetDepotReservation(t, false);
-                                       } else {
+                                       } else if (IsPlainRailTile(t)) {
                                                SetTrackReservation(t, TRACK_BIT_NONE);
+                                       } else {
+                                               fprintf(stderr, "Unknown MP_RAILWAY tile: %i\n", t);
                                        }
                                        break;
 

which outputs

Unknown MP_RAILWAY tile: 50011
Unknown MP_RAILWAY tile: 52370

and looks like:

I notice that neither of these tiles are apparently stored in the old WAYP save block, which will presumably be why they're getting converted to depots instead. As to why they're not in the WAYP block...

@LordAro LordAro changed the title Crash on loading saved game from #1131 Loading old waypoints from savegame version 72 causes crash Jan 3, 2020
LordAro added a commit to LordAro/OpenTTD that referenced this issue Jan 3, 2020
@LordAro LordAro closed this in cddb8a4 Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.