OpenTTD Source: src/timetable_cmd.cpp File Reference

OpenTTD Source 1.11.0-RC1

Functions
timetable_cmd.cpp File Reference
`#include "stdafx.h"`
`#include "command_func.h"`
`#include "company_func.h"`
`#include "date_func.h"`
`#include "window_func.h"`
`#include "vehicle_base.h"`
`#include "cmd_helper.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Functions
static void | ChangeTimetable (Vehicle *v, VehicleOrderID order_number, uint16 val, ModifyTimetableFlags mtf, bool timetabled)
| Change/update a particular timetable entry. More...
CommandCost | CmdChangeTimetable (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change timetable data of an order. More...
CommandCost | CmdSetVehicleOnTime (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Clear the lateness counter to make the vehicle on time. More...
static bool | VehicleTimetableSorter (Vehicle *const &a, Vehicle *const &b)
| Order vehicles based on their timetable. More...
CommandCost | CmdSetTimetableStart (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Set the start date of the timetable. More...
CommandCost | CmdAutofillTimetable (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Start or stop filling the timetable automatically from the time the vehicle actually takes to complete it. More...
void | UpdateVehicleTimetable (Vehicle *v, bool travelling)
| Update the timetable for the vehicle. More...

## Detailed Description

Commands related to time tabling.

Definition in file timetable_cmd.cpp.

## Function Documentation

## ◆ ChangeTimetable()

static void ChangeTimetable | ( | Vehicle * | v,
|  | VehicleOrderID | order_number,
|  | uint16 | val,
|  | ModifyTimetableFlags | mtf,
|  | bool | timetabled
| ) |  |
| static

Change/update a particular timetable entry.

Parameters

  v | The vehicle to change the timetable of.
  order_number | The index of the timetable in the order list.
  val | The new data of the timetable entry.
  mtf | Which part of the timetable entry to change.
  timetabled | If the new value is explicitly timetabled.

Definition at line 30 of file timetable_cmd.cpp.

References Vehicle::GetOrder(), Order::GetTimetabledTravel(), Order::GetTimetabledWait(), Order::GetTravelTime(), Order::GetWaitTime(), MTF_TRAVEL_SPEED, MTF_TRAVEL_TIME, MTF_WAIT_TIME, Order::SetMaxSpeed(), Order::SetTravelTime(), Order::SetTravelTimetabled(), Order::SetWaitTime(), and Order::SetWaitTimetabled().

## ◆ CmdAutofillTimetable()

CommandCost CmdAutofillTimetable | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text
| ) |  |

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

  tile | Not used.
  flags | Operation to perform.
  p1 | Vehicle index.
  p2 | Various bitstuffed elements 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
  text | unused

Returns
  the cost of this operation or an error

Definition at line 326 of file timetable_cmd.cpp.

References CheckOwnership(), ClrBit(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), Vehicle::FirstShared(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), HasBit(), Vehicle::IsPrimaryVehicle(), BaseConsist::lateness_counter, Vehicle::list, 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.

## ◆ CmdChangeTimetable()

CommandCost CmdChangeTimetable | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text
| ) |  |

Change timetable data of an order.

Parameters

  tile | Not used.
  flags | Operation to perform.
  p1 | Various bitstuffed elements p1 = (bit 0-19) - Vehicle with the orders to change. p1 = (bit 20-27) - Order index to modify. p1 = (bit 28-29) - Timetable data to change (

See also
  ModifyTimetableFlags)

Parameters

  p2 | The amount of time to wait. p2 = (bit 0-15) - The data to modify as specified by p1 bits 28-29. 0 to clear times, UINT16_MAX to clear speed limit.
  text | unused

Returns
  the cost of this operation or an error

Definition at line 100 of file timetable_cmd.cpp.

References CheckOwnership(), CMD_ERROR, CommandCost::Failed(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::GetOrder(), Vehicle::IsPrimaryVehicle(), Order::IsType(), and Vehicle::owner.

## ◆ CmdSetTimetableStart()

CommandCost CmdSetTimetableStart | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text
| ) |  |

Set the start date of the timetable.

Parameters

  tile | Not used.
  flags | Operation to perform.
  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
  p2 | The timetable start date.
  text | Not used.

Returns
  The error or cost of the operation.

Definition at line 261 of file timetable_cmd.cpp.

References _date, CheckOwnership(), CMD_ERROR, DAYS_IN_LEAP_YEAR, DC_EXEC, CommandCost::Failed(), GB(), OrderList::GetFirstSharedVehicle(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), OrderList::GetTimetableTotalDuration(), HasBit(), OrderList::IsCompleteTimetable(), Vehicle::IsPrimaryVehicle(), Vehicle::list, MAX_DAY, Vehicle::NextShared(), Vehicle::orders, and Vehicle::owner.

## ◆ CmdSetVehicleOnTime()

CommandCost CmdSetVehicleOnTime | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text
| ) |  |

Clear the lateness counter to make the vehicle on time.

Parameters

  tile | Not used.
  flags | Operation to perform.
  p1 | Various bitstuffed elements p1 = (bit 0-19) - Vehicle with the orders to change.
  p2 | unused
  text | unused

Returns
  the cost of this operation or an error

Definition at line 194 of file timetable_cmd.cpp.

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

## ◆ UpdateVehicleTimetable()

void UpdateVehicleTimetable | ( | Vehicle * | v,
|  | bool | travelling
| ) |  |

Update the timetable for the vehicle.

Parameters

  v | The vehicle to update the timetable for.
  travelling | Whether we just travelled or waited at a station.

Definition at line 372 of file timetable_cmd.cpp.

References Vehicle::current_order, BaseConsist::current_order_time, and Order::IsType().

## ◆ VehicleTimetableSorter()

static bool VehicleTimetableSorter | ( | Vehicle *const & | a,
|  | Vehicle *const & | b
| ) |  |
| static

Order vehicles based on their timetable.

The vehicles will be sorted in order they would reach the first station.

Parameters

  a | First Vehicle pointer.
  b | Second Vehicle pointer.

Returns
  Comparison value.

Definition at line 220 of file timetable_cmd.cpp.

References BaseConsist::cur_real_order_index, Vehicle::current_order, and Order::IsType().