Fix #10216: Initialise RoadStop caches before using them and don't try to teleport crashed vehicles (#10217)

This commit is contained in:
Loïc Guilloux 2022-12-05 12:46:46 +01:00 committed by GitHub
parent 2c5eb206d4
commit 13d2d11fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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();