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 station_type.h Types related to stations. */
12 #ifndef STATION_TYPE_H
13 #define STATION_TYPE_H
15 #include "core/smallvec_type.hpp"
16 #include "map/tilearea.h"
20 typedef uint16 StationID
;
21 typedef uint16 RoadStopID
;
22 typedef uint16 DockID
;
30 static const StationID INVALID_STATION
= 0xFFFF;
32 struct StationIDStack
: std::deque
<StationID
> {
33 /** Check if the stack contains a given element. */
34 bool Contains (StationID id
) const
36 for (const_iterator
iter (begin()); iter
!= end(); iter
++) {
37 if (*iter
== id
) return true;
55 /** Types of RoadStops */
57 ROADSTOP_BUS
, ///< A standard stop for buses
58 ROADSTOP_TRUCK
, ///< A standard stop for trucks
61 /** The facilities a station might be having */
62 enum StationFacility
{
63 FACIL_NONE
= 0, ///< The station has no facilities at all
64 FACIL_TRAIN
= 1 << 0, ///< Station with train station
65 FACIL_TRUCK_STOP
= 1 << 1, ///< Station with truck stops
66 FACIL_BUS_STOP
= 1 << 2, ///< Station with bus stops
67 FACIL_AIRPORT
= 1 << 3, ///< Station with an airport
68 FACIL_DOCK
= 1 << 4, ///< Station with a dock
69 FACIL_WAYPOINT
= 1 << 7, ///< Station is a waypoint
71 DECLARE_ENUM_AS_BIT_SET(StationFacility
)
72 typedef SimpleTinyEnumT
<StationFacility
, byte
> StationFacilityByte
;
74 /** The vehicles that may have visited a station */
75 enum StationHadVehicleOfType
{
76 HVOT_NONE
= 0, ///< Station has seen no vehicles
77 HVOT_TRAIN
= 1 << 1, ///< Station has seen a train
78 HVOT_BUS
= 1 << 2, ///< Station has seen a bus
79 HVOT_TRUCK
= 1 << 3, ///< Station has seen a truck
80 HVOT_AIRCRAFT
= 1 << 4, ///< Station has seen an aircraft
81 HVOT_SHIP
= 1 << 5, ///< Station has seen a ship
83 HVOT_WAYPOINT
= 1 << 6, ///< Station is a waypoint (NewGRF only!)
85 DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType
)
86 typedef SimpleTinyEnumT
<StationHadVehicleOfType
, byte
> StationHadVehicleOfTypeByte
;
88 /** The different catchment areas used */
90 CA_NONE
= 0, ///< Catchment when the station has no facilities
91 CA_BUS
= 3, ///< Catchment for bus stops with "modified catchment" enabled
92 CA_TRUCK
= 3, ///< Catchment for truck stops with "modified catchment" enabled
93 CA_TRAIN
= 4, ///< Catchment for train stations with "modified catchment" enabled
94 CA_DOCK
= 5, ///< Catchment for docks with "modified catchment" enabled
96 CA_UNMODIFIED
= 4, ///< Catchment for all stations with "modified catchment" disabled
98 MAX_CATCHMENT
= 10, ///< Maximum catchment for airports with "modified catchment" enabled
101 static const uint MAX_LENGTH_STATION_NAME_CHARS
= 32; ///< The maximum length of a station name in characters including '\0'
103 /** List of station IDs */
104 typedef std::list
<StationID
> StationIDList
;
106 /** List of stations */
107 typedef SmallVector
<Station
*, 2> StationList
;
110 * Structure contains cached list of stations nearby. The list
111 * is created upon first call to GetStations()
113 class StationFinder
: TileArea
{
114 StationList stations
; ///< List of stations nearby
117 * Constructs StationFinder
118 * @param area the area to search from
120 StationFinder(const TileArea
&area
) : TileArea(area
) {}
121 const StationList
*GetStations();
124 #endif /* STATION_TYPE_H */