From 68ead6b84f56ad3c93d05ad3e09b7fbb8173cf26 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 22 Jul 2009 08:59:57 +0000 Subject: (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. --- src/station_map.h | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'src/station_map.h') 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); -- cgit v1.2.3-54-g00ecf