1 /* $Id: departures_type.h $ */
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/>.
10 /** @file departures_type.h Types related to departures. */
12 #ifndef DEPARTURES_TYPE_H
13 #define DEPARTURES_TYPE_H
15 #include "station_base.h"
16 #include "order_base.h"
17 #include "vehicle_base.h"
19 /** Whether or not a vehicle has arrived for a departure. */
26 /** The type of departures. */
32 typedef struct CallAt
{
36 CallAt(const StationID
& s
) : station(s
), scheduled_date(0) { }
37 CallAt(const StationID
& s
, const Ticks
& t
) : station(s
), scheduled_date(t
) { }
38 CallAt(const CallAt
& c
) : station(c
.station
), scheduled_date(c
.scheduled_date
) { }
40 inline bool operator==(const CallAt
& c
) const {
41 return this->station
== c
.station
;
44 inline bool operator!=(const CallAt
& c
) const {
45 return this->station
!= c
.station
;
48 inline bool operator>=(const CallAt
& c
) const {
49 return this->station
== c
.station
&&
50 this->scheduled_date
!= 0 &&
51 c
.scheduled_date
!= 0 &&
52 this->scheduled_date
>= c
.scheduled_date
;
55 CallAt
& operator=(const CallAt
& c
) {
56 this->station
= c
.station
;
57 this->scheduled_date
= c
.scheduled_date
;
61 inline bool operator==(StationID s
) const {
62 return this->station
== s
;
66 /** A scheduled departure. */
67 typedef struct Departure
{
68 Ticks scheduled_date
; ///< The date this departure is scheduled to finish on (i.e. when the vehicle leaves the station)
69 Ticks lateness
; ///< How delayed the departure is expected to be
70 CallAt terminus
; ///< The station at which the vehicle will terminate following this departure
71 StationID via
; ///< The station the departure should list as going via
72 SmallVector
<CallAt
, 32> calling_at
; ///< The stations both called at and unloaded at by the vehicle after this departure before it terminates
73 DepartureStatus status
; ///< Whether the vehicle has arrived yet for this departure
74 DepartureType type
; ///< The type of the departure (departure or arrival)
75 VehicleID vehicle
; ///< The vehicle performing this departure
76 OrderID order
; ///< The order corresponding to this departure
77 Departure() : terminus(INVALID_STATION
), via(INVALID_STATION
), calling_at(), vehicle(INVALID_VEHICLE
), order(INVALID_ORDER
) { }
83 inline bool operator==(const Departure
& d
) const {
84 if (this->calling_at
.Length() != d
.calling_at
.Length()) return false;
86 for (uint i
= 0; i
< this->calling_at
.Length(); ++i
) {
87 if (*(this->calling_at
.Get(i
)) != *(d
.calling_at
.Get(i
))) return false;
91 this->scheduled_date
== d
.scheduled_date
&&
92 this->vehicle
== d
.vehicle
&&
99 typedef SmallVector
<Departure
*, 32> DepartureList
;
101 #endif /* DEPARTURES_TYPE_H */