diff options
author | Yexo <yexo@openttd.org> | 2020-05-04 23:58:56 +0200 |
---|---|---|
committer | Yexo <t.marinussen@gmail.com> | 2020-05-06 22:10:08 +0200 |
commit | 64278fd5983c80757615d67c76922e700246fc1b (patch) | |
tree | 1ecd60a46824c1ed344e96468becbdd343beae7b /src/saveload | |
parent | 364f6806c8e73555e7091f57d39b9118871bf76c (diff) | |
download | openttd-64278fd5983c80757615d67c76922e700246fc1b.tar.xz |
Fix: reset roadtype/streetcartype info for non-road bridges
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/afterload.cpp | 8 | ||||
-rw-r--r-- | src/saveload/saveload.h | 13 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 9fbccf65e..0f1d4c450 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3119,6 +3119,14 @@ bool AfterLoadGame() } } + if (IsSavegameVersionUntil(SLV_ENDING_YEAR)) { + for (TileIndex t = 0; t < map_size; t++) { + if (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) != TRANSPORT_ROAD) { + SetRoadTypes(t, INVALID_ROADTYPE, INVALID_ROADTYPE); + } + } + } + /* Update station docking tiles. */ AfterLoadScanDockingTiles(); diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index eeb0c58f2..5065e568b 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -770,6 +770,19 @@ static inline bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor = 0 } /** + * Checks whether the savegame is below or at \a major. This should be used to repair data from existing + * savegames which is no longer corrupted in new savegames, but for which otherwise no savegame + * bump is required. + * @param major Major number of the version to check against. + * @return Savegame version is at most the specified version. + */ +static inline bool IsSavegameVersionUntil(SaveLoadVersion major) +{ + extern SaveLoadVersion _sl_version; + return _sl_version <= major; +} + +/** * Checks if some version from/to combination falls within the range of the * active savegame version. * @param version_from Inclusive savegame version lower bound. |