Scheduled dispatch: Add clear schedule GUI function

Add management dropdown box to window
This commit is contained in:
Jonathan G Rennison
2021-12-18 12:46:25 +00:00
parent 7b0c083c11
commit 66ce6c5090
6 changed files with 79 additions and 5 deletions

View File

@@ -276,6 +276,36 @@ CommandCost CmdScheduledDispatchResetLastDispatch(TileIndex tile, DoCommandFlag
return CommandCost();
}
/**
* Clear scheduled dispatch schedule
*
* @param tile Not used.
* @param flags Operation to perform.
* @param p1 Vehicle index
* @param p2 Not used
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdScheduledDispatchClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
VehicleID veh = GB(p1, 0, 20);
Vehicle *v = Vehicle::GetIfValid(veh);
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
if (ret.Failed()) return ret;
if (v->orders.list == nullptr) return CMD_ERROR;
if (flags & DC_EXEC) {
v->orders.list->ClearScheduledDispatch();
SetWindowDirty(WC_SCHDISPATCH_SLOTS, v->index);
}
return CommandCost();
}
/**
* Set scheduled dispatch slot list.
* @param dispatch_list The offset time list, must be correctly sorted.