OpenTTD Source: src/timetable_cmd.h File Reference

OpenTTD Source 14.1

Functions
timetable_cmd.h File Reference
`#include "command_type.h"`
`#include "timer/timer_game_tick.h"`

Go to the source code of this file.

## Functions
CommandCost | CmdChangeTimetable (DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data)
| Change timetable data of an order. More...
CommandCost | CmdBulkChangeTimetable (DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data)
| Change timetable data of all orders of a vehicle. More...
CommandCost | CmdSetVehicleOnTime (DoCommandFlag flags, VehicleID veh, bool apply_to_group)
| Clear the lateness counter to make the vehicle on time. More...
CommandCost | CmdAutofillTimetable (DoCommandFlag flags, VehicleID veh, bool autofill, bool preserve_wait_time)
| Start or stop filling the timetable automatically from the time the vehicle actually takes to complete it. More...
CommandCost | CmdSetTimetableStart (DoCommandFlag flags, VehicleID veh_id, bool timetable_all, TimerGameTick::TickCounter start_tick)
| Set the start date of the timetable. More...

## Detailed Description

Command definitions related to timetables.

Definition in file timetable_cmd.h.

## Function Documentation

## ◆ CmdAutofillTimetable()

CommandCost CmdAutofillTimetable | ( | DoCommandFlag | flags,
|  | VehicleID | veh,
|  | bool | autofill,
|  | bool | preserve_wait_time
| ) |  |

Start or stop filling the timetable automatically from the time the vehicle actually takes to complete it.

When starting to autofill the current times are cleared and the timetable will start again from scratch.

Parameters

  flags | Operation to perform.
  veh | Vehicle index.
  autofill | Enable or disable autofill
  preserve_wait_time | Set to preserve waiting times in non-destructive mode

Returns
  the cost of this operation or an error

Definition at line 425 of file timetable_cmd.cpp.

References CheckOwnership(), ClrBit(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), Vehicle::FirstShared(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::IsPrimaryVehicle(), BaseConsist::lateness_counter, Vehicle::NextShared(), Vehicle::orders, Vehicle::owner, SetBit(), SetWindowDirty(), BaseConsist::timetable_start, BaseConsist::vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME, VF_AUTOFILL_TIMETABLE, VF_TIMETABLE_STARTED, and WC_VEHICLE_TIMETABLE.

## ◆ CmdBulkChangeTimetable()

CommandCost CmdBulkChangeTimetable | ( | DoCommandFlag | flags,
|  | VehicleID | veh,
|  | ModifyTimetableFlags | mtf,
|  | uint16_t | data
| ) |  |

Change timetable data of all orders of a vehicle.

Parameters

  flags | Operation to perform.
  veh | Vehicle with the orders to change.
  mtf | Timetable data to change (

See also
  ModifyTimetableFlags)

Parameters

  data | The data to modify as specified by `mtf`. 0 to clear times, UINT16_MAX to clear speed limit.

Returns
  the cost of this operation or an error

Definition at line 228 of file timetable_cmd.cpp.

## ◆ CmdChangeTimetable()

CommandCost CmdChangeTimetable | ( | DoCommandFlag | flags,
|  | VehicleID | veh,
|  | VehicleOrderID | order_number,
|  | ModifyTimetableFlags | mtf,
|  | uint16_t | data
| ) |  |

Change timetable data of an order.

Parameters

  flags | Operation to perform.
  veh | Vehicle with the orders to change.
  order_number | Order index to modify.
  mtf | Timetable data to change (

See also
  ModifyTimetableFlags)

Parameters

  data | The data to modify as specified by `mtf`. 0 to clear times, UINT16_MAX to clear speed limit.

Returns
  the cost of this operation or an error

Definition at line 133 of file timetable_cmd.cpp.

## ◆ CmdSetTimetableStart()

CommandCost CmdSetTimetableStart | ( | DoCommandFlag | flags,
|  | VehicleID | veh_id,
|  | bool | timetable_all,
|  | TimerGameTick::TickCounter | start_tick
| ) |  |

Set the start date of the timetable.

Parameters

  flags | Operation to perform.
  veh_id | Vehicle ID.
  timetable_all | Set to set timetable start for all vehicles sharing this order
  start_tick | The TimerGameTick::counter tick when the timetable starts.

Returns
  The error or cost of the operation.

Definition at line 351 of file timetable_cmd.cpp.

References CheckOwnership(), CMD_ERROR, TimerGameEconomy::date, TimerGame< struct Economy >::DateAtStartOfYear(), Ticks::DAY_TICKS, TimerGameConst< struct Economy >::DAYS_IN_LEAP_YEAR, DC_EXEC, CommandCost::Failed(), GetDateFromStartTick(), OrderList::GetFirstSharedVehicle(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), OrderList::GetTimetableTotalDuration(), OrderList::IsCompleteTimetable(), Vehicle::IsPrimaryVehicle(), TimerGameConst< struct Economy >::MAX_DATE, MAX_TIMETABLE_START_YEARS, Vehicle::NextShared(), Vehicle::orders, and Vehicle::owner.

## ◆ CmdSetVehicleOnTime()

CommandCost CmdSetVehicleOnTime | ( | DoCommandFlag | flags,
|  | VehicleID | veh,
|  | bool | apply_to_group
| ) |  |

Clear the lateness counter to make the vehicle on time.

Parameters

  flags | Operation to perform.
  veh | Vehicle with the orders to change.
  apply_to_group | Set to reset the late counter for all vehicles sharing the orders.

Returns
  the cost of this operation or an error

Definition at line 259 of file timetable_cmd.cpp.

References CheckOwnership(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), Vehicle::FirstShared(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::IsPrimaryVehicle(), BaseConsist::lateness_counter, Vehicle::NextShared(), Vehicle::orders, Vehicle::owner, BaseConsist::ResetDepotUnbunching(), SetWindowDirty(), BaseConsist::vehicle_flags, VF_TIMETABLE_STARTED, and WC_VEHICLE_TIMETABLE.