Functions

timetable_cmd.cpp File Reference

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 "tile_cmd.h"
#include "settings_type.h"
#include "table/strings.h"

Go to the source code of this file.

Functions

static void ChangeTimetable (Vehicle *v, VehicleOrderID order_number, uint16 time, bool is_journey)
 Change/update a particular timetable entry.
CommandCost CmdChangeTimetable (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Add or remove waiting times from 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.
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.
CommandCost CmdAutomateTimetable (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Start or stop automatic management of the timetable.
int TimeToFinishOrder (Vehicle *v, int n)
int SeparationBetween (Vehicle *v1, Vehicle *v2)
void UpdateSeparationOrder (Vehicle *v_start)
void UpdateVehicleTimetable (Vehicle *v, bool travelling)
 Update the timetable for the vehicle.

Detailed Description

Commands related to time tabling.

Definition in file timetable_cmd.cpp.


Function Documentation

static void ChangeTimetable ( Vehicle v,
VehicleOrderID  order_number,
uint16  time,
bool  is_journey 
) [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.
time The new time of the timetable entry.
is_journey Whether to set the waiting or travelling time.

Definition at line 30 of file timetable_cmd.cpp.

References Vehicle::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, Vehicle::NextShared(), Vehicle::orders, SetWindowDirty(), Order::travel_time, OrderList::UpdateOrderTimetable(), and Order::wait_time.

Referenced by CmdAutomateTimetable(), 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.

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 204 of file timetable_cmd.cpp.

References _settings_game, 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(), Vehicle::lateness_counter, Vehicle::NextShared(), GameSettings::order, Vehicle::owner, SetBit(), SetWindowDirty(), Vehicle::timetable_start, OrderSettings::timetabling, Vehicle::vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME, VF_AUTOFILL_TIMETABLE, and VF_TIMETABLE_STARTED.

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

Start or stop automatic management of the timetable.

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 automation.
  • p2 = (bit 1) - Ctrl was pressed. Used when disabling to keep times.
text unused
Returns:
the cost of this operation or an error

Definition at line 258 of file timetable_cmd.cpp.

References _settings_game, ChangeTimetable(), 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(), OrderList::GetNumOrders(), HasBit(), Vehicle::IsPrimaryVehicle(), Vehicle::NextShared(), GameSettings::order, Vehicle::owner, SetBit(), SetWindowDirty(), OrderSettings::timetable_automated, VF_AUTOFILL_PRES_WAIT_TIME, VF_AUTOFILL_TIMETABLE, VF_AUTOMATE_TIMETABLE, and VF_TIMETABLE_STARTED.

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

Add or remove waiting times from 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) - Whether to change the waiting time or the travelling time.
p2 The amount of time to wait.

  • p2 = (bit 0-15) - Waiting or travelling time as specified by p1 bit 28
text unused
Returns:
the cost of this operation or an error

Definition at line 70 of file timetable_cmd.cpp.

References _settings_game, 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(), HasBit(), Vehicle::IsPrimaryVehicle(), Order::IsType(), GameSettings::order, Vehicle::owner, return_cmd_error, OrderSettings::timetabling, Order::travel_time, and Order::wait_time.

CommandCost CmdSetTimetableStart ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)
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 129 of file timetable_cmd.cpp.

References _settings_game, 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(), Vehicle::lateness_counter, GameSettings::order, Vehicle::owner, SetWindowDirty(), and OrderSettings::timetabling.

void UpdateVehicleTimetable ( Vehicle v,
bool  travelling 
)