(svn r28004) -Update from Eints:
[openttd.git] / src / depot_map.h
blobc304790f8a58b8025c57fb3c0dda1743ddcf77a4
1 /* $Id$ */
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 */
10 /** @file depot_map.h Map related accessors for depots. */
12 #ifndef DEPOT_MAP_H
13 #define DEPOT_MAP_H
15 #include "station_map.h"
17 /**
18 * Check if a tile is a depot and it is a depot of the given type.
20 static inline bool IsDepotTypeTile(TileIndex tile, TransportType type)
22 switch (type) {
23 default: NOT_REACHED();
24 case TRANSPORT_RAIL:
25 return IsRailDepotTile(tile);
27 case TRANSPORT_ROAD:
28 return IsRoadDepotTile(tile);
30 case TRANSPORT_WATER:
31 return IsShipDepotTile(tile);
33 case TRANSPORT_AIR:
34 return IsHangarTile(tile);
38 /**
39 * Is the given tile a tile with a depot on it?
40 * @param tile the tile to check
41 * @return true if and only if there is a depot on the tile.
43 static inline bool IsDepotTile(TileIndex tile)
45 return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
48 /**
49 * Get the index of which depot is attached to the tile.
50 * @param t the tile
51 * @pre IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t)
52 * @return DepotID
54 static inline DepotID GetDepotIndex(TileIndex t)
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;
61 /**
62 * Get the type of vehicles that can use a depot
63 * @param t The tile
64 * @pre IsDepotTile(t)
65 * @return the type of vehicles that can use the depot
67 static inline VehicleType GetDepotVehicleType(TileIndex t)
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;
78 #endif /* DEPOT_MAP_H */