Fix order backup not copying dispatch schedules when not enabled

See: #559
This commit is contained in:
Jonathan G Rennison
2023-07-01 02:17:10 +01:00
parent d09b504bc5
commit 28a764f319
3 changed files with 8 additions and 7 deletions

View File

@@ -56,4 +56,9 @@ void BaseConsist::CopyConsistPropertiesFrom(const BaseConsist *src)
} else { } else {
ClrBit(this->vehicle_flags, VF_TIMETABLE_SEPARATION); ClrBit(this->vehicle_flags, VF_TIMETABLE_SEPARATION);
} }
if (HasBit(src->vehicle_flags, VF_SCHEDULED_DISPATCH)) {
SetBit(this->vehicle_flags, VF_SCHEDULED_DISPATCH);
} else {
ClrBit(this->vehicle_flags, VF_SCHEDULED_DISPATCH);
}
} }

View File

@@ -68,8 +68,7 @@ OrderBackup::OrderBackup(const Vehicle *v, uint32 user)
tail = &copy->next; tail = &copy->next;
} }
if (v->orders != nullptr && HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH)) { if (v->orders != nullptr) {
SetBit(this->vehicle_flags, VF_SCHEDULED_DISPATCH);
this->dispatch_schedules = v->orders->GetScheduledDispatchScheduleSet(); this->dispatch_schedules = v->orders->GetScheduledDispatchScheduleSet();
} }
} }
@@ -90,10 +89,7 @@ void OrderBackup::DoRestore(Vehicle *v)
v->orders = new OrderList(this->orders, v); v->orders = new OrderList(this->orders, v);
this->orders = nullptr; this->orders = nullptr;
if (HasBit(this->vehicle_flags, VF_SCHEDULED_DISPATCH)) { v->orders->GetScheduledDispatchScheduleSet() = std::move(this->dispatch_schedules);
SetBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH);
v->orders->GetScheduledDispatchScheduleSet() = std::move(this->dispatch_schedules);
}
/* Make sure buoys/oil rigs are updated in the station list. */ /* Make sure buoys/oil rigs are updated in the station list. */
InvalidateWindowClassesData(WC_STATION_LIST, 0); InvalidateWindowClassesData(WC_STATION_LIST, 0);

View File

@@ -1432,7 +1432,7 @@ void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags) static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
{ {
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
/* Clear cheduled dispatch flag if any */ /* Clear scheduled dispatch flag if any */
if (HasBit(dst->vehicle_flags, VF_SCHEDULED_DISPATCH)) { if (HasBit(dst->vehicle_flags, VF_SCHEDULED_DISPATCH)) {
ClrBit(dst->vehicle_flags, VF_SCHEDULED_DISPATCH); ClrBit(dst->vehicle_flags, VF_SCHEDULED_DISPATCH);
} }