diff options
author | rubidium <rubidium@openttd.org> | 2013-02-14 17:24:55 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-02-14 17:24:55 +0000 |
commit | ced17303c2a721560e31fb035fd331be4518e298 (patch) | |
tree | 81ff122d1c26d62c87e5fd3290abda9c8c6bffa0 | |
parent | 3d7860e0a5490b0f008a4abca024b94311593fc1 (diff) | |
download | openttd-ced17303c2a721560e31fb035fd331be4518e298.tar.xz |
(svn r24998) -Fix [FS#5137]: Set vehicle's service interval is percent flag appropriately on creation (peter1138)
-rw-r--r-- | src/aircraft_cmd.cpp | 1 | ||||
-rw-r--r-- | src/base_consist.h | 4 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 1 | ||||
-rw-r--r-- | src/saveload/order_sl.cpp | 11 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 3 | ||||
-rw-r--r-- | src/saveload/vehicle_sl.cpp | 8 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 1 | ||||
-rw-r--r-- | src/train_cmd.cpp | 1 | ||||
-rw-r--r-- | src/vehicle_base.h | 15 | ||||
-rw-r--r-- | src/vehicle_cmd.cpp | 2 |
10 files changed, 30 insertions, 17 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index af388c0ed..385eb9be1 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -314,6 +314,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine * 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(); diff --git a/src/base_consist.h b/src/base_consist.h index 0ea13b3f2..3679afd35 100644 --- a/src/base_consist.h +++ b/src/base_consist.h @@ -24,12 +24,12 @@ struct BaseConsist { 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(); diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index e58acee5a..e740e26f9 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -303,6 +303,7 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin 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(); diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp index 5b7fa535e..4d2a4b02e 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -251,11 +251,12 @@ const SaveLoad *GetOrderBackupDescription() 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() }; diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 7fa763a86..a21f6242a 100644 --- 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 diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index aebde2bb0..a33ceb6d3 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -655,8 +655,9 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) 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 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) 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), diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 1bc0dc999..55c695603 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -701,6 +701,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, const Engine *e, u 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(); diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index a6fe72048..a01612511 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -743,6 +743,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engin 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; diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 3343359d5..f0502a218 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -45,6 +45,8 @@ enum VehicleFlags { 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 @@ public: 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 ServiceIntervalIsPercent() const { return HasBit(this->service_interval, 30); } + inline bool ServiceIntervalIsCustom() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_CUSTOM); } - inline void SetServiceIntervalIsCustom(bool on) { SB(this->service_interval, 31, 1, on); } + inline bool ServiceIntervalIsPercent() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_PERCENT); } - inline void SetServiceIntervalIsPercent(bool on) { SB(this->service_interval, 30, 1, on); } + inline void SetServiceIntervalIsCustom(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_CUSTOM, 1, on); } + + inline void SetServiceIntervalIsPercent(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_PERCENT, 1, on); } private: /** diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 98eb6a989..7271d27b0 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -843,6 +843,8 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint /* 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 } |