OpenTTD Source: src/depot_map.h Source File

OpenTTD Source 15.3

depot_map.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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef DEPOT_MAP_H
11#define DEPOT_MAP_H
12
13#include "order_type.h"
14#include "station_map.h"
15
19 inline bool IsDepotTypeTile(Tile tile, TransportType type)
20{
21 switch (type) {
22 default: NOT_REACHED();
23 case TRANSPORT_RAIL:
24 return IsRailDepotTile(tile);
25
26 case TRANSPORT_ROAD:
27 return IsRoadDepotTile(tile);
28
29 case TRANSPORT_WATER:
30 return IsShipDepotTile(tile);
31
32 case TRANSPORT_AIR:
33 return IsHangarTile(tile);
34 }
35}
36
42 inline bool IsDepotTile(Tile tile)
43{
44 return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
45}
46
53 inline DepotID GetDepotIndex(Tile t)
54{
55 /* Hangars don't have a Depot class, thus store no DepotID. */
56 assert(IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t));
57 return DepotID{t.m2()};
58}
59
66 inline DestinationID GetDepotDestinationIndex(Tile t)
67{
68 if (IsHangarTile(t)) return GetStationIndex(t);
69 return GetDepotIndex(t);
70}
71
78 inline VehicleType GetDepotVehicleType(Tile t)
79{
80 switch (GetTileType(t)) {
81 default: NOT_REACHED();
82 case MP_RAILWAY: return VEH_TRAIN;
83 case MP_ROAD: return VEH_ROAD;
84 case MP_WATER: return VEH_SHIP;
85 case MP_STATION: return VEH_AIRCRAFT;
86 }
87}
88
89#endif /* DEPOT_MAP_H */
Tile
Wrapper class to abstract away the way the tiles are stored.
Definition map_func.h:25
Tile::m2
uint16_t & m2()
Primarily used for indices to towns, industries and stations.
Definition map_func.h:125
GetDepotIndex
DepotID GetDepotIndex(Tile t)
Get the index of which depot is attached to the tile.
Definition depot_map.h:53
IsDepotTypeTile
bool IsDepotTypeTile(Tile tile, TransportType type)
Check if a tile is a depot and it is a depot of the given type.
Definition depot_map.h:19
IsDepotTile
bool IsDepotTile(Tile tile)
Is the given tile a tile with a depot on it?
Definition depot_map.h:42
GetDepotDestinationIndex
DestinationID GetDepotDestinationIndex(Tile t)
Get the destination index of a 'depot'.
Definition depot_map.h:66
GetDepotVehicleType
VehicleType GetDepotVehicleType(Tile t)
Get the type of vehicles that can use a depot.
Definition depot_map.h:78
order_type.h
Types related to orders.
IsRailDepotTile
static bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
Definition rail_map.h:105
IsRoadDepotTile
static bool IsRoadDepotTile(Tile t)
Return whether a tile is a road depot tile.
Definition road_map.h:100
station_map.h
Maps accessors for stations.
GetStationIndex
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition station_map.h:28
IsHangarTile
bool IsHangarTile(Tile t)
Is tile t an hangar tile?
Definition station_map.h:420
DestinationID
Definition order_type.h:21
PoolID
Templated helper to make a PoolID a single POD value.
Definition pool_type.hpp:43
GetTileType
static TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
Definition tile_map.h:96
MP_ROAD
@ MP_ROAD
A tile with road (or tram tracks)
Definition tile_type.h:50
MP_STATION
@ MP_STATION
A tile of a station.
Definition tile_type.h:53
MP_WATER
@ MP_WATER
Water tile.
Definition tile_type.h:54
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition tile_type.h:49
TransportType
TransportType
Available types of transport.
Definition transport_type.h:17
TRANSPORT_RAIL
@ TRANSPORT_RAIL
Transport by train.
Definition transport_type.h:25
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition transport_type.h:26
TRANSPORT_WATER
@ TRANSPORT_WATER
Transport over water.
Definition transport_type.h:27
TRANSPORT_AIR
@ TRANSPORT_AIR
Transport through air.
Definition transport_type.h:28
VehicleType
VehicleType
Available vehicle types.
Definition vehicle_type.h:22
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition vehicle_type.h:26
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition vehicle_type.h:28
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition vehicle_type.h:27
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition vehicle_type.h:25
IsShipDepotTile
bool IsShipDepotTile(Tile t)
Is it a ship depot tile?
Definition water_map.h:234