Scheduled dispatch: Simplify schedule copying

This commit is contained in:
Jonathan G Rennison
2019-10-07 21:21:43 +01:00
parent ef4055a7dc
commit 0472327ef1
3 changed files with 30 additions and 13 deletions

View File

@@ -266,6 +266,17 @@ CommandCost CmdScheduledDispatchResetLastDispatch(TileIndex tile, DoCommandFlag
return CommandCost();
}
/**
* Set scheduled dispatch slot list.
* @param dispatch_list The offset time list, must be correctly sorted.
*/
void OrderList::SetScheduledDispatch(std::vector<uint32> dispatch_list)
{
this->scheduled_dispatch = std::move(dispatch_list);
assert(std::is_sorted(this->scheduled_dispatch.begin(), this->scheduled_dispatch.end()));
this->UpdateScheduledDispatch();
}
/**
* Add new scheduled dispatch slot at offsets time.
* @param offset The offset time to add.
@@ -329,7 +340,7 @@ void OrderList::UpdateScheduledDispatch()
void OrderList::ResetScheduledDispatch()
{
uint32 windex = this->first_shared->index;
Date start_date;
uint16 start_full_date_fract;
uint32 duration;
@@ -350,7 +361,7 @@ void OrderList::ResetScheduledDispatch()
start_full_date_fract = 0;
duration = 365*DAY_TICKS;
}
DoCommandP(0, windex, duration, CMD_SCHEDULED_DISPATCH_SET_DURATION | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
uint32 p1 = 0, p2 = 0;