OpenTTD
timetable_cmd.cpp
Go to the documentation of this file.
1 /* $Id$ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
12 #include "stdafx.h"
13 #include "command_func.h"
14 #include "company_func.h"
15 #include "date_func.h"
16 #include "window_func.h"
17 #include "vehicle_base.h"
18 #include "cmd_helper.h"
19 
20 #include "table/strings.h"
21 
22 #include "safeguards.h"
23 
32 static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 val, ModifyTimetableFlags mtf, bool timetabled)
33 {
34  Order *order = v->GetOrder(order_number);
35  int total_delta = 0;
36  int timetable_delta = 0;
37 
38  switch (mtf) {
39  case MTF_WAIT_TIME:
40  total_delta = val - order->GetWaitTime();
41  timetable_delta = (timetabled ? val : 0) - order->GetTimetabledWait();
42  order->SetWaitTime(val);
43  order->SetWaitTimetabled(timetabled);
44  break;
45 
46  case MTF_TRAVEL_TIME:
47  total_delta = val - order->GetTravelTime();
48  timetable_delta = (timetabled ? val : 0) - order->GetTimetabledTravel();
49  order->SetTravelTime(val);
50  order->SetTravelTimetabled(timetabled);
51  break;
52 
53  case MTF_TRAVEL_SPEED:
54  order->SetMaxSpeed(val);
55  break;
56 
57  default:
58  NOT_REACHED();
59  }
60  v->orders.list->UpdateTotalDuration(total_delta);
61  v->orders.list->UpdateTimetableDuration(timetable_delta);
62 
63  for (v = v->FirstShared(); v != nullptr; v = v->NextShared()) {
64  if (v->cur_real_order_index == order_number && v->current_order.Equals(*order)) {
65  switch (mtf) {
66  case MTF_WAIT_TIME:
67  v->current_order.SetWaitTime(val);
68  v->current_order.SetWaitTimetabled(timetabled);
69  break;
70 
71  case MTF_TRAVEL_TIME:
73  v->current_order.SetTravelTimetabled(timetabled);
74  break;
75 
76  case MTF_TRAVEL_SPEED:
77  v->current_order.SetMaxSpeed(val);
78  break;
79 
80  default:
81  NOT_REACHED();
82  }
83  }
85  }
86 }
87 
102 CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
103 {
104  VehicleID veh = GB(p1, 0, 20);
105 
106  Vehicle *v = Vehicle::GetIfValid(veh);
107  if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
108 
109  CommandCost ret = CheckOwnership(v->owner);
110  if (ret.Failed()) return ret;
111 
112  VehicleOrderID order_number = GB(p1, 20, 8);
113  Order *order = v->GetOrder(order_number);
114  if (order == nullptr || order->IsType(OT_IMPLICIT)) return CMD_ERROR;
115 
116  ModifyTimetableFlags mtf = Extract<ModifyTimetableFlags, 28, 2>(p1);
117  if (mtf >= MTF_END) return CMD_ERROR;
118 
119  int wait_time = order->GetWaitTime();
120  int travel_time = order->GetTravelTime();
121  int max_speed = order->GetMaxSpeed();
122  switch (mtf) {
123  case MTF_WAIT_TIME:
124  wait_time = GB(p2, 0, 16);
125  break;
126 
127  case MTF_TRAVEL_TIME:
128  travel_time = GB(p2, 0, 16);
129  break;
130 
131  case MTF_TRAVEL_SPEED:
132  max_speed = GB(p2, 0, 16);
133  if (max_speed == 0) max_speed = UINT16_MAX; // Disable speed limit.
134  break;
135 
136  default:
137  NOT_REACHED();
138  }
139 
140  if (wait_time != order->GetWaitTime()) {
141  switch (order->GetType()) {
142  case OT_GOTO_STATION:
143  if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_ERROR_TIMETABLE_NOT_STOPPING_HERE);
144  break;
145 
146  case OT_CONDITIONAL:
147  break;
148 
149  default: return_cmd_error(STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS);
150  }
151  }
152 
153  if (travel_time != order->GetTravelTime() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
154  if (max_speed != order->GetMaxSpeed() && (order->IsType(OT_CONDITIONAL) || v->type == VEH_AIRCRAFT)) return CMD_ERROR;
155 
156  if (flags & DC_EXEC) {
157  switch (mtf) {
158  case MTF_WAIT_TIME:
159  /* Set time if changing the value or confirming an estimated time as timetabled. */
160  if (wait_time != order->GetWaitTime() || (wait_time > 0 && !order->IsWaitTimetabled())) {
161  ChangeTimetable(v, order_number, wait_time, MTF_WAIT_TIME, wait_time > 0);
162  }
163  break;
164 
165  case MTF_TRAVEL_TIME:
166  /* Set time if changing the value or confirming an estimated time as timetabled. */
167  if (travel_time != order->GetTravelTime() || (travel_time > 0 && !order->IsTravelTimetabled())) {
168  ChangeTimetable(v, order_number, travel_time, MTF_TRAVEL_TIME, travel_time > 0);
169  }
170  break;
171 
172  case MTF_TRAVEL_SPEED:
173  if (max_speed != order->GetMaxSpeed()) {
174  ChangeTimetable(v, order_number, max_speed, MTF_TRAVEL_SPEED, max_speed != UINT16_MAX);
175  }
176  break;
177 
178  default:
179  break;
180  }
181  }
182 
183  return CommandCost();
184 }
185 
196 CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
197 {
198  VehicleID veh = GB(p1, 0, 20);
199 
200  Vehicle *v = Vehicle::GetIfValid(veh);
201  if (v == nullptr || !v->IsPrimaryVehicle() || v->orders.list == nullptr) return CMD_ERROR;
202 
203  CommandCost ret = CheckOwnership(v->owner);
204  if (ret.Failed()) return ret;
205 
206  if (flags & DC_EXEC) {
207  v->lateness_counter = 0;
209  }
210 
211  return CommandCost();
212 }
213 
222 static bool VehicleTimetableSorter(Vehicle * const &a, Vehicle * const &b)
223 {
226  int j = (int)b_order - (int)a_order;
227 
228  /* Are we currently at an ordered station (un)loading? */
229  bool a_load = a->current_order.IsType(OT_LOADING) && a->current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE;
230  bool b_load = b->current_order.IsType(OT_LOADING) && b->current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE;
231 
232  /* If the current order is not loading at the ordered station, decrease the order index by one since we have
233  * not yet arrived at the station (and thus the timetable entry; still in the travelling of the previous one).
234  * Since the ?_order variables are unsigned the -1 will flow under and place the vehicles going to order #0 at
235  * the begin of the list with vehicles arriving at #0. */
236  if (!a_load) a_order--;
237  if (!b_load) b_order--;
238 
239  /* First check the order index that accounted for loading, then just the raw one. */
240  int i = (int)b_order - (int)a_order;
241  if (i != 0) return i < 0;
242  if (j != 0) return j < 0;
243 
244  /* Look at the time we spent in this order; the higher, the closer to its destination. */
246  if (i != 0) return i < 0;
247 
248  /* If all else is equal, use some unique index to sort it the same way. */
249  return b->unitnumber < a->unitnumber;
250 }
251 
263 CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
264 {
265  bool timetable_all = HasBit(p1, 20);
266  Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
267  if (v == nullptr || !v->IsPrimaryVehicle() || v->orders.list == nullptr) return CMD_ERROR;
268 
269  CommandCost ret = CheckOwnership(v->owner);
270  if (ret.Failed()) return ret;
271 
272  /* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
273  Date start_date = (Date)p2;
274  if (start_date < 0 || start_date > MAX_DAY) return CMD_ERROR;
275  if (start_date - _date > 15 * DAYS_IN_LEAP_YEAR) return CMD_ERROR;
276  if (_date - start_date > DAYS_IN_LEAP_YEAR) return CMD_ERROR;
277  if (timetable_all && !v->orders.list->IsCompleteTimetable()) return CMD_ERROR;
278 
279  if (flags & DC_EXEC) {
280  std::vector<Vehicle *> vehs;
281 
282  if (timetable_all) {
283  for (Vehicle *w = v->orders.list->GetFirstSharedVehicle(); w != nullptr; w = w->NextShared()) {
284  vehs.push_back(w);
285  }
286  } else {
287  vehs.push_back(v);
288  }
289 
290  int total_duration = v->orders.list->GetTimetableTotalDuration();
291  int num_vehs = (uint)vehs.size();
292 
293  if (num_vehs >= 2) {
294  std::sort(vehs.begin(), vehs.end(), &VehicleTimetableSorter);
295  }
296 
297  int idx = vehs.begin() - std::find(vehs.begin(), vehs.end(), v);
298 
299  for (Vehicle *w : vehs) {
300 
301  w->lateness_counter = 0;
302  ClrBit(w->vehicle_flags, VF_TIMETABLE_STARTED);
303  /* Do multiplication, then division to reduce rounding errors. */
304  w->timetable_start = start_date + idx * total_duration / num_vehs / DAY_TICKS;
306  ++idx;
307  }
308 
309  }
310 
311  return CommandCost();
312 }
313 
314 
328 CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
329 {
330  VehicleID veh = GB(p1, 0, 20);
331 
332  Vehicle *v = Vehicle::GetIfValid(veh);
333  if (v == nullptr || !v->IsPrimaryVehicle() || v->orders.list == nullptr) return CMD_ERROR;
334 
335  CommandCost ret = CheckOwnership(v->owner);
336  if (ret.Failed()) return ret;
337 
338  if (flags & DC_EXEC) {
339  if (HasBit(p2, 0)) {
340  /* Start autofilling the timetable, which clears the
341  * "timetable has started" bit. Times are not cleared anymore, but are
342  * overwritten when the order is reached now. */
345 
346  /* Overwrite waiting times only if they got longer */
348 
349  v->timetable_start = 0;
350  v->lateness_counter = 0;
351  } else {
354  }
355 
356  for (Vehicle *v2 = v->FirstShared(); v2 != nullptr; v2 = v2->NextShared()) {
357  if (v2 != v) {
358  /* Stop autofilling; only one vehicle at a time can perform autofill */
359  ClrBit(v2->vehicle_flags, VF_AUTOFILL_TIMETABLE);
360  ClrBit(v2->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME);
361  }
363  }
364  }
365 
366  return CommandCost();
367 }
368 
374 void UpdateVehicleTimetable(Vehicle *v, bool travelling)
375 {
376  uint time_taken = v->current_order_time;
377 
378  v->current_order_time = 0;
379 
380  if (v->current_order.IsType(OT_IMPLICIT)) return; // no timetabling of auto orders
381 
382  if (v->cur_real_order_index >= v->GetNumOrders()) return;
383  Order *real_current_order = v->GetOrder(v->cur_real_order_index);
384 
385  VehicleOrderID first_manual_order = 0;
386  for (Order *o = v->GetFirstOrder(); o != nullptr && o->IsType(OT_IMPLICIT); o = o->next) {
387  ++first_manual_order;
388  }
389 
390  bool just_started = false;
391 
392  /* This vehicle is arriving at the first destination in the timetable. */
393  if (v->cur_real_order_index == first_manual_order && travelling) {
394  /* If the start date hasn't been set, or it was set automatically when
395  * the vehicle last arrived at the first destination, update it to the
396  * current time. Otherwise set the late counter appropriately to when
397  * the vehicle should have arrived. */
398  just_started = !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
399 
400  if (v->timetable_start != 0) {
402  v->timetable_start = 0;
403  }
404 
407  }
408 
409  if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) return;
410 
411  bool autofilling = HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE);
412  bool remeasure_wait_time = !real_current_order->IsWaitTimetabled() ||
413  (autofilling && !HasBit(v->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME));
414 
415  if (travelling && remeasure_wait_time) {
416  /* We just finished travelling and want to remeasure the loading time,
417  * so do not apply any restrictions for the loading to finish. */
419  }
420 
421  if (just_started) return;
422 
423  /* Before modifying waiting times, check whether we want to preserve bigger ones. */
424  if (!real_current_order->IsType(OT_CONDITIONAL) &&
425  (travelling || time_taken > real_current_order->GetWaitTime() || remeasure_wait_time)) {
426  /* Round the time taken up to the nearest day, as this will avoid
427  * confusion for people who are timetabling in days, and can be
428  * adjusted later by people who aren't.
429  * For trains/aircraft multiple movement cycles are done in one
430  * tick. This makes it possible to leave the station and process
431  * e.g. a depot order in the same tick, causing it to not fill
432  * the timetable entry like is done for road vehicles/ships.
433  * Thus always make sure at least one tick is used between the
434  * processing of different orders when filling the timetable. */
435  uint time_to_set = CeilDiv(max(time_taken, 1U), DAY_TICKS) * DAY_TICKS;
436 
437  if (travelling && (autofilling || !real_current_order->IsTravelTimetabled())) {
438  ChangeTimetable(v, v->cur_real_order_index, time_to_set, MTF_TRAVEL_TIME, autofilling);
439  } else if (!travelling && (autofilling || !real_current_order->IsWaitTimetabled())) {
440  ChangeTimetable(v, v->cur_real_order_index, time_to_set, MTF_WAIT_TIME, autofilling);
441  }
442  }
443 
444  if (v->cur_real_order_index == first_manual_order && travelling) {
445  /* If we just started we would have returned earlier and have not reached
446  * this code. So obviously, we have completed our round: So turn autofill
447  * off again. */
450  }
451 
452  if (autofilling) return;
453 
454  uint timetabled = travelling ? real_current_order->GetTimetabledTravel() :
455  real_current_order->GetTimetabledWait();
456 
457  /* Vehicles will wait at stations if they arrive early even if they are not
458  * timetabled to wait there, so make sure the lateness counter is updated
459  * when this happens. */
460  if (timetabled == 0 && (travelling || v->lateness_counter >= 0)) return;
461 
462  v->lateness_counter -= (timetabled - time_taken);
463 
464  /* When we are more late than this timetabled bit takes we (somewhat expensively)
465  * check how many ticks the (fully filled) timetable has. If a timetable cycle is
466  * shorter than the amount of ticks we are late we reduce the lateness by the
467  * length of a full cycle till lateness is less than the length of a timetable
468  * cycle. When the timetable isn't fully filled the cycle will be INVALID_TICKS. */
469  if (v->lateness_counter > (int)timetabled) {
471  if (cycle != INVALID_TICKS && v->lateness_counter > cycle) {
472  v->lateness_counter %= cycle;
473  }
474  }
475 
476  for (v = v->FirstShared(); v != nullptr; v = v->NextShared()) {
478  }
479 }
Set max travel speed.
Definition: order_type.h:175
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:257
Set wait time.
Definition: order_type.h:173
uint16 GetTravelTime() const
Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not)...
Definition: order_base.h:187
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3199
Ticks GetTimetableTotalDuration() const
Gets the total duration of the vehicles timetable or INVALID_TICKS is the timetable is not complete...
Definition: order_base.h:364
union Vehicle::@49 orders
The orders currently assigned to the vehicle.
Whether the vehicle has started running on the timetable yet.
Definition: vehicle_base.h:47
Functions related to dates.
void UpdateTimetableDuration(Ticks delta)
Must be called if an order&#39;s timetable is changed to update internal book keeping.
Definition: order_base.h:382
void SetWaitTime(uint16 time)
Set the time in ticks to wait at the destination.
Definition: order_base.h:205
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
static const Ticks INVALID_TICKS
Representation of an invalid number of ticks.
Definition: date_type.h:111
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Definition: command_func.h:25
OrderList * list
Pointer to the order list for this vehicle.
Definition: vehicle_base.h:321
bool IsCompleteTimetable() const
Checks whether all orders of the list have a filled timetable.
Definition: order_cmd.cpp:592
bool IsTravelTimetabled() const
Does this order have an explicit travel time set?
Definition: order_base.h:178
uint32 current_order_time
How many ticks have passed since this order started.
Definition: base_consist.h:23
Vehicle data structure.
Definition: vehicle_base.h:212
Tindex index
Index of this pool item.
Definition: pool_type.hpp:147
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
Definition: date_type.h:30
Helper functions to extract data from command parameters.
int32 lateness_counter
How many ticks late (or early if negative) this vehicle is.
Definition: base_consist.h:24
ModifyTimetableFlags
Enumeration for the data to set in CmdChangeTimetable.
Definition: order_type.h:172
Common return value for all commands.
Definition: command_type.h:25
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
Definition: order_base.h:337
void SetMaxSpeed(uint16 speed)
Set the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination...
Definition: order_base.h:218
The vehicle will stop at any station it passes except the destination.
Definition: order_type.h:77
CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Clear the lateness counter to make the vehicle on time.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
Definition: vehicle_base.h:675
Set travel time.
Definition: order_type.h:174
The vehicle will stop at any station it passes and the destination.
Definition: order_type.h:75
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
Definition: vehicle_base.h:433
UnitID unitnumber
unit number, for display purposes only
Definition: vehicle_base.h:291
DateFract _date_fract
Fractional part of the day.
Definition: date.cpp:29
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:18
bool IsType(OrderType type) const
Check whether this order is of the given type.
Definition: order_base.h:63
DoCommandFlag
List of flags for a command.
Definition: command_type.h:344
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:316
Whether the vehicle should fill in the timetable automatically.
Definition: vehicle_base.h:48
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
Definition: order_base.h:176
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Change timetable data of an order.
uint16 GetTimetabledTravel() const
Get the time in ticks a vehicle should take to reach the destination or 0 if it&#39;s not timetabled...
Definition: order_base.h:183
CommandCost CheckOwnership(Owner owner, TileIndex tile)
Check whether the current owner owns something.
Vehicle timetable; Window numbers:
Definition: window_type.h:219
void SetWaitTimetabled(bool timetabled)
Set if the wait time is explicitly timetabled (unless the order is conditional).
Definition: order_base.h:197
Owner owner
Which company owns the vehicle?
Definition: vehicle_base.h:273
bool Equals(const Order &other) const
Does this order have the same type, flags and destination?
Definition: order_cmd.cpp:176
bool Failed() const
Did this command fail?
Definition: command_type.h:161
Date timetable_start
When the vehicle is supposed to start the timetable.
Definition: base_consist.h:25
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
Definition: vehicle_base.h:654
#define return_cmd_error(errcode)
Returns from a function with a specific StringID as error.
Definition: command_func.h:35
uint16 GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not)...
Definition: order_base.h:185
execute the given command
Definition: command_type.h:346
static bool VehicleTimetableSorter(Vehicle *const &a, Vehicle *const &b)
Order vehicles based on their timetable.
Functions related to companies.
uint16 GetTimetabledWait() const
Get the time in ticks a vehicle should wait at the destination or 0 if it&#39;s not timetabled.
Definition: order_base.h:181
static T ClrBit(T &x, const uint8 y)
Clears a bit in a variable.
Base class for all vehicles.
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
int32 Ticks
The type to store ticks in.
Definition: date_type.h:18
void SetTravelTimetabled(bool timetabled)
Set if the travel time is explicitly timetabled (unless the order is conditional).
Definition: order_base.h:199
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Set the start date of the timetable.
VehicleType type
Type of vehicle.
Definition: vehicle_type.h:54
#define MAX_DAY
The number of days till the last day.
Definition: date_type.h:97
void UpdateTotalDuration(Ticks delta)
Must be called if an order&#39;s timetable is changed to update internal book keeping.
Definition: order_base.h:388
Functions related to commands.
Order * GetOrder(int index) const
Returns order &#39;index&#39; of a vehicle or nullptr when it doesn&#39;t exists.
Definition: vehicle_base.h:860
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
Definition: vehicle_base.h:687
int32 Date
The type to store our dates in.
Definition: date_type.h:16
Aircraft vehicle type.
Definition: vehicle_type.h:29
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 complet...
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
Definition: base_consist.h:32
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:17
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
void UpdateVehicleTimetable(Vehicle *v, bool travelling)
Update the timetable for the vehicle.
Whether non-destructive auto-fill should preserve waiting times.
Definition: vehicle_base.h:49
OrderType GetType() const
Get the type of order of this order.
Definition: order_base.h:69
uint16 GetMaxSpeed() const
Get the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the destination...
Definition: order_base.h:194
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
Definition: vehicle_base.h:663
Window functions not directly related to making/drawing windows.
static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 val, ModifyTimetableFlags mtf, bool timetabled)
Change/update a particular timetable entry.
Date _date
Current date in days (day counter)
Definition: date.cpp:28
void SetTravelTime(uint16 time)
Set the time in ticks to take for travelling to the destination.
Definition: order_base.h:211
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
Definition: base_consist.h:29
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
Definition: order_base.h:133
Order current_order
The current order (+ status, like: loading)
Definition: vehicle_base.h:318
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
Definition: date_type.h:32