2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-03-28 16:33:28 +00:00
|
|
|
/** @file station_type.h Types related to stations. */
|
|
|
|
|
|
|
|
#ifndef STATION_TYPE_H
|
|
|
|
#define STATION_TYPE_H
|
|
|
|
|
2013-10-20 13:47:11 +00:00
|
|
|
#include "core/smallstack_type.hpp"
|
2010-01-04 18:05:14 +00:00
|
|
|
#include "tilearea_type.h"
|
2019-03-13 02:49:35 +00:00
|
|
|
#include "3rdparty/cpp-btree/btree_set.h"
|
2009-07-04 11:26:57 +00:00
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
typedef uint16_t StationID;
|
|
|
|
typedef uint16_t RoadStopID;
|
|
|
|
typedef uint16_t DockID;
|
2008-03-28 16:33:28 +00:00
|
|
|
|
2009-07-17 19:44:13 +00:00
|
|
|
struct BaseStation;
|
2008-03-28 16:33:28 +00:00
|
|
|
struct Station;
|
|
|
|
struct RoadStop;
|
2008-03-31 06:42:26 +00:00
|
|
|
struct StationSpec;
|
2009-07-28 21:06:38 +00:00
|
|
|
struct Waypoint;
|
2008-03-28 16:33:28 +00:00
|
|
|
|
2009-04-10 22:47:19 +00:00
|
|
|
static const StationID NEW_STATION = 0xFFFE;
|
2008-03-28 16:33:28 +00:00
|
|
|
static const StationID INVALID_STATION = 0xFFFF;
|
|
|
|
|
2021-06-23 06:21:29 +00:00
|
|
|
static const uint MAX_STATION_CARGO_HISTORY_DAYS = 24;
|
|
|
|
|
2013-10-20 13:47:11 +00:00
|
|
|
typedef SmallStack<StationID, StationID, INVALID_STATION, 8, 0xFFFD> StationIDStack;
|
|
|
|
|
2008-10-19 15:39:12 +00:00
|
|
|
/** Station types */
|
2008-03-28 16:33:28 +00:00
|
|
|
enum StationType {
|
|
|
|
STATION_RAIL,
|
|
|
|
STATION_AIRPORT,
|
|
|
|
STATION_TRUCK,
|
|
|
|
STATION_BUS,
|
|
|
|
STATION_OILRIG,
|
|
|
|
STATION_DOCK,
|
2009-07-18 10:01:31 +00:00
|
|
|
STATION_BUOY,
|
|
|
|
STATION_WAYPOINT,
|
2022-01-25 22:02:32 +00:00
|
|
|
STATION_ROADWAYPOINT,
|
2008-03-28 16:33:28 +00:00
|
|
|
};
|
|
|
|
|
2008-03-31 00:06:17 +00:00
|
|
|
/** Types of RoadStops */
|
|
|
|
enum RoadStopType {
|
|
|
|
ROADSTOP_BUS, ///< A standard stop for buses
|
2011-12-19 17:48:04 +00:00
|
|
|
ROADSTOP_TRUCK, ///< A standard stop for trucks
|
2008-03-31 00:06:17 +00:00
|
|
|
};
|
|
|
|
|
2009-07-07 11:21:14 +00:00
|
|
|
/** The facilities a station might be having */
|
2019-04-21 22:01:29 +00:00
|
|
|
enum StationFacility : byte {
|
2009-07-07 11:21:14 +00:00
|
|
|
FACIL_NONE = 0, ///< The station has no facilities at all
|
|
|
|
FACIL_TRAIN = 1 << 0, ///< Station with train station
|
|
|
|
FACIL_TRUCK_STOP = 1 << 1, ///< Station with truck stops
|
|
|
|
FACIL_BUS_STOP = 1 << 2, ///< Station with bus stops
|
|
|
|
FACIL_AIRPORT = 1 << 3, ///< Station with an airport
|
|
|
|
FACIL_DOCK = 1 << 4, ///< Station with a dock
|
2009-07-18 18:39:17 +00:00
|
|
|
FACIL_WAYPOINT = 1 << 7, ///< Station is a waypoint
|
2008-03-28 16:33:28 +00:00
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(StationFacility)
|
2008-03-28 16:33:28 +00:00
|
|
|
|
2009-07-07 11:21:14 +00:00
|
|
|
/** The vehicles that may have visited a station */
|
2019-04-21 22:13:27 +00:00
|
|
|
enum StationHadVehicleOfType : byte {
|
2009-07-07 11:21:14 +00:00
|
|
|
HVOT_NONE = 0, ///< Station has seen no vehicles
|
|
|
|
HVOT_TRAIN = 1 << 1, ///< Station has seen a train
|
|
|
|
HVOT_BUS = 1 << 2, ///< Station has seen a bus
|
|
|
|
HVOT_TRUCK = 1 << 3, ///< Station has seen a truck
|
|
|
|
HVOT_AIRCRAFT = 1 << 4, ///< Station has seen an aircraft
|
|
|
|
HVOT_SHIP = 1 << 5, ///< Station has seen a ship
|
2009-07-22 08:59:57 +00:00
|
|
|
|
|
|
|
HVOT_WAYPOINT = 1 << 6, ///< Station is a waypoint (NewGRF only!)
|
2008-03-28 16:33:28 +00:00
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(StationHadVehicleOfType)
|
2008-03-28 16:33:28 +00:00
|
|
|
|
2009-07-07 11:21:14 +00:00
|
|
|
/** The different catchment areas used */
|
2008-03-28 16:33:28 +00:00
|
|
|
enum CatchmentArea {
|
2009-07-07 11:21:14 +00:00
|
|
|
CA_NONE = 0, ///< Catchment when the station has no facilities
|
|
|
|
CA_BUS = 3, ///< Catchment for bus stops with "modified catchment" enabled
|
|
|
|
CA_TRUCK = 3, ///< Catchment for truck stops with "modified catchment" enabled
|
|
|
|
CA_TRAIN = 4, ///< Catchment for train stations with "modified catchment" enabled
|
|
|
|
CA_DOCK = 5, ///< Catchment for docks with "modified catchment" enabled
|
2008-03-28 16:33:28 +00:00
|
|
|
|
2009-07-07 11:21:14 +00:00
|
|
|
CA_UNMODIFIED = 4, ///< Catchment for all stations with "modified catchment" disabled
|
2008-03-28 16:33:28 +00:00
|
|
|
|
2009-07-07 11:21:14 +00:00
|
|
|
MAX_CATCHMENT = 10, ///< Maximum catchment for airports with "modified catchment" enabled
|
2008-03-28 16:33:28 +00:00
|
|
|
};
|
|
|
|
|
2022-01-03 03:05:57 +00:00
|
|
|
enum StationDelivery : byte {
|
|
|
|
SD_NEAREST_FIRST = 0, ///< Station delivers cargo only to the nearest accepting industry
|
|
|
|
SD_BALANCED = 1 ///< Station delivers cargo equally among accepting industries
|
|
|
|
};
|
|
|
|
|
2017-06-01 20:33:36 +00:00
|
|
|
static const uint MAX_LENGTH_STATION_NAME_CHARS = 128; ///< The maximum length of a station name in characters including '\0'
|
2008-08-13 06:05:01 +00:00
|
|
|
|
2019-02-24 18:52:15 +00:00
|
|
|
struct StationCompare {
|
|
|
|
bool operator() (const Station *lhs, const Station *rhs) const;
|
|
|
|
};
|
|
|
|
|
2009-11-15 21:06:13 +00:00
|
|
|
/** List of stations */
|
2019-03-13 02:49:35 +00:00
|
|
|
typedef btree::btree_set<Station *, StationCompare> StationList;
|
2009-11-15 21:06:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Structure contains cached list of stations nearby. The list
|
|
|
|
* is created upon first call to GetStations()
|
|
|
|
*/
|
2010-01-04 18:12:10 +00:00
|
|
|
class StationFinder : TileArea {
|
2009-11-15 21:06:13 +00:00
|
|
|
StationList stations; ///< List of stations nearby
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructs StationFinder
|
2010-01-04 18:12:10 +00:00
|
|
|
* @param area the area to search from
|
2009-11-15 21:06:13 +00:00
|
|
|
*/
|
2010-01-04 18:12:10 +00:00
|
|
|
StationFinder(const TileArea &area) : TileArea(area) {}
|
2009-11-15 21:06:13 +00:00
|
|
|
const StationList *GetStations();
|
|
|
|
};
|
|
|
|
|
2008-03-28 16:33:28 +00:00
|
|
|
#endif /* STATION_TYPE_H */
|