Mercurial > hg > openttd
changeset 10445:642c4c52707d draft
(svn r14700) -Fix (r1): loading of very old savegames was broken (STNS chunk is stored before MAP in old savegame)
author | smatz <smatz@openttd.org> |
---|---|
date | Sat, 20 Dec 2008 01:35:12 +0000 |
parents | 368a9eb9207e |
children | b90baa371bc6 |
files | src/oldloader.cpp src/openttd.cpp src/station_cmd.cpp |
diffstat | 3 files changed, 21 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -325,18 +325,6 @@ } } -static void FixOldStations() -{ - Station *st; - - FOR_ALL_STATIONS(st) { - /* Check if we need to swap width and height for the station */ - if (st->train_tile != 0 && GetRailStationAxis(st->train_tile) != AXIS_X) { - Swap(st->trainst_w, st->trainst_h); - } - } -} - static StringID *_old_vehicle_names = NULL; static void FixOldVehicles() @@ -614,7 +602,6 @@ return true; } -static uint8 _old_platforms; static uint _current_station_id; static uint16 _waiting_acceptance; static uint8 _cargo_source; @@ -659,8 +646,7 @@ OCL_SVAR( OC_TILE, Station, train_tile ), OCL_SVAR( OC_TILE, Station, airport_tile ), OCL_SVAR( OC_TILE, Station, dock_tile ), - - OCL_VAR ( OC_UINT8, 1, &_old_platforms ), + OCL_SVAR( OC_UINT8, Station, trainst_w ), OCL_NULL( 1 ), ///< sort-index, no longer in use OCL_NULL( 2 ), ///< sign-width, no longer in use @@ -700,14 +686,6 @@ return false; if (st->IsValid()) { - if (st->train_tile) { - /* Calculate the trainst_w and trainst_h */ - uint w = GB(_old_platforms, 3, 3); - uint h = GB(_old_platforms, 0, 3); - st->trainst_w = w; - st->trainst_h = h; - } - st->town = GetTown(REMAP_TOWN_IDX(_old_town_index)); st->string_id = RemapOldStringID(_old_string_id); } @@ -1692,7 +1670,6 @@ /* Fix the game to be compatible with OpenTTD */ FixOldTowns(); - FixOldStations(); FixOldVehicles(); /* We have a new difficulty setting */
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1326,6 +1326,26 @@ 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();
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3420,16 +3420,6 @@ Station *st = new (index) Station(); SaveLoad_STNS(st); - - /* this means it's an oldstyle savegame without support for nonuniform stations */ - if (st->train_tile != 0 && st->trainst_h == 0) { - uint w = GB(st->trainst_w, 4, 4); - uint h = GB(st->trainst_w, 0, 4); - - if (GetRailStationAxis(st->train_tile) != AXIS_X) Swap(w, h); - st->trainst_w = w; - st->trainst_h = h; - } } /* This is to ensure all pointers are within the limits of _stations_size */