OpenTTD Source: src/timetable.h File Reference

OpenTTD Source 15.3

Enumerations | Functions | Variables
timetable.h File Reference

Functions related to time tabling. More...

`#include "strings_type.h"`
`#include "timer/timer_game_tick.h"`
`#include "timer/timer_game_economy.h"`
`#include "vehicle_type.h"`

Go to the source code of this file.

## Enumerations
enum class | TimetableMode : uint8_t { Days , Seconds , Ticks }

## Functions
TimerGameTick::TickCounter | GetStartTickFromDate (TimerGameEconomy::Date start_date)
| Get the TimerGameTick::TickCounter tick of a given date.
TimerGameEconomy::Date | GetDateFromStartTick (TimerGameTick::TickCounter start_tick)
| Get a date from a given start tick of timetable.
void | ShowTimetableWindow (const Vehicle *v)
| Show the timetable for a given vehicle.
void | UpdateVehicleTimetable (Vehicle *v, bool travelling)
| Update the timetable for the vehicle.
std::pair< StringParameter, StringParameter > | GetTimetableParameters (TimerGameTick::Ticks ticks)
| Get parameters to format timetable time.

## Variables
static const TimerGameEconomy::Year | MAX_TIMETABLE_START_YEARS {15}
| The maximum start date offset, in economy years.

## Detailed Description

Functions related to time tabling.

Definition in file timetable.h.

## Enumeration Type Documentation

## ◆ TimetableMode

enum class TimetableMode : uint8_t
| strong

Definition at line 20 of file timetable.h.

## Function Documentation

## ◆ GetDateFromStartTick()

TimerGameEconomy::Date GetDateFromStartTick | ( | TimerGameTick::TickCounter | start_tick | ) |

Get a date from a given start tick of timetable.

Parameters

  start_tick | The TimerGameTick::TickCounter when the timetable starts.

Returns
  The date when we reach this tick.

Definition at line 46 of file timetable_cmd.cpp.

References TimerGameTick::counter, TimerGameEconomy::date, TimerGameEconomy::date_fract, and Ticks::DAY_TICKS.

Referenced by CmdSetTimetableStart(), and TimetableWindow::DrawSummaryPanel().

## ◆ GetStartTickFromDate()

TimerGameTick::TickCounter GetStartTickFromDate | ( | TimerGameEconomy::Date | start_date | ) |

Get the TimerGameTick::TickCounter tick of a given date.

Parameters

  start_date | The date when the timetable starts.

Returns
  The first tick of this date.

Definition at line 29 of file timetable_cmd.cpp.

References TimerGameTick::counter, TimerGameEconomy::date, TimerGameEconomy::date_fract, and Ticks::DAY_TICKS.

## ◆ GetTimetableParameters()

std::pair< StringParameter, StringParameter > GetTimetableParameters | ( | TimerGameTick::Ticks | ticks | ) |

Get parameters to format timetable time.

Parameters

  ticks | Number of ticks to format.

Returns
  Pair of parameters to format timetable time.

Definition at line 50 of file timetable_gui.cpp.

References _settings_client, Ticks::DAY_TICKS, ClientSettings::gui, Ticks::TICKS_PER_SECOND, and GUISettings::timetable_mode.

Referenced by DrawOrderString(), and TimetableWindow::DrawSummaryPanel().

## ◆ ShowTimetableWindow()

void ShowTimetableWindow | ( | const Vehicle * | v | ) |

Show the timetable for a given vehicle.

Parameters

  v | The vehicle to show the timetable for.

Definition at line 856 of file timetable_gui.cpp.

References CloseWindowById(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, WC_VEHICLE_DETAILS, and WC_VEHICLE_ORDERS.

Referenced by OrdersWindow::OnClick(), and VehicleViewWindow::OnClick().

## ◆ 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 469 of file timetable_cmd.cpp.

References AutofillPreserveWaitTime, AutofillTimetable, CeilDiv(), ChangeTimetable(), TimerGameTick::counter, BaseConsist::cur_real_order_index, Vehicle::current_order, BaseConsist::current_order_time, Vehicle::FirstShared(), Vehicle::GetNumOrders(), Vehicle::GetOrder(), Order::GetTimetabledTravel(), Order::GetTimetabledWait(), OrderList::GetTimetableTotalDuration(), Order::GetWaitTime(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Ticks::INVALID_TICKS, Order::IsTravelTimetabled(), Order::IsType(), Order::IsWaitTimetabled(), BaseConsist::lateness_counter, MTF_TRAVEL_TIME, MTF_WAIT_TIME, Vehicle::NextShared(), Vehicle::orders, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), Order::SetWaitTime(), SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Ticks::TICKS_PER_SECOND, BaseConsist::timetable_start, TimetableStarted, BaseConsist::vehicle_flags, and WC_VEHICLE_TIMETABLE.

Referenced by Vehicle::BeginLoading(), Vehicle::LeaveStation(), ProcessOrders(), UpdateOrderDest(), and VehicleEnterDepot().

## Variable Documentation

## ◆ MAX_TIMETABLE_START_YEARS

const TimerGameEconomy::Year MAX_TIMETABLE_START_YEARS {15}
| static

The maximum start date offset, in economy years.

Definition at line 18 of file timetable.h.

Referenced by CmdSetTimetableStart(), and TimetableWindow::OnClick().