Mercurial > hg > openttd
changeset 20065:a7ddf82cf8e2 draft
(svn r24998) -Fix [FS#5137]: Set vehicle's service interval is percent flag appropriately on creation (peter1138)
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 14 Feb 2013 17:24:55 +0000 |
parents | 871b52359afb |
children | ab1f34ab3e0d |
files | src/aircraft_cmd.cpp src/base_consist.h src/roadveh_cmd.cpp src/saveload/order_sl.cpp src/saveload/saveload.cpp src/saveload/vehicle_sl.cpp src/ship_cmd.cpp src/train_cmd.cpp src/vehicle_base.h src/vehicle_cmd.cpp |
diffstat | 10 files changed, 30 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -314,6 +314,7 @@ v->vehicle_flags = 0; if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); + v->SetServiceIntervalIsPercent(Company::Get(_current_company)->settings.vehicle.servint_ispercent); v->InvalidateNewGRFCacheOfChain();
--- a/src/base_consist.h +++ b/src/base_consist.h @@ -24,12 +24,12 @@ int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is. Date timetable_start; ///< When the vehicle is supposed to start the timetable. - uint32 service_interval; ///< The interval for (automatic) servicing; either in days or %. + uint16 service_interval; ///< The interval for (automatic) servicing; either in days or %. VehicleOrderID cur_real_order_index;///< The index to the current real (non-implicit) order VehicleOrderID cur_implicit_order_index;///< The index to the current implicit order - byte vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum) + uint16 vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum) BaseConsist() : name(NULL) {} virtual ~BaseConsist();
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -303,6 +303,7 @@ v->gcache.cached_veh_length = VEHICLE_LENGTH; if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); + v->SetServiceIntervalIsPercent(Company::Get(_current_company)->settings.vehicle.servint_ispercent); AddArticulatedParts(v); v->InvalidateNewGRFCacheOfChain();
--- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -251,11 +251,12 @@ SLE_STR(OrderBackup, name, SLE_STR, 0), SLE_VAR(OrderBackup, clone, SLE_UINT16), SLE_VAR(OrderBackup, cur_real_order_index, SLE_UINT8), - SLE_CONDVAR(OrderBackup, cur_implicit_order_index, SLE_UINT8, 176, SL_MAX_VERSION), - SLE_CONDVAR(OrderBackup, current_order_time, SLE_UINT32, 176, SL_MAX_VERSION), - SLE_CONDVAR(OrderBackup, lateness_counter, SLE_INT32, 176, SL_MAX_VERSION), - SLE_CONDVAR(OrderBackup, timetable_start, SLE_INT32, 176, SL_MAX_VERSION), - SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_UINT8, 176, SL_MAX_VERSION), + SLE_CONDVAR(OrderBackup, cur_implicit_order_index, SLE_UINT8, 176, SL_MAX_VERSION), + SLE_CONDVAR(OrderBackup, current_order_time, SLE_UINT32, 176, SL_MAX_VERSION), + SLE_CONDVAR(OrderBackup, lateness_counter, SLE_INT32, 176, SL_MAX_VERSION), + SLE_CONDVAR(OrderBackup, timetable_start, SLE_INT32, 176, SL_MAX_VERSION), + SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_FILE_U8 | SLE_VAR_U16, 176, 179), + SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_UINT16, 180, SL_MAX_VERSION), SLE_REF(OrderBackup, orders, REF_ORDER), SLE_END() };
--- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -243,8 +243,9 @@ * 177 24619 * 178 24789 * 179 24810 + * 180 24998 */ -extern const uint16 SAVEGAME_VERSION = 179; ///< Current savegame version of OpenTTD. +extern const uint16 SAVEGAME_VERSION = 180; ///< Current savegame version of OpenTTD. SavegameType _savegame_type; ///< type of savegame we are loading
--- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -655,8 +655,9 @@ SLE_CONDVAR(Vehicle, max_age, SLE_INT32, 31, SL_MAX_VERSION), SLE_CONDVAR(Vehicle, date_of_last_service, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), SLE_CONDVAR(Vehicle, date_of_last_service, SLE_INT32, 31, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, service_interval, SLE_FILE_U16 | SLE_VAR_U32, 0, 30), - SLE_CONDVAR(Vehicle, service_interval, SLE_UINT32, 31, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, service_interval, SLE_UINT16, 0, 30), + SLE_CONDVAR(Vehicle, service_interval, SLE_FILE_U32 | SLE_VAR_U16, 31, 179), + SLE_CONDVAR(Vehicle, service_interval, SLE_UINT16, 180, SL_MAX_VERSION), SLE_VAR(Vehicle, reliability, SLE_UINT16), SLE_VAR(Vehicle, reliability_spd_dec, SLE_UINT16), SLE_VAR(Vehicle, breakdown_ctr, SLE_UINT8), @@ -668,7 +669,8 @@ SLE_VAR(Vehicle, load_unload_ticks, SLE_UINT16), SLEG_CONDVAR( _cargo_paid_for, SLE_UINT16, 45, SL_MAX_VERSION), - SLE_CONDVAR(Vehicle, vehicle_flags, SLE_UINT8, 40, SL_MAX_VERSION), + SLE_CONDVAR(Vehicle, vehicle_flags, SLE_FILE_U8 | SLE_VAR_U16, 40, 179), + SLE_CONDVAR(Vehicle, vehicle_flags, SLE_UINT16, 180, SL_MAX_VERSION), SLE_CONDVAR(Vehicle, profit_this_year, SLE_FILE_I32 | SLE_VAR_I64, 0, 64), SLE_CONDVAR(Vehicle, profit_this_year, SLE_INT64, 65, SL_MAX_VERSION),
--- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -701,6 +701,7 @@ v->UpdateCache(); if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); + v->SetServiceIntervalIsPercent(Company::Get(_current_company)->settings.vehicle.servint_ispercent); v->InvalidateNewGRFCacheOfChain();
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -743,6 +743,7 @@ v->random_bits = VehicleRandomBits(); if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE); + v->SetServiceIntervalIsPercent(Company::Get(_current_company)->settings.vehicle.servint_ispercent); v->group_id = DEFAULT_GROUP;
--- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -45,6 +45,8 @@ VF_AUTOFILL_PRES_WAIT_TIME, ///< Whether non-destructive auto-fill should preserve waiting times VF_STOP_LOADING, ///< Don't load anymore during the next load cycle. VF_PATHFINDER_LOST, ///< Vehicle's pathfinder is lost. + VF_SERVINT_IS_CUSTOM, ///< Service interval is custom. + VF_SERVINT_IS_PERCENT, ///< Service interval is percent. }; /** Bit numbers used to indicate which of the #NewGRFCache values are valid. */ @@ -645,16 +647,17 @@ void UpdateVisualEffect(bool allow_power_change = true); void ShowVisualEffect() const; - inline uint16 GetServiceInterval() const { return GB(this->service_interval, 0, 16); } - inline void SetServiceInterval(uint16 interval) { SB(this->service_interval, 0, 16, interval); } + inline uint16 GetServiceInterval() const { return this->service_interval; } - inline bool ServiceIntervalIsCustom() const { return HasBit(this->service_interval, 31); } + inline void SetServiceInterval(uint16 interval) { this->service_interval = interval; } + + inline bool ServiceIntervalIsCustom() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_CUSTOM); } - inline bool ServiceIntervalIsPercent() const { return HasBit(this->service_interval, 30); } + inline bool ServiceIntervalIsPercent() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_PERCENT); } - inline void SetServiceIntervalIsCustom(bool on) { SB(this->service_interval, 31, 1, on); } + inline void SetServiceIntervalIsCustom(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_CUSTOM, 1, on); } - inline void SetServiceIntervalIsPercent(bool on) { SB(this->service_interval, 30, 1, on); } + inline void SetServiceIntervalIsPercent(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_PERCENT, 1, on); } private: /**
--- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -843,6 +843,8 @@ /* this is a front engine or not a train. */ w_front = w; w->service_interval = v->service_interval; + w->SetServiceIntervalIsCustom(v->ServiceIntervalIsCustom()); + w->SetServiceIntervalIsPercent(v->ServiceIntervalIsPercent()); } w_rear = w; // trains needs to know the last car in the train, so they can add more in next loop }