OpenTTD Source 20241224-master-gf74b0cf984
|
Commands related to time tabling. More...
#include "stdafx.h"
#include "command_func.h"
#include "company_func.h"
#include "timer/timer_game_tick.h"
#include "timer/timer_game_economy.h"
#include "window_func.h"
#include "vehicle_base.h"
#include "timetable_cmd.h"
#include "timetable.h"
#include "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
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. | |
static void | ChangeTimetable (Vehicle *v, VehicleOrderID order_number, uint16_t val, ModifyTimetableFlags mtf, bool timetabled) |
Change/update a particular timetable entry. | |
CommandCost | CmdChangeTimetable (DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data) |
Change timetable data of an order. | |
CommandCost | CmdBulkChangeTimetable (DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data) |
Change timetable data of all orders of a vehicle. | |
CommandCost | CmdSetVehicleOnTime (DoCommandFlag flags, VehicleID veh, bool apply_to_group) |
Clear the lateness counter to make the vehicle on time. | |
static bool | VehicleTimetableSorter (Vehicle *const &a, Vehicle *const &b) |
Order vehicles based on their timetable. | |
CommandCost | CmdSetTimetableStart (DoCommandFlag flags, VehicleID veh_id, bool timetable_all, TimerGameTick::TickCounter start_tick) |
Set the start date of the timetable. | |
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. | |
void | UpdateVehicleTimetable (Vehicle *v, bool travelling) |
Update the timetable for the vehicle. | |
Commands related to time tabling.
Definition in file timetable_cmd.cpp.
|
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. |
timetabled | If the new value is explicitly timetabled. |
Definition at line 66 of file timetable_cmd.cpp.
References BaseConsist::cur_real_order_index, Vehicle::current_order, Order::Equals(), Vehicle::FirstShared(), Vehicle::GetOrder(), Order::GetTimetabledTravel(), Order::GetTimetabledWait(), Order::GetTravelTime(), Order::GetWaitTime(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, MTF_TRAVEL_SPEED, MTF_TRAVEL_TIME, MTF_WAIT_TIME, Vehicle::NextShared(), Vehicle::orders, Order::SetMaxSpeed(), Order::SetTravelTime(), Order::SetTravelTimetabled(), Order::SetWaitTime(), Order::SetWaitTimetabled(), SetWindowDirty(), OrderList::UpdateTimetableDuration(), OrderList::UpdateTotalDuration(), and WC_VEHICLE_TIMETABLE.
Referenced by CmdChangeTimetable(), and UpdateVehicleTimetable().
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.
flags | Operation to perform. |
veh | Vehicle index. |
autofill | Enable or disable autofill |
preserve_wait_time | Set to preserve waiting times in non-destructive mode |
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::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 CmdBulkChangeTimetable | ( | DoCommandFlag | flags, |
VehicleID | veh, | ||
ModifyTimetableFlags | mtf, | ||
uint16_t | data | ||
) |
Change timetable data of all orders of a vehicle.
flags | Operation to perform. |
veh | Vehicle with the orders to change. |
mtf | Timetable data to change ( |
data | The data to modify as specified by mtf . 0 to clear times, UINT16_MAX to clear speed limit. |
Definition at line 228 of file timetable_cmd.cpp.
References CheckOwnership(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::GetNumOrders(), Vehicle::GetOrder(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::IsPrimaryVehicle(), Order::IsType(), and Vehicle::owner.
CommandCost CmdChangeTimetable | ( | DoCommandFlag | flags, |
VehicleID | veh, | ||
VehicleOrderID | order_number, | ||
ModifyTimetableFlags | mtf, | ||
uint16_t | data | ||
) |
Change timetable data of an order.
flags | Operation to perform. |
veh | Vehicle with the orders to change. |
order_number | Order index to modify. |
mtf | Timetable data to change ( |
data | The data to modify as specified by mtf . 0 to clear times, UINT16_MAX to clear speed limit. |
Definition at line 133 of file timetable_cmd.cpp.
References ChangeTimetable(), CheckOwnership(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), Vehicle::FirstShared(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Order::GetMaxSpeed(), Order::GetNonStopType(), Vehicle::GetOrder(), Order::GetTravelTime(), Order::GetType(), Order::GetWaitTime(), Vehicle::IsPrimaryVehicle(), Order::IsTravelTimetabled(), Order::IsType(), Order::IsWaitTimetabled(), MTF_TRAVEL_SPEED, MTF_TRAVEL_TIME, MTF_WAIT_TIME, Vehicle::NextShared(), ONSF_NO_STOP_AT_DESTINATION_STATION, Vehicle::owner, BaseConsist::ResetDepotUnbunching(), BaseVehicle::type, and VEH_AIRCRAFT.
CommandCost CmdSetTimetableStart | ( | DoCommandFlag | flags, |
VehicleID | veh_id, | ||
bool | timetable_all, | ||
TimerGameTick::TickCounter | start_tick | ||
) |
Set the start date of the timetable.
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. |
Definition at line 351 of file timetable_cmd.cpp.
References CheckOwnership(), ClrBit(), 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::orders, Vehicle::owner, BaseConsist::ResetDepotUnbunching(), SetWindowDirty(), VehicleTimetableSorter(), VF_TIMETABLE_STARTED, and WC_VEHICLE_TIMETABLE.
CommandCost CmdSetVehicleOnTime | ( | DoCommandFlag | flags, |
VehicleID | veh, | ||
bool | apply_to_group | ||
) |
Clear the lateness counter to make the vehicle on time.
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. |
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.
TimerGameEconomy::Date GetDateFromStartTick | ( | TimerGameTick::TickCounter | start_tick | ) |
Get a date from a given start tick of timetable.
start_tick | The TimerGameTick::TickCounter when the timetable starts. |
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().
TimerGameTick::TickCounter GetStartTickFromDate | ( | TimerGameEconomy::Date | start_date | ) |
Get the TimerGameTick::TickCounter tick of a given date.
start_date | The date when the timetable starts. |
Definition at line 29 of file timetable_cmd.cpp.
References TimerGameTick::counter, TimerGameEconomy::date, TimerGameEconomy::date_fract, and Ticks::DAY_TICKS.
Referenced by ChangeTimetableStartCallback().
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 469 of file timetable_cmd.cpp.
References _settings_client, CeilDiv(), ChangeTimetable(), ClrBit(), TimerGameTick::counter, BaseConsist::cur_real_order_index, Vehicle::current_order, BaseConsist::current_order_time, Ticks::DAY_TICKS, Vehicle::FirstShared(), Vehicle::GetFirstOrder(), Vehicle::GetNumOrders(), Vehicle::GetOrder(), Order::GetTimetabledTravel(), Order::GetTimetabledWait(), OrderList::GetTimetableTotalDuration(), Order::GetWaitTime(), ClientSettings::gui, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::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, SetBit(), Order::SetWaitTime(), SetWindowDirty(), Ticks::TICKS_PER_SECOND, GUISettings::timetable_mode, BaseConsist::timetable_start, BaseConsist::vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME, VF_AUTOFILL_TIMETABLE, VF_TIMETABLE_STARTED, 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 313 of file timetable_cmd.cpp.
References BaseConsist::cur_real_order_index, Vehicle::current_order, BaseConsist::current_order_time, Order::GetNonStopType(), Order::IsType(), ONSF_STOP_EVERYWHERE, and Vehicle::unitnumber.
Referenced by CmdSetTimetableStart().