diff options
author | rubidium <rubidium@openttd.org> | 2008-08-02 22:47:48 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-08-02 22:47:48 +0000 |
commit | 8eb9c27f8d6e3511ed832b1738e11f213cc2e5d1 (patch) | |
tree | ab32926a52ecf98f970be7136e5b8f5078296938 /src | |
parent | bef1770590e40860758ff32d45abe7eb7f0666b1 (diff) | |
download | openttd-8eb9c27f8d6e3511ed832b1738e11f213cc2e5d1.tar.xz |
(svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
Diffstat (limited to 'src')
-rw-r--r-- | src/pbs.cpp | 43 | ||||
-rw-r--r-- | src/pbs.h | 13 |
2 files changed, 56 insertions, 0 deletions
diff --git a/src/pbs.cpp b/src/pbs.cpp new file mode 100644 index 000000000..c75eb8caf --- /dev/null +++ b/src/pbs.cpp @@ -0,0 +1,43 @@ +/* $Id$ */ + +/** @file pbs.cpp */ + +#include "stdafx.h" +#include "openttd.h" +#include "pbs.h" +#include "rail_map.h" +#include "road_map.h" +#include "station_map.h" +#include "tunnelbridge_map.h" + +/** + * Get the reserved trackbits for any tile, regardless of type. + * @param t the tile + * @return the reserved trackbits. TRACK_BIT_NONE on nothing reserved or + * a tile without rail. + */ +TrackBits GetReservedTrackbits(TileIndex t) +{ + switch (GetTileType(t)) { + case MP_RAILWAY: + if (IsRailWaypoint(t) || IsRailDepot(t)) return GetRailWaypointReservation(t); + if (IsPlainRailTile(t)) return GetTrackReservation(t); + break; + + case MP_ROAD: + if (IsLevelCrossing(t)) return GetRailCrossingReservation(t); + break; + + case MP_STATION: + if (IsRailwayStation(t)) return GetRailStationReservation(t); + break; + + case MP_TUNNELBRIDGE: + if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) return GetRailTunnelBridgeReservation(t); + break; + + default: + break; + } + return TRACK_BIT_NONE; +} diff --git a/src/pbs.h b/src/pbs.h new file mode 100644 index 000000000..51a9ba201 --- /dev/null +++ b/src/pbs.h @@ -0,0 +1,13 @@ +/* $Id$ */ + +/** @file pbs.h PBS support routines */ + +#ifndef PBS_H +#define PBS_H + +#include "tile_type.h" +#include "track_type.h" + +TrackBits GetReservedTrackbits(TileIndex t); + +#endif /* PBS_H */ |