Commands related to time tabling. More...
#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 "core/sort_func.hpp"
#include "table/strings.h"
Go to the source code of this file.
Functions | |
static void | ChangeTimetable (Vehicle *v, VehicleOrderID order_number, uint16 val, ModifyTimetableFlags mtf) |
Change/update a particular timetable entry. | |
CommandCost | CmdChangeTimetable (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Change timetable data of an order. | |
CommandCost | CmdSetVehicleOnTime (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Clear the lateness counter to make the vehicle on time. | |
static int CDECL | VehicleTimetableSorter (Vehicle *const *ap, Vehicle *const *bp) |
Order vehicles based on their timetable. | |
CommandCost | CmdSetTimetableStart (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
Set the start date of the timetable. | |
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. | |
void | UpdateVehicleTimetable (Vehicle *v, bool travelling) |
Update the timetable for the vehicle. |
Commands related to time tabling.
Definition in file timetable_cmd.cpp.
static void ChangeTimetable | ( | Vehicle * | v, | |
VehicleOrderID | order_number, | |||
uint16 | val, | |||
ModifyTimetableFlags | mtf | |||
) | [static] |
Change/update a particular timetable entry.
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. |
Definition at line 30 of file timetable_cmd.cpp.
References BaseConsist::cur_real_order_index, Vehicle::current_order, Order::Equals(), Vehicle::FirstShared(), Vehicle::GetOrder(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::list, Order::max_speed, MTF_TRAVEL_SPEED, MTF_TRAVEL_TIME, MTF_WAIT_TIME, Vehicle::NextShared(), Vehicle::orders, SetWindowDirty(), Order::travel_time, OrderList::UpdateOrderTimetable(), Order::wait_time, and WC_VEHICLE_TIMETABLE.
Referenced by CmdChangeTimetable(), and UpdateVehicleTimetable().
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.
tile | Not used. | |
flags | Operation to perform. | |
p1 | Vehicle index. | |
p2 | Various bitstuffed elements
| |
text | unused |
Definition at line 300 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.
CommandCost CmdChangeTimetable | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Change timetable data of an order.
tile | Not used. | |
flags | Operation to perform. | |
p1 | Various bitstuffed elements |
p2 | The amount of time to wait.
| |
text | unused |
Definition at line 91 of file timetable_cmd.cpp.
References ChangeTimetable(), CheckOwnership(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Order::GetNonStopType(), Vehicle::GetOrder(), Order::GetType(), Vehicle::IsPrimaryVehicle(), Order::IsType(), Order::max_speed, MTF_TRAVEL_SPEED, MTF_TRAVEL_TIME, MTF_WAIT_TIME, Vehicle::owner, return_cmd_error, Order::travel_time, BaseVehicle::type, and Order::wait_time.
CommandCost CmdSetTimetableStart | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Set the start date of the timetable.
tile | Not used. | |
flags | Operation to perform. | |
p2 | Various bitstuffed elements
| |
p2 | The timetable start date. | |
text | Not used. |
Definition at line 234 of file timetable_cmd.cpp.
References _date, SmallVector< T, S >::Append(), SmallVector< T, S >::Begin(), CheckOwnership(), ClrBit(), CMD_ERROR, DAY_TICKS, DAYS_IN_LEAP_YEAR, DC_EXEC, SmallVector< T, S >::End(), CommandCost::Failed(), SmallVector< T, S >::FindIndex(), GB(), OrderList::GetFirstSharedVehicle(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), OrderList::GetTimetableTotalDuration(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, OrderList::IsCompleteTimetable(), Vehicle::IsPrimaryVehicle(), BaseConsist::lateness_counter, SmallVector< T, S >::Length(), Vehicle::list, MAX_DAY, Vehicle::NextShared(), Vehicle::orders, Vehicle::owner, QSortT(), SetWindowDirty(), BaseConsist::timetable_start, BaseConsist::vehicle_flags, VF_TIMETABLE_STARTED, and WC_VEHICLE_TIMETABLE.
CommandCost CmdSetVehicleOnTime | ( | TileIndex | tile, | |
DoCommandFlag | flags, | |||
uint32 | p1, | |||
uint32 | p2, | |||
const char * | text | |||
) |
Clear the lateness counter to make the vehicle on time.
tile | Not used. | |
flags | Operation to perform. | |
p1 | Various bitstuffed elements
| |
p2 | unused | |
text | unused |
Definition at line 164 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.
void UpdateVehicleTimetable | ( | Vehicle * | v, | |
bool | travelling | |||
) |
Update the timetable for the vehicle.
v | The vehicle to update the timetable for. | |
travelling | Whether we just travelled or waited at a station. |
Definition at line 346 of file timetable_cmd.cpp.
References _date, _date_fract, CeilDiv(), ChangeTimetable(), ClrBit(), BaseConsist::cur_real_order_index, Vehicle::current_order, BaseConsist::current_order_time, DAY_TICKS, Vehicle::FirstShared(), Vehicle::GetFirstOrder(), OrderList::GetTimetableTotalDuration(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TICKS, Order::IsType(), BaseConsist::lateness_counter, Vehicle::list, max(), MTF_TRAVEL_TIME, MTF_WAIT_TIME, Vehicle::NextShared(), Vehicle::orders, SetBit(), SetWindowDirty(), BaseConsist::timetable_start, Order::travel_time, BaseConsist::vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME, VF_AUTOFILL_TIMETABLE, VF_TIMETABLE_STARTED, Order::wait_time, and WC_VEHICLE_TIMETABLE.
Referenced by Vehicle::BeginLoading(), Vehicle::LeaveStation(), ProcessOrders(), UpdateOrderDest(), and VehicleEnterDepot().
Order vehicles based on their timetable.
The vehicles will be sorted in order they would reach the first station.
Definition at line 190 of file timetable_cmd.cpp.
References BaseConsist::cur_real_order_index, Vehicle::current_order, BaseConsist::current_order_time, Order::GetNonStopType(), Order::IsType(), and Vehicle::unitnumber.