OpenTTD Source  14.0-beta3
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 <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef DEPOT_MAP_H
11 #define DEPOT_MAP_H
12 
13 #include "station_map.h"
14 
18 inline bool IsDepotTypeTile(Tile tile, TransportType type)
19 {
20  switch (type) {
21  default: NOT_REACHED();
22  case TRANSPORT_RAIL:
23  return IsRailDepotTile(tile);
24 
25  case TRANSPORT_ROAD:
26  return IsRoadDepotTile(tile);
27 
28  case TRANSPORT_WATER:
29  return IsShipDepotTile(tile);
30 
31  case TRANSPORT_AIR:
32  return IsHangarTile(tile);
33  }
34 }
35 
41 inline bool IsDepotTile(Tile tile)
42 {
43  return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
44 }
45 
53 {
54  /* Hangars don't have a Depot class, thus store no DepotID. */
55  assert(IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t));
56  return t.m2();
57 }
58 
66 {
67  switch (GetTileType(t)) {
68  default: NOT_REACHED();
69  case MP_RAILWAY: return VEH_TRAIN;
70  case MP_ROAD: return VEH_ROAD;
71  case MP_WATER: return VEH_SHIP;
72  case MP_STATION: return VEH_AIRCRAFT;
73  }
74 }
75 
76 #endif /* DEPOT_MAP_H */
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition: tile_type.h:49
Tile
Wrapper class to abstract away the way the tiles are stored.
Definition: map_func.h:25
TRANSPORT_WATER
@ TRANSPORT_WATER
Transport over water.
Definition: transport_type.h:29
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
MP_ROAD
@ MP_ROAD
A tile with road (or tram tracks)
Definition: tile_type.h:50
GetTileType
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
Definition: tile_map.h:96
TRANSPORT_RAIL
@ TRANSPORT_RAIL
Transport by train.
Definition: transport_type.h:27
Tile::m2
debug_inline uint16_t & m2()
Primarily used for indices to towns, industries and stations.
Definition: map_func.h:125
TransportType
TransportType
Available types of transport.
Definition: transport_type.h:19
MP_WATER
@ MP_WATER
Water tile.
Definition: tile_type.h:54
IsShipDepotTile
bool IsShipDepotTile(Tile t)
Is it a ship depot tile?
Definition: water_map.h:235
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:18
IsDepotTile
bool IsDepotTile(Tile tile)
Is the given tile a tile with a depot on it?
Definition: depot_map.h:41
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
GetDepotIndex
DepotID GetDepotIndex(Tile t)
Get the index of which depot is attached to the tile.
Definition: depot_map.h:52
GetDepotVehicleType
VehicleType GetDepotVehicleType(Tile t)
Get the type of vehicles that can use a depot.
Definition: depot_map.h:65
DepotID
uint16_t DepotID
Type for the unique identifier of depots.
Definition: depot_type.h:13
IsRailDepotTile
static debug_inline bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
Definition: rail_map.h:105
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:53
TRANSPORT_AIR
@ TRANSPORT_AIR
Transport through air.
Definition: transport_type.h:30
station_map.h
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:28
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
IsRoadDepotTile
static debug_inline bool IsRoadDepotTile(Tile t)
Return whether a tile is a road depot tile.
Definition: road_map.h:116
IsHangarTile
bool IsHangarTile(Tile t)
Is tile t an hangar tile?
Definition: station_map.h:327