summaryrefslogtreecommitdiff
path: root/src/station_map.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-22 08:59:57 +0000
committerrubidium <rubidium@openttd.org>2009-07-22 08:59:57 +0000
commit68ead6b84f56ad3c93d05ad3e09b7fbb8173cf26 (patch)
treeee33bd19b96a138530a84e86e7ffd60c0700f9d9 /src/station_map.h
parent2646a99d29535a44c5998f080131cbca2e85bdcf (diff)
downloadopenttd-68ead6b84f56ad3c93d05ad3e09b7fbb8173cf26.tar.xz
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
-Change: make (rail) waypoints sub classes of 'base stations', make buoys waypoints and unify code between them where possible.
Diffstat (limited to 'src/station_map.h')
-rw-r--r--src/station_map.h41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/station_map.h b/src/station_map.h
index a2bb5df66..ef1a7a54f 100644
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -88,6 +88,28 @@ static inline bool IsRailwayStationTile(TileIndex t)
return IsTileType(t, MP_STATION) && IsRailwayStation(t);
}
+/**
+ * Is this station tile a rail waypoint?
+ * @param t the tile to get the information from
+ * @pre IsTileType(t, MP_STATION)
+ * @return true if and only if the tile is a rail waypoint
+ */
+static inline bool IsRailWaypoint(TileIndex t)
+{
+ return GetStationType(t) == STATION_WAYPOINT;
+}
+
+/**
+ * Is this tile a station tile and a rail waypoint?
+ * @param t the tile to get the information from
+ * @return true if and only if the tile is a rail waypoint
+ */
+static inline bool IsRailWaypointTile(TileIndex t)
+{
+ return IsTileType(t, MP_STATION) && IsRailWaypoint(t);
+}
+
+
static inline bool IsAirport(TileIndex t)
{
return GetStationType(t) == STATION_AIRPORT;
@@ -186,7 +208,7 @@ static inline bool IsHangarTile(TileIndex t)
static inline Axis GetRailStationAxis(TileIndex t)
{
- assert(IsRailwayStation(t));
+ assert(IsRailwayStation(t) || IsRailWaypoint(t));
return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
}
@@ -214,31 +236,31 @@ static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
/**
* Get the reservation state of the rail station
- * @pre IsRailwayStationTile(t)
+ * @pre IsRailwayStation(t) || IsRailWaypoint(t)
* @param t the station tile
* @return reservation state
*/
static inline bool HasStationReservation(TileIndex t)
{
- assert(IsRailwayStationTile(t));
+ assert(IsRailwayStation(t) || IsRailWaypoint(t));
return HasBit(_m[t].m6, 2);
}
/**
* Set the reservation state of the rail station
- * @pre IsRailwayStationTile(t)
+ * @pre IsRailwayStation(t) || IsRailWaypoint(t)
* @param t the station tile
* @param b the reservation state
*/
static inline void SetRailwayStationReservation(TileIndex t, bool b)
{
- assert(IsRailwayStationTile(t));
+ assert(IsRailwayStation(t) || IsRailWaypoint(t));
SB(_m[t].m6, 2, 1, b ? 1 : 0);
}
/**
* Get the reserved track bits for a waypoint
- * @pre IsRailwayStationTile(t)
+ * @pre IsRailwayStation(t) || IsRailWaypoint(t)
* @param t the tile
* @return reserved track bits
*/
@@ -325,6 +347,13 @@ static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a,
SetRailwayStationReservation(t, false);
}
+static inline void MakeRailWaypoint(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
+{
+ MakeStation(t, o, sid, STATION_WAYPOINT, section + a);
+ SetRailType(t, rt);
+ SetRailwayStationReservation(t, false);
+}
+
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)
{
MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);