From ece7f8401f5eed7ba7e5025af514fad3c77e6082 Mon Sep 17 00:00:00 2001 From: J0anJosep Date: Sat, 26 Aug 2023 17:52:41 +0200 Subject: [PATCH] Change: Add a wait counter for all vehicle types. --- src/saveload/vehicle_sl.cpp | 4 +++- src/vehicle_base.h | 25 +++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 4e42de3962..f28d04b0e5 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -665,6 +665,7 @@ public: SLE_VAR(Vehicle, progress, SLE_UINT8), SLE_VAR(Vehicle, vehstatus, SLE_UINT8), + SLE_CONDVAR(Vehicle, wait_counter, SLE_UINT16, SLV_EXTENDED_DEPOTS, SL_MAX_VERSION), SLE_CONDVAR(Vehicle, last_station_visited, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_5), SLE_CONDVAR(Vehicle, last_station_visited, SLE_UINT16, SLV_5, SL_MAX_VERSION), SLE_CONDVAR(Vehicle, last_loading_station, SLE_UINT16, SLV_182, SL_MAX_VERSION), @@ -793,7 +794,7 @@ public: SLE_CONDVAR(Train, flags, SLE_FILE_U8 | SLE_VAR_U16, SLV_2, SLV_100), SLE_CONDVAR(Train, flags, SLE_UINT16, SLV_100, SL_MAX_VERSION), - SLE_CONDVAR(Train, wait_counter, SLE_UINT16, SLV_136, SL_MAX_VERSION), + SLE_CONDVAR(Train, wait_counter, SLE_UINT16, SLV_136, SLV_EXTENDED_DEPOTS), SLE_CONDVAR(Train, gv_flags, SLE_UINT16, SLV_139, SL_MAX_VERSION), }; inline const static SaveLoadCompatTable compat_description = _vehicle_train_sl_compat; @@ -1072,6 +1073,7 @@ struct VEHSChunkHandler : ChunkHandler { default: SlErrorCorrupt("Invalid vehicle type"); } + if (IsSavegameVersionBefore(SLV_EXTENDED_DEPOTS)) assert(v->type == VEH_TRAIN || v->wait_counter == 0); SlObject(v, slt); if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v) && CargoPacket::CanAllocateItem()) { diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 65fac6e103..b13e6bda8e 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -313,23 +313,24 @@ public: * 0xff == reserved for another custom sprite */ uint8_t spritenum; - uint8_t x_extent; ///< x-extent of vehicle bounding box - uint8_t y_extent; ///< y-extent of vehicle bounding box - uint8_t z_extent; ///< z-extent of vehicle bounding box - int8_t x_bb_offs; ///< x offset of vehicle bounding box - int8_t y_bb_offs; ///< y offset of vehicle bounding box - int8_t x_offs; ///< x offset for vehicle sprite - int8_t y_offs; ///< y offset for vehicle sprite + uint8_t x_extent; ///< x-extent of vehicle bounding box + uint8_t y_extent; ///< y-extent of vehicle bounding box + uint8_t z_extent; ///< z-extent of vehicle bounding box + int8_t x_bb_offs; ///< x offset of vehicle bounding box + int8_t y_bb_offs; ///< y offset of vehicle bounding box + int8_t x_offs; ///< x offset for vehicle sprite + int8_t y_offs; ///< y offset for vehicle sprite EngineID engine_type; ///< The type of engine used for this vehicle. TextEffectID fill_percent_te_id; ///< a text-effect id to a loading indicator object UnitID unitnumber; ///< unit number, for display purposes only - uint16_t cur_speed; ///< current speed - uint8_t subspeed; ///< fractional speed - uint8_t acceleration; ///< used by train & aircraft - uint32_t motion_counter; ///< counter to occasionally play a vehicle sound. - uint8_t progress; ///< The percentage (if divided by 256) this vehicle already crossed the tile unit. + uint16_t cur_speed; ///< current speed + uint8_t subspeed; ///< fractional speed + uint8_t acceleration; ///< used by train & aircraft + uint32_t motion_counter; ///< counter to occasionally play a vehicle sound. + uint16_t wait_counter; ///< waiting ticks (servicing, waiting in front of a signal or forced proceeding) + uint8_t progress; ///< The percentage (if divided by 256) this vehicle already crossed the tile unit. uint8_t waiting_triggers; ///< Triggers to be yet matched before rerandomizing the random bits. uint16_t random_bits; ///< Bits used for randomized variational spritegroups.