OpenTTD Source: src/station_type.h Source File

OpenTTD Source 15.0-beta1

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
16typedef uint16_t StationID;
17typedef uint16_t RoadStopID;
18
19struct BaseStation;
20struct Station;
21struct RoadStop;
22struct StationSpec;
23struct Waypoint;
24
25static const StationID NEW_STATION = 0xFFFE;
26static const StationID INVALID_STATION = 0xFFFF;
27
28typedef SmallStack<StationID, StationID, INVALID_STATION, 8, 0xFFFD> StationIDStack;
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 {
46 ROADSTOP_BUS,
47 ROADSTOP_TRUCK,
48 ROADSTOP_END,
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};
61 DECLARE_ENUM_AS_BIT_SET(StationFacility)
62
63
64enum 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};
74 DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType)
75
76/* The different catchment area sizes. */
77static constexpr uint CA_NONE = 0;
78static constexpr uint CA_BUS = 3;
79static constexpr uint CA_TRUCK = 3;
80static constexpr uint CA_TRAIN = 4;
81static constexpr uint CA_DOCK = 5;
82
83static constexpr uint CA_UNMODIFIED = 4;
84
85static constexpr uint MAX_CATCHMENT = 10;
86
87static const uint MAX_LENGTH_STATION_NAME_CHARS = 32;
88
89struct StationCompare {
90 bool operator() (const Station *lhs, const Station *rhs) const;
91};
92
94 typedef std::set<Station *, StationCompare> StationList;
95
100 class StationFinder : TileArea {
101 StationList stations;
102public:
107 StationFinder(const TileArea &area) : TileArea(area) {}
108 const StationList &GetStations();
109};
110
111#endif /* STATION_TYPE_H */
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:100
StationFinder::GetStations
const StationList & GetStations()
Run a tile loop to find stations around a tile, on demand.
Definition station_cmd.cpp:4354
StationFinder::stations
StationList stations
List of stations nearby.
Definition station_type.h:101
StationFinder::StationFinder
StationFinder(const TileArea &area)
Constructs StationFinder.
Definition station_type.h:107
DECLARE_ENUM_AS_BIT_SET
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:35
smallstack_type.hpp
Minimal stack that uses a pool to avoid pointers and doesn't allocate any heap memory if there is onl...
CA_TRAIN
static constexpr uint CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
Definition station_type.h:80
RoadStopType
RoadStopType
Types of RoadStops.
Definition station_type.h:45
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition station_type.h:46
ROADSTOP_TRUCK
@ ROADSTOP_TRUCK
A standard stop for trucks.
Definition station_type.h:47
ROADSTOP_END
@ ROADSTOP_END
End of valid types.
Definition station_type.h:48
StationHadVehicleOfType
StationHadVehicleOfType
The vehicles that may have visited a station.
Definition station_type.h:64
HVOT_WAYPOINT
@ HVOT_WAYPOINT
Station is a waypoint (NewGRF only!)
Definition station_type.h:72
HVOT_TRUCK
@ HVOT_TRUCK
Station has seen a truck.
Definition station_type.h:68
HVOT_NONE
@ HVOT_NONE
Station has seen no vehicles.
Definition station_type.h:65
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
HVOT_SHIP
@ HVOT_SHIP
Station has seen a ship.
Definition station_type.h:70
HVOT_TRAIN
@ HVOT_TRAIN
Station has seen a train.
Definition station_type.h:66
StationFacility
StationFacility
The facilities a station might be having.
Definition station_type.h:52
FACIL_DOCK
@ FACIL_DOCK
Station with a dock.
Definition station_type.h:58
FACIL_BUS_STOP
@ FACIL_BUS_STOP
Station with bus stops.
Definition station_type.h:56
FACIL_AIRPORT
@ FACIL_AIRPORT
Station with an airport.
Definition station_type.h:57
FACIL_WAYPOINT
@ FACIL_WAYPOINT
Station is a waypoint.
Definition station_type.h:59
FACIL_TRUCK_STOP
@ FACIL_TRUCK_STOP
Station with truck stops.
Definition station_type.h:55
FACIL_TRAIN
@ FACIL_TRAIN
Station with train station.
Definition station_type.h:54
FACIL_NONE
@ FACIL_NONE
The station has no facilities at all.
Definition station_type.h:53
CA_NONE
static constexpr uint CA_NONE
Catchment when the station has no facilities.
Definition station_type.h:77
StationType
StationType
Station types.
Definition station_type.h:31
MAX_CATCHMENT
static constexpr uint MAX_CATCHMENT
Maximum catchment for airports with "modified catchment" enabled.
Definition station_type.h:85
CA_DOCK
static constexpr uint CA_DOCK
Catchment for docks with "modified catchment" enabled.
Definition station_type.h:81
CA_BUS
static constexpr uint CA_BUS
Catchment for bus stops with "modified catchment" enabled.
Definition station_type.h:78
CA_UNMODIFIED
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition station_type.h:83
StationList
std::set< Station *, StationCompare > StationList
List of stations.
Definition station_type.h:94
CA_TRUCK
static constexpr uint CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition station_type.h:79
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:87
BaseStation
Base class for all station-ish types.
Definition base_station_base.h:59
OrthogonalTileArea
Represents the covered area of e.g.
Definition tilearea_type.h:18
RoadStop
A Stop for a Road Vehicle.
Definition roadstop_base.h:22
StationCompare
Definition station_type.h:89
StationSpec
Station specification.
Definition newgrf_station.h:115
Station
Station data structure.
Definition station_base.h:439
Waypoint
Representation of a waypoint.
Definition waypoint_base.h:23
tilearea_type.h
Type for storing the 'area' of something uses on the map.