Fix: Violation of strict weak ordering in engine name sorter
[openttd-github.git] / src / depot_map.h
blobf92ca9f6e40e98461f7892b778de253926ff7a3a
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 */
8 /** @file depot_map.h Map related accessors for depots. */
10 #ifndef DEPOT_MAP_H
11 #define DEPOT_MAP_H
13 #include "station_map.h"
15 /**
16 * Check if a tile is a depot and it is a depot of the given type.
18 static inline bool IsDepotTypeTile(TileIndex tile, TransportType type)
20 switch (type) {
21 default: NOT_REACHED();
22 case TRANSPORT_RAIL:
23 return IsRailDepotTile(tile);
25 case TRANSPORT_ROAD:
26 return IsRoadDepotTile(tile);
28 case TRANSPORT_WATER:
29 return IsShipDepotTile(tile);
31 case TRANSPORT_AIR:
32 return IsHangarTile(tile);
36 /**
37 * Is the given tile a tile with a depot on it?
38 * @param tile the tile to check
39 * @return true if and only if there is a depot on the tile.
41 static inline bool IsDepotTile(TileIndex tile)
43 return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
46 /**
47 * Get the index of which depot is attached to the tile.
48 * @param t the tile
49 * @pre IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t)
50 * @return DepotID
52 static inline DepotID GetDepotIndex(TileIndex t)
54 /* Hangars don't have a Depot class, thus store no DepotID. */
55 assert(IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t));
56 return _m[t].m2;
59 /**
60 * Get the type of vehicles that can use a depot
61 * @param t The tile
62 * @pre IsDepotTile(t)
63 * @return the type of vehicles that can use the depot
65 static inline VehicleType GetDepotVehicleType(TileIndex t)
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;
76 #endif /* DEPOT_MAP_H */