Jump counter is no longer a separate field

pull/199/head
Jonathan G Rennison 4 years ago
parent 6e17f9bf5d
commit b9f7db9c7e

@ -77,7 +77,6 @@ private:
CargoID refit_cargo; ///< Refit CargoID
uint8 occupancy; ///< Estimate of vehicle occupancy on departure, for the current order, 0 indicates invalid, 1 - 101 indicate 0 - 100%
int8 jump_counter; ///< Counter for the 'jump xx% of times' option
std::unique_ptr<OrderExtraInfo> extra; ///< Extra order info
@ -325,6 +324,8 @@ public:
inline VehicleOrderID GetConditionSkipToOrder() const { return this->flags; }
/** Get the value to base the skip on. */
inline uint16 GetConditionValue() const { return GB(this->dest, 0, 11); }
/** Get counter for the 'jump xx% of times' option */
inline int8 GetJumpCounter() const { return GB(this->GetXData(), 0, 8); }
/** Set how the consist must be loaded. */
inline void SetLoadType(OrderLoadFlags load_type)
@ -384,6 +385,8 @@ public:
inline void SetConditionSkipToOrder(VehicleOrderID order_id) { this->flags = order_id; }
/** Set the value to base the skip on. */
inline void SetConditionValue(uint16 value) { SB(this->dest, 0, 11, value); }
/** Get counter for the 'jump xx% of times' option */
inline void SetJumpCounter(int8 jump_counter) { SB(this->GetXDataRef(), 0, 8, jump_counter); }
/* As conditional orders write their "skip to" order all over the flags, we cannot check the
* flags to find out if timetabling is enabled. However, as conditional orders are never

@ -176,12 +176,13 @@ void Order::MakeLoading(bool ordered)
*/
bool Order::UpdateJumpCounter(byte percent, bool dry_run)
{
if (dry_run) return this->jump_counter >= 0;
if (this->jump_counter >= 0) {
this->jump_counter += (percent - 100);
const int8 jump_counter = this->GetJumpCounter();
if (dry_run) return jump_counter >= 0;
if (jump_counter >= 0) {
this->SetJumpCounter(jump_counter + (percent - 100));
return true;
}
this->jump_counter += percent;
this->SetJumpCounter(jump_counter + percent);
return false;
}
@ -320,7 +321,6 @@ Order::Order(uint32 packed)
this->occupancy = 0;
this->wait_time = 0;
this->travel_time = 0;
this->jump_counter = 0;
this->max_speed = UINT16_MAX;
}
@ -361,7 +361,6 @@ void Order::AssignOrder(const Order &other)
this->wait_time = other.wait_time;
this->jump_counter = other.jump_counter;
this->travel_time = other.travel_time;
this->max_speed = other.max_speed;

@ -91,7 +91,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_INFRA_SHARING, XSCF_NULL, 2, 2, "infra_sharing", nullptr, nullptr, "CPDP" },
{ XSLFI_VARIABLE_DAY_LENGTH, XSCF_NULL, 2, 2, "variable_day_length", nullptr, nullptr, nullptr },
{ XSLFI_ORDER_OCCUPANCY, XSCF_NULL, 2, 2, "order_occupancy", nullptr, nullptr, nullptr },
{ XSLFI_MORE_COND_ORDERS, XSCF_NULL, 6, 6, "more_cond_orders", nullptr, nullptr, nullptr },
{ XSLFI_MORE_COND_ORDERS, XSCF_NULL, 7, 7, "more_cond_orders", nullptr, nullptr, nullptr },
{ XSLFI_EXTRA_LARGE_MAP, XSCF_NULL, 0, 1, "extra_large_map", nullptr, nullptr, nullptr },
{ XSLFI_REVERSE_AT_WAYPOINT, XSCF_NULL, 1, 1, "reverse_at_waypoint", nullptr, nullptr, nullptr },
{ XSLFI_VEH_LIFETIME_PROFIT, XSCF_NULL, 1, 1, "veh_lifetime_profit", nullptr, nullptr, nullptr },

@ -119,7 +119,7 @@ const SaveLoad *GetOrderDescription()
SLE_CONDVAR_X(Order, travel_time, SLE_FILE_U16 | SLE_VAR_U32, SLV_67, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TIMETABLE_EXTRA, 0, 5)),
SLE_CONDVAR_X(Order, travel_time, SLE_UINT32, SLV_67, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_TIMETABLE_EXTRA, 6)),
SLE_CONDVAR(Order, max_speed, SLE_UINT16, SLV_172, SL_MAX_VERSION),
SLE_CONDVAR_X(Order, jump_counter, SLE_INT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MORE_COND_ORDERS)),
SLE_CONDNULL_X(1, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_MORE_COND_ORDERS, 1, 6)), // jump_counter
/* Leftover from the minor savegame version stuff
* We will never use those free bytes, but we have to keep this line to allow loading of old savegames */

Loading…
Cancel
Save