From d1ea0502321e38f38011e481b1daff4a14d583cc Mon Sep 17 00:00:00 2001 From: smatz Date: Sat, 20 Dec 2008 01:35:12 +0000 Subject: (svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame) --- src/openttd.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/openttd.cpp') diff --git a/src/openttd.cpp b/src/openttd.cpp index 7a3a9cd18..daae2d596 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1326,6 +1326,26 @@ bool AfterLoadGame() if (CheckSavegameVersion(98)) GamelogGRFAddList(_grfconfig); + /* in very old versions, size of train stations was stored differently */ + if (CheckSavegameVersion(2)) { + Station *st; + FOR_ALL_STATIONS(st) { + if (st->train_tile != 0 && st->trainst_h == 0) { + extern SavegameType _savegame_type; + uint n = _savegame_type == SGT_OTTD ? 4 : 3; // OTTD uses 4 bits per dimensions, TTD 3 bits + uint w = GB(st->trainst_w, n, n); + uint h = GB(st->trainst_w, 0, n); + + if (GetRailStationAxis(st->train_tile) != AXIS_X) Swap(w, h); + + st->trainst_w = w; + st->trainst_h = h; + + assert(GetStationIndex(st->train_tile + TileDiffXY(w - 1, h - 1)) == st->index); + } + } + } + /* in version 2.1 of the savegame, town owner was unified. */ if (CheckSavegameVersionOldStyle(2, 1)) ConvertTownOwner(); -- cgit v1.2.3-70-g09d2