From 13d2d11fa8f2696611ddec0a4d8f31a831a86a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Mon, 5 Dec 2022 12:46:46 +0100 Subject: [PATCH] Fix #10216: Initialise RoadStop caches before using them and don't try to teleport crashed vehicles (#10217) --- src/saveload/afterload.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 6fbc2ac9a2..3426a88010 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3155,6 +3155,9 @@ bool AfterLoadGame() } } + /* Road stops is 'only' updating some caches, but they are needed for PF calls in SLV_MULTITRACK_LEVEL_CROSSINGS teleporting. */ + AfterLoadRoadStops(); + /* Road vehicles stopped on multitrack level crossings need teleporting to a depot * to avoid crashing into the side of the train they're waiting for. */ if (IsSavegameVersionBefore(SLV_MULTITRACK_LEVEL_CROSSINGS)) { @@ -3166,6 +3169,9 @@ bool AfterLoadGame() /* Ignore moving vehicles. */ if (rv->cur_speed > 0) continue; + /* Ignore crashed vehicles. */ + if (rv->vehstatus & VS_CRASHED) continue; + /* Ignore vehicles not on level crossings. */ TileIndex cur_tile = rv->tile; if (!IsLevelCrossingTile(cur_tile)) continue; @@ -3207,8 +3213,6 @@ bool AfterLoadGame() for (Station *st : Station::Iterate()) UpdateStationAcceptance(st, false); } - /* Road stops is 'only' updating some caches */ - AfterLoadRoadStops(); AfterLoadLabelMaps(); AfterLoadCompanyStats(); AfterLoadStoryBook();