1
0
Fork 0

Change: Add a wait counter for all vehicle types.

pull/8480/head
J0anJosep 2023-08-26 17:52:41 +02:00
parent 08f4ae4b3d
commit ece7f8401f
2 changed files with 16 additions and 13 deletions

View File

@ -665,6 +665,7 @@ public:
SLE_VAR(Vehicle, progress, SLE_UINT8), SLE_VAR(Vehicle, progress, SLE_UINT8),
SLE_VAR(Vehicle, vehstatus, 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_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_station_visited, SLE_UINT16, SLV_5, SL_MAX_VERSION),
SLE_CONDVAR(Vehicle, last_loading_station, SLE_UINT16, SLV_182, 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_FILE_U8 | SLE_VAR_U16, SLV_2, SLV_100),
SLE_CONDVAR(Train, flags, SLE_UINT16, SLV_100, SL_MAX_VERSION), 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), SLE_CONDVAR(Train, gv_flags, SLE_UINT16, SLV_139, SL_MAX_VERSION),
}; };
inline const static SaveLoadCompatTable compat_description = _vehicle_train_sl_compat; inline const static SaveLoadCompatTable compat_description = _vehicle_train_sl_compat;
@ -1072,6 +1073,7 @@ struct VEHSChunkHandler : ChunkHandler {
default: SlErrorCorrupt("Invalid vehicle type"); default: SlErrorCorrupt("Invalid vehicle type");
} }
if (IsSavegameVersionBefore(SLV_EXTENDED_DEPOTS)) assert(v->type == VEH_TRAIN || v->wait_counter == 0);
SlObject(v, slt); SlObject(v, slt);
if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v) && CargoPacket::CanAllocateItem()) { if (_cargo_count != 0 && IsCompanyBuildableVehicleType(v) && CargoPacket::CanAllocateItem()) {

View File

@ -313,23 +313,24 @@ public:
* 0xff == reserved for another custom sprite * 0xff == reserved for another custom sprite
*/ */
uint8_t spritenum; uint8_t spritenum;
uint8_t x_extent; ///< x-extent of vehicle bounding box uint8_t x_extent; ///< x-extent of vehicle bounding box
uint8_t y_extent; ///< y-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 uint8_t z_extent; ///< z-extent of vehicle bounding box
int8_t x_bb_offs; ///< x offset 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 y_bb_offs; ///< y offset of vehicle bounding box
int8_t x_offs; ///< x offset for vehicle sprite int8_t x_offs; ///< x offset for vehicle sprite
int8_t y_offs; ///< y offset for vehicle sprite int8_t y_offs; ///< y offset for vehicle sprite
EngineID engine_type; ///< The type of engine used for this vehicle. 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 TextEffectID fill_percent_te_id; ///< a text-effect id to a loading indicator object
UnitID unitnumber; ///< unit number, for display purposes only UnitID unitnumber; ///< unit number, for display purposes only
uint16_t cur_speed; ///< current speed uint16_t cur_speed; ///< current speed
uint8_t subspeed; ///< fractional speed uint8_t subspeed; ///< fractional speed
uint8_t acceleration; ///< used by train & aircraft uint8_t acceleration; ///< used by train & aircraft
uint32_t motion_counter; ///< counter to occasionally play a vehicle sound. 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 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. uint8_t waiting_triggers; ///< Triggers to be yet matched before rerandomizing the random bits.
uint16_t random_bits; ///< Bits used for randomized variational spritegroups. uint16_t random_bits; ///< Bits used for randomized variational spritegroups.