(svn r22713) -Feature: [NewGRF] Per vehicle custom cargo ageing period.

This commit is contained in:
michi_cc
2011-08-03 20:55:08 +00:00
parent 9ccf86eafb
commit d25840978c
17 changed files with 74 additions and 16 deletions

View File

@@ -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

View File

@@ -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 ),

View File

@@ -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

View File

@@ -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),