OpenTTD

depot_map.h
Go to the documentation of this file.
1 /* $Id: depot_map.h 26692 2014-07-16 20:56:39Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef DEPOT_MAP_H
13 #define DEPOT_MAP_H
14
15 #include "station_map.h"
16
20 static inline bool IsDepotTypeTile(TileIndex tile, TransportType type)
21 {
22 switch (type) {
23 default: NOT_REACHED();
24 case TRANSPORT_RAIL:
25 return IsRailDepotTile(tile);
26
27 case TRANSPORT_ROAD:
28 return IsRoadDepotTile(tile);
29
30 case TRANSPORT_WATER:
31 return IsShipDepotTile(tile);
32
33 case TRANSPORT_AIR:
34 return IsHangarTile(tile);
35 }
36 }
37
43 static inline bool IsDepotTile(TileIndex tile)
44 {
45 return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
46 }
47
54 static inline DepotID GetDepotIndex(TileIndex t)
55 {
56 /* Hangars don't have a Depot class, thus store no DepotID. */
57 assert(IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t));
58 return _m[t].m2;
59 }
60
67 static inline VehicleType GetDepotVehicleType(TileIndex t)
68 {
69 switch (GetTileType(t)) {
70 default: NOT_REACHED();
71 case MP_RAILWAY: return VEH_TRAIN;
72 case MP_ROAD: return VEH_ROAD;
73 case MP_WATER: return VEH_SHIP;
74 case MP_STATION: return VEH_AIRCRAFT;
75 }
76 }
77
78 #endif /* DEPOT_MAP_H */
GetTileType
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
Definition: tile_map.h:89
DepotID
uint16 DepotID
Type for the unique identifier of depots.
Definition: depot_type.h:15
station_map.h
Maps accessors for stations.
Tile::m2
uint16 m2
Primarily used for indices to towns, industries and stations.
Definition: map_type.h:22
MP_ROAD
A tile with road (or tram tracks)
Definition: tile_type.h:45
_m
Tile * _m
Tiles of the map.
Definition: map.cpp:32
TRANSPORT_WATER
Transport over water.
Definition: transport_type.h:31
TRANSPORT_AIR
Transport through air.
Definition: transport_type.h:32
MP_RAILWAY
A railway.
Definition: tile_type.h:44
VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
IsDepotTypeTile
static bool IsDepotTypeTile(TileIndex tile, TransportType type)
Check if a tile is a depot and it is a depot of the given type.
Definition: depot_map.h:20
MP_WATER
Water tile.
Definition: tile_type.h:49
IsRoadDepotTile
static bool IsRoadDepotTile(TileIndex t)
Return whether a tile is a road depot tile.
Definition: road_map.h:99
VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
GetDepotVehicleType
static VehicleType GetDepotVehicleType(TileIndex t)
Get the type of vehicles that can use a depot.
Definition: depot_map.h:67
IsShipDepotTile
static bool IsShipDepotTile(TileIndex t)
Is it a ship depot tile?
Definition: water_map.h:226
GetDepotIndex
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Definition: depot_map.h:54
VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
TRANSPORT_RAIL
Transport by train.
Definition: transport_type.h:29
IsRailDepotTile
static bool IsRailDepotTile(TileIndex t)
Is this tile rail tile and a rail depot?
Definition: rail_map.h:106
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
TransportType
TransportType
Available types of transport.
Definition: transport_type.h:21
MP_STATION
A tile of a station.
Definition: tile_type.h:48
TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:30
IsHangarTile
static bool IsHangarTile(TileIndex t)
Is tile t an hangar tile?
Definition: station_map.h:327
IsDepotTile
static bool IsDepotTile(TileIndex tile)
Is the given tile a tile with a depot on it?
Definition: depot_map.h:43
VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24