OpenTTD Source  20240915-master-g3784a3d3d6
station_type.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #ifndef STATION_TYPE_H
11 #define STATION_TYPE_H
12 
13 #include "core/smallstack_type.hpp"
14 #include "tilearea_type.h"
15 
16 typedef uint16_t StationID;
17 typedef uint16_t RoadStopID;
18 
19 struct BaseStation;
20 struct Station;
21 struct RoadStop;
22 struct StationSpec;
23 struct Waypoint;
24 
25 static const StationID NEW_STATION = 0xFFFE;
26 static const StationID INVALID_STATION = 0xFFFF;
27 
29 
31 enum StationType : uint8_t {
32  STATION_RAIL,
33  STATION_AIRPORT,
34  STATION_TRUCK,
35  STATION_BUS,
36  STATION_OILRIG,
37  STATION_DOCK,
38  STATION_BUOY,
39  STATION_WAYPOINT,
40  STATION_ROADWAYPOINT,
41  STATION_END,
42 };
43 
45 enum RoadStopType : uint8_t {
49 };
50 
52 enum StationFacility : uint8_t {
53  FACIL_NONE = 0,
54  FACIL_TRAIN = 1 << 0,
55  FACIL_TRUCK_STOP = 1 << 1,
56  FACIL_BUS_STOP = 1 << 2,
57  FACIL_AIRPORT = 1 << 3,
58  FACIL_DOCK = 1 << 4,
59  FACIL_WAYPOINT = 1 << 7,
60 };
62 
63 
64 enum StationHadVehicleOfType : uint8_t {
65  HVOT_NONE = 0,
66  HVOT_TRAIN = 1 << 1,
67  HVOT_BUS = 1 << 2,
68  HVOT_TRUCK = 1 << 3,
69  HVOT_AIRCRAFT = 1 << 4,
70  HVOT_SHIP = 1 << 5,
71 
72  HVOT_WAYPOINT = 1 << 6,
73 };
75 
76 
78  CA_NONE = 0,
79  CA_BUS = 3,
80  CA_TRUCK = 3,
81  CA_TRAIN = 4,
82  CA_DOCK = 5,
83 
85 
87 };
88 
89 static const uint MAX_LENGTH_STATION_NAME_CHARS = 32;
90 
92  bool operator() (const Station *lhs, const Station *rhs) const;
93 };
94 
96 typedef std::set<Station *, StationCompare> StationList;
97 
104 public:
109  StationFinder(const TileArea &area) : TileArea(area) {}
110  const StationList *GetStations();
111 };
112 
113 #endif /* STATION_TYPE_H */
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition: station_type.h:46
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:84
SmallStack
Minimal stack that uses a pool to avoid pointers.
Definition: smallstack_type.hpp:135
StationFinder
Structure contains cached list of stations nearby.
Definition: station_type.h:102
FACIL_TRAIN
@ FACIL_TRAIN
Station with train station.
Definition: station_type.h:54
ROADSTOP_END
@ ROADSTOP_END
End of valid types.
Definition: station_type.h:48
CA_NONE
@ CA_NONE
Catchment when the station has no facilities.
Definition: station_type.h:78
FACIL_DOCK
@ FACIL_DOCK
Station with a dock.
Definition: station_type.h:58
HVOT_TRUCK
@ HVOT_TRUCK
Station has seen a truck.
Definition: station_type.h:68
Station
Station data structure.
Definition: station_base.h:439
HVOT_AIRCRAFT
@ HVOT_AIRCRAFT
Station has seen an aircraft.
Definition: station_type.h:69
HVOT_BUS
@ HVOT_BUS
Station has seen a bus.
Definition: station_type.h:67
Waypoint
Representation of a waypoint.
Definition: waypoint_base.h:23
HVOT_SHIP
@ HVOT_SHIP
Station has seen a ship.
Definition: station_type.h:70
ROADSTOP_TRUCK
@ ROADSTOP_TRUCK
A standard stop for trucks.
Definition: station_type.h:47
StationType
StationType
Station types.
Definition: station_type.h:31
MAX_CATCHMENT
@ MAX_CATCHMENT
Maximum catchment for airports with "modified catchment" enabled.
Definition: station_type.h:86
StationFinder::stations
StationList stations
List of stations nearby.
Definition: station_type.h:103
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
FACIL_NONE
@ FACIL_NONE
The station has no facilities at all.
Definition: station_type.h:53
CA_BUS
@ CA_BUS
Catchment for bus stops with "modified catchment" enabled.
Definition: station_type.h:79
FACIL_TRUCK_STOP
@ FACIL_TRUCK_STOP
Station with truck stops.
Definition: station_type.h:55
CA_TRUCK
@ CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition: station_type.h:80
StationFinder::GetStations
const StationList * GetStations()
Run a tile loop to find stations around a tile, on demand.
Definition: station_cmd.cpp:4367
StationList
std::set< Station *, StationCompare > StationList
List of stations.
Definition: station_type.h:96
StationHadVehicleOfType
StationHadVehicleOfType
The vehicles that may have visited a station.
Definition: station_type.h:64
CA_DOCK
@ CA_DOCK
Catchment for docks with "modified catchment" enabled.
Definition: station_type.h:82
MAX_LENGTH_STATION_NAME_CHARS
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
Definition: station_type.h:89
tilearea_type.h
HVOT_TRAIN
@ HVOT_TRAIN
Station has seen a train.
Definition: station_type.h:66
StationSpec
Station specification.
Definition: newgrf_station.h:115
StationFacility
StationFacility
The facilities a station might be having.
Definition: station_type.h:52
BaseStation
Base class for all station-ish types.
Definition: base_station_base.h:59
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
FACIL_BUS_STOP
@ FACIL_BUS_STOP
Station with bus stops.
Definition: station_type.h:56
CA_TRAIN
@ CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
Definition: station_type.h:81
HVOT_NONE
@ HVOT_NONE
Station has seen no vehicles.
Definition: station_type.h:65
RoadStopType
RoadStopType
Types of RoadStops.
Definition: station_type.h:45
RoadStop
A Stop for a Road Vehicle.
Definition: roadstop_base.h:22
smallstack_type.hpp
FACIL_WAYPOINT
@ FACIL_WAYPOINT
Station is a waypoint.
Definition: station_type.h:59
CatchmentArea
CatchmentArea
The different catchment areas used.
Definition: station_type.h:77
HVOT_WAYPOINT
@ HVOT_WAYPOINT
Station is a waypoint (NewGRF only!)
Definition: station_type.h:72
StationCompare
Definition: station_type.h:91
StationFinder::StationFinder
StationFinder(const TileArea &area)
Constructs StationFinder.
Definition: station_type.h:109
FACIL_AIRPORT
@ FACIL_AIRPORT
Station with an airport.
Definition: station_type.h:57