summaryrefslogtreecommitdiff
path: root/src/depot_map.h
diff options
context:
space:
mode:
authorzuu <zuu@openttd.org>2013-10-13 20:11:05 +0000
committerzuu <zuu@openttd.org>2013-10-13 20:11:05 +0000
commitcef1c47f18591678fbe4df4e0f343b6561cb6b01 (patch)
tree7370f95304dec517a7937ffcc0d75770d7ba2658 /src/depot_map.h
parent12ddbb7cb11ddeba47a6bed8d36bef6432aa3236 (diff)
downloadopenttd-cef1c47f18591678fbe4df4e0f343b6561cb6b01.tar.xz
(svn r25865) -Codechange: Refactor detecting of depot vehicle type of a tile to a new function, GetDepotVehicleType (cirdan, LordAro)
Diffstat (limited to 'src/depot_map.h')
-rw-r--r--src/depot_map.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/depot_map.h b/src/depot_map.h
index b4f7a11ec..e55994869 100644
--- a/src/depot_map.h
+++ b/src/depot_map.h
@@ -55,4 +55,21 @@ static inline DepotID GetDepotIndex(TileIndex t)
return _m[t].m2;
}
+/**
+ * Get the type of vehicles that can use a depot
+ * @param t The tile
+ * @pre IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t) || IsTileType(t, MP_STATION)
+ * @return the type of vehicles that can use the depot
+ */
+static inline VehicleType GetDepotVehicleType(TileIndex t)
+{
+ switch (GetTileType(t)) {
+ default: NOT_REACHED();
+ case MP_RAILWAY: return VEH_TRAIN;
+ case MP_ROAD: return VEH_ROAD;
+ case MP_WATER: return VEH_SHIP;
+ case MP_STATION: return VEH_AIRCRAFT;
+ }
+}
+
#endif /* DEPOT_MAP_H */