diff options
author | smatz <smatz@openttd.org> | 2008-12-20 01:35:12 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-12-20 01:35:12 +0000 |
commit | c6c3124c30e5aef9371eff42c90e9d00fc528322 (patch) | |
tree | 2e5026c17011a6b8a6d73ea849156242e69cae97 /src/openttd.cpp | |
parent | 6afd6a450fd29c164028dbd8337181c1cee8d0e2 (diff) | |
download | openttd-c6c3124c30e5aef9371eff42c90e9d00fc528322.tar.xz |
(svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r-- | src/openttd.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
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(); |