@@ -157,25 +157,25 @@ CommandCost CmdChangeTimetable(TileIndex
* @param flags Operation to perform.
* @param p1 Various bitstuffed elements
* - p1 = (bit 0-19) - Vehicle with the orders to change.
* @param p2 unused
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
VehicleID veh = GB(p1, 0, 20);
Vehicle *v = Vehicle::GetIfValid(veh);
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
if (v == NULL || !v->IsPrimaryVehicle() || v->orders.list == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
v->lateness_counter = 0;
SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
}
return CommandCost();
@@ -226,25 +226,25 @@ static int CDECL VehicleTimetableSorter(
* @param p2 Various bitstuffed elements
* - p2 = (bit 0-19) - Vehicle ID.
* - p2 = (bit 20) - Set to 1 to set timetable start for all vehicles sharing this order
* @param p2 The timetable start date.
* @param text Not used.
* @return The error or cost of the operation.
CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
bool timetable_all = HasBit(p1, 20);
Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
Date start_date = (Date)p2;
if (start_date < 0 || start_date > MAX_DAY) return CMD_ERROR;
if (start_date - _date > 15 * DAYS_IN_LEAP_YEAR) return CMD_ERROR;
if (_date - start_date > DAYS_IN_LEAP_YEAR) return CMD_ERROR;
if (timetable_all && !v->orders.list->IsCompleteTimetable()) return CMD_ERROR;
@@ -293,25 +293,25 @@ CommandCost CmdSetTimetableStart(TileInd
* @param p1 Vehicle index.
* - p2 = (bit 0) - Set to 1 to enable, 0 to disable autofill.
* - p2 = (bit 1) - Set to 1 to preserve waiting times in non-destructive mode
CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
if (HasBit(p2, 0)) {
/* Start autofilling the timetable, which clears the
* "timetable has started" bit. Times are not cleared anymore, but are
* overwritten when the order is reached now. */
SetBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE);
ClrBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
@@ -319,27 +319,27 @@ struct TimetableWindow : Window {
} else {
disable = order == NULL || ((!order->IsType(OT_GOTO_STATION) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) && !order->IsType(OT_CONDITIONAL));
bool disable_speed = disable || selected % 2 != 1 || v->type == VEH_AIRCRAFT;
this->SetWidgetDisabledState(WID_VT_CHANGE_TIME, disable);
this->SetWidgetDisabledState(WID_VT_CLEAR_TIME, disable);
this->SetWidgetDisabledState(WID_VT_CHANGE_SPEED, disable_speed);
this->SetWidgetDisabledState(WID_VT_CLEAR_SPEED, disable_speed);
this->SetWidgetDisabledState(WID_VT_SHARED_ORDER_LIST, !v->IsOrderListShared());
this->EnableWidget(WID_VT_START_DATE);
this->EnableWidget(WID_VT_RESET_LATENESS);
this->EnableWidget(WID_VT_AUTOFILL);
this->SetWidgetDisabledState(WID_VT_START_DATE, v->orders.list == NULL);
this->SetWidgetDisabledState(WID_VT_RESET_LATENESS, v->orders.list == NULL);
this->SetWidgetDisabledState(WID_VT_AUTOFILL, v->orders.list == NULL);
this->DisableWidget(WID_VT_START_DATE);
this->DisableWidget(WID_VT_CHANGE_TIME);
this->DisableWidget(WID_VT_CLEAR_TIME);
this->DisableWidget(WID_VT_CHANGE_SPEED);
this->DisableWidget(WID_VT_CLEAR_SPEED);
this->DisableWidget(WID_VT_RESET_LATENESS);
this->DisableWidget(WID_VT_AUTOFILL);
this->DisableWidget(WID_VT_SHARED_ORDER_LIST);
this->SetWidgetLoweredState(WID_VT_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
Status change: