diff options
author | michi_cc <michi_cc@openttd.org> | 2011-08-03 20:55:08 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-08-03 20:55:08 +0000 |
commit | 08b7981f37431f57ca2fa8dd25db4088c7c69d4e (patch) | |
tree | d55fa560c79768b03077cb544552875e8064d17e /src/saveload | |
parent | 442b92ff33c31317f77786f23539c2566f8252f3 (diff) | |
download | openttd-08b7981f37431f57ca2fa8dd25db4088c7c69d4e.tar.xz |
(svn r22713) -Feature: [NewGRF] Per vehicle custom cargo ageing period.
Diffstat (limited to 'src/saveload')
-rw-r--r-- | src/saveload/misc_sl.cpp | 5 | ||||
-rw-r--r-- | src/saveload/oldloader_sl.cpp | 1 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 3 | ||||
-rw-r--r-- | src/saveload/vehicle_sl.cpp | 10 |
4 files changed, 16 insertions, 3 deletions
diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp index 2f3827ce9..ccfc7a2d3 100644 --- a/src/saveload/misc_sl.cpp +++ b/src/saveload/misc_sl.cpp @@ -60,6 +60,7 @@ void ResetViewportAfterLoadGame() MarkWholeScreenDirty(); } +byte _age_cargo_skip_counter; ///< Skip aging of cargo? Used before savegame version 162. static const SaveLoadGlobVarList _date_desc[] = { SLEG_CONDVAR(_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), @@ -67,7 +68,7 @@ static const SaveLoadGlobVarList _date_desc[] = { SLEG_VAR(_date_fract, SLE_UINT16), SLEG_VAR(_tick_counter, SLE_UINT16), SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day - SLEG_VAR(_age_cargo_skip_counter, SLE_UINT8), + SLEG_CONDVAR(_age_cargo_skip_counter, SLE_UINT8, 0, 161), SLE_CONDNULL(1, 0, 45), SLEG_CONDVAR(_cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), SLEG_CONDVAR(_cur_tileloop_tile, SLE_UINT32, 6, SL_MAX_VERSION), @@ -92,7 +93,7 @@ static const SaveLoadGlobVarList _date_check_desc[] = { SLE_NULL(2), // _date_fract SLE_NULL(2), // _tick_counter SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day - SLE_NULL(1), // _age_cargo_skip_counter + SLE_CONDNULL(1, 0, 161), // _age_cargo_skip_counter SLE_CONDNULL(1, 0, 45), SLE_CONDNULL(2, 0, 5), // _cur_tileloop_tile SLE_CONDNULL(4, 6, SL_MAX_VERSION), // _cur_tileloop_tile diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 7f1722e0f..d4ff3758a 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -1573,6 +1573,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num) extern TileIndex _cur_tileloop_tile; extern uint16 _disaster_delay; extern byte _trees_tick_ctr; +extern byte _age_cargo_skip_counter; // From misc_sl.cpp static const OldChunks main_chunk[] = { OCL_ASSERT( OC_TTD, 0 ), OCL_ASSERT( OC_TTO, 0 ), diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 486d1d8e5..162776533 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -226,8 +226,9 @@ * 159 21962 * 160 21974 * 161 22567 + * 162 22713 */ -extern const uint16 SAVEGAME_VERSION = 161; ///< Current savegame version of OpenTTD. +extern const uint16 SAVEGAME_VERSION = 162; ///< Current savegame version of OpenTTD. SavegameType _savegame_type; ///< type of savegame we are loading diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index b9b2d53ce..ff738c7e2 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -237,6 +237,8 @@ static void CheckValidVehicles() } } +extern byte _age_cargo_skip_counter; // From misc_sl.cpp + /** Called after load to update coordinates */ void AfterLoadVehicles(bool part_of_load) { @@ -342,6 +344,13 @@ void AfterLoadVehicles(bool part_of_load) } } } + + if (IsSavegameVersionBefore(162)) { + /* Set the vehicle-local cargo age counter from the old global counter. */ + FOR_ALL_VEHICLES(v) { + v->cargo_age_counter = _age_cargo_skip_counter; + } + } } CheckValidVehicles(); @@ -499,6 +508,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_VAR(Vehicle, cargo_cap, SLE_UINT16), SLEG_CONDVAR( _cargo_count, SLE_UINT16, 0, 67), SLE_CONDLST(Vehicle, cargo.packets, REF_CARGO_PACKET, 68, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, cargo_age_counter, SLE_UINT16, 162, SL_MAX_VERSION), SLE_VAR(Vehicle, day_counter, SLE_UINT8), SLE_VAR(Vehicle, tick_counter, SLE_UINT8), |