Scheduled dispatch: Add order backup support
This commit is contained in:
@@ -65,6 +65,15 @@ OrderBackup::OrderBackup(const Vehicle *v, uint32 user)
|
||||
*tail = copy;
|
||||
tail = ©->next;
|
||||
}
|
||||
|
||||
if (v->orders.list != nullptr && HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH)) {
|
||||
SetBit(this->vehicle_flags, VF_SCHEDULED_DISPATCH);
|
||||
this->scheduled_dispatch = v->orders.list->GetScheduledDispatch();
|
||||
this->scheduled_dispatch_duration = v->orders.list->GetScheduledDispatchDuration();
|
||||
this->scheduled_dispatch_start_date = v->orders.list->GetScheduledDispatchStartDatePart();
|
||||
this->scheduled_dispatch_start_full_date_fract = v->orders.list->GetScheduledDispatchStartDateFractPart();
|
||||
this->scheduled_dispatch_max_delay = v->orders.list->GetScheduledDispatchDelay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +89,17 @@ void OrderBackup::DoRestore(Vehicle *v)
|
||||
} else if (this->orders != nullptr && OrderList::CanAllocateItem()) {
|
||||
v->orders.list = new OrderList(this->orders, v);
|
||||
this->orders = nullptr;
|
||||
|
||||
if (HasBit(this->vehicle_flags, VF_SCHEDULED_DISPATCH)) {
|
||||
SetBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH);
|
||||
v->orders.list->SetScheduledDispatchDuration(this->scheduled_dispatch_duration);
|
||||
v->orders.list->SetScheduledDispatchDelay(this->scheduled_dispatch_max_delay);
|
||||
v->orders.list->SetScheduledDispatchStartDate(this->scheduled_dispatch_start_date,
|
||||
this->scheduled_dispatch_start_full_date_fract);
|
||||
v->orders.list->SetScheduledDispatchLastDispatch(0);
|
||||
v->orders.list->SetScheduledDispatch(std::move(this->scheduled_dispatch));
|
||||
}
|
||||
|
||||
/* Make sure buoys/oil rigs are updated in the station list. */
|
||||
InvalidateWindowClassesData(WC_STATION_LIST, 0);
|
||||
}
|
||||
|
@@ -45,6 +45,13 @@ private:
|
||||
const Vehicle *clone; ///< Vehicle this vehicle was a clone of.
|
||||
Order *orders; ///< The actual orders if the vehicle was not a clone.
|
||||
|
||||
std::vector<uint32> scheduled_dispatch; ///< Scheduled dispatch time
|
||||
uint32 scheduled_dispatch_duration; ///< Scheduled dispatch duration
|
||||
Date scheduled_dispatch_start_date; ///< Scheduled dispatch start date
|
||||
uint16 scheduled_dispatch_start_full_date_fract;///< Scheduled dispatch start full date fraction;
|
||||
/// this count to (DAY_TICK * _settings_game.economy.day_length_factor)
|
||||
int32 scheduled_dispatch_max_delay; ///< Maximum allowed delay
|
||||
|
||||
/** Creation for savegame restoration. */
|
||||
OrderBackup() {}
|
||||
OrderBackup(const Vehicle *v, uint32 user);
|
||||
|
@@ -89,7 +89,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
||||
{ XSLFI_STATION_CATCHMENT_INC, XSCF_NULL, 1, 1, "station_catchment_inc", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_CUSTOM_BRIDGE_HEADS, XSCF_NULL, 2, 2, "custom_bridge_heads", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_CHUNNEL, XSCF_NULL, 2, 2, "chunnel", nullptr, nullptr, "TUNN" },
|
||||
{ XSLFI_SCHEDULED_DISPATCH, XSCF_NULL, 1, 1, "scheduled_dispatch", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_SCHEDULED_DISPATCH, XSCF_NULL, 2, 2, "scheduled_dispatch", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_MORE_TOWN_GROWTH_RATES, XSCF_NULL, 1, 1, "more_town_growth_rates", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_MULTIPLE_DOCKS, XSCF_NULL, 2, 2, "multiple_docks", nullptr, nullptr, nullptr },
|
||||
{ XSLFI_TIMETABLE_EXTRA, XSCF_NULL, 6, 6, "timetable_extra", nullptr, nullptr, "ORDX" },
|
||||
|
@@ -318,6 +318,11 @@ const SaveLoad *GetOrderBackupDescription()
|
||||
SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_FILE_U8 | SLE_VAR_U16, SLV_176, SLV_180),
|
||||
SLE_CONDVAR(OrderBackup, vehicle_flags, SLE_UINT16, SLV_180, SL_MAX_VERSION),
|
||||
SLE_REF(OrderBackup, orders, REF_ORDER),
|
||||
SLE_CONDVARVEC_X(OrderBackup, scheduled_dispatch, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_SCHEDULED_DISPATCH, 2)),
|
||||
SLE_CONDVAR_X(OrderBackup, scheduled_dispatch_duration, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_SCHEDULED_DISPATCH, 2)),
|
||||
SLE_CONDVAR_X(OrderBackup, scheduled_dispatch_start_date, SLE_INT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_SCHEDULED_DISPATCH, 2)),
|
||||
SLE_CONDVAR_X(OrderBackup, scheduled_dispatch_start_full_date_fract, SLE_UINT16, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_SCHEDULED_DISPATCH, 2)),
|
||||
SLE_CONDVAR_X(OrderBackup, scheduled_dispatch_max_delay, SLE_INT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_SCHEDULED_DISPATCH, 2)),
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user