summaryrefslogtreecommitdiff
path: root/src/station_map.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-08-02 22:47:20 +0000
committerrubidium <rubidium@openttd.org>2008-08-02 22:47:20 +0000
commit11bf3902c46fd559e203cbee59489048ad3c62b3 (patch)
tree8771ffd53d04267f920a1a780c439b1f8f8c63de /src/station_map.h
parentc85451555b9dd32bb6f3dd0fae9511528dc0a8dd (diff)
downloadopenttd-11bf3902c46fd559e203cbee59489048ad3c62b3.tar.xz
(svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
Diffstat (limited to 'src/station_map.h')
-rw-r--r--src/station_map.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/station_map.h b/src/station_map.h
index 7422a32e5..77d427958 100644
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -204,6 +204,41 @@ static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
!IsStationTileBlocked(t1);
}
+/**
+ * Get the reservation state of the rail station
+ * @pre IsRailwayStationTile(t)
+ * @param t the station tile
+ * @return reservation state
+ */
+static inline bool GetRailwayStationReservation(TileIndex t)
+{
+ assert(IsRailwayStationTile(t));
+ return HasBit(_m[t].m6, 2);
+}
+
+/**
+ * Set the reservation state of the rail station
+ * @pre IsRailwayStationTile(t)
+ * @param t the station tile
+ * @param b the reservation state
+ */
+static inline void SetRailwayStationReservation(TileIndex t, bool b)
+{
+ assert(IsRailwayStationTile(t));
+ SB(_m[t].m6, 2, 1, b ? 1 : 0);
+}
+
+/**
+ * Get the reserved track bits for a waypoint
+ * @pre IsRailwayStationTile(t)
+ * @param t the tile
+ * @return reserved track bits
+ */
+static inline TrackBits GetRailStationReservation(TileIndex t)
+{
+ return GetRailwayStationReservation(t) ? AxisToTrackBits(GetRailStationAxis(t)) : TRACK_BIT_NONE;
+}
+
static inline DiagDirection GetDockDirection(TileIndex t)
{
@@ -277,6 +312,7 @@ static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a,
{
MakeStation(t, o, sid, STATION_RAIL, section + a);
SetRailType(t, rt);
+ SetRailwayStationReservation(t, false);
}
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)