From fc47ae96c42f49df29e7bc812eb446a49c41e71a Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 2 Aug 2008 22:48:43 +0000 Subject: (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc) --- src/rail_map.h | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/rail_map.h') diff --git a/src/rail_map.h b/src/rail_map.h index 649e3baed..2d25feb5a 100644 --- a/src/rail_map.h +++ b/src/rail_map.h @@ -338,19 +338,24 @@ static inline TrackBits GetRailDepotReservation(TileIndex t) } +static inline bool IsPbsSignal(SignalType s) +{ + return s == SIGTYPE_PBS || s == SIGTYPE_PBS_ONEWAY; +} + static inline SignalType GetSignalType(TileIndex t, Track track) { assert(GetRailTileType(t) == RAIL_TILE_SIGNALS); byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0; - return (SignalType)GB(_m[t].m2, pos, 2); + return (SignalType)GB(_m[t].m2, pos, 3); } static inline void SetSignalType(TileIndex t, Track track, SignalType s) { assert(GetRailTileType(t) == RAIL_TILE_SIGNALS); byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0; - SB(_m[t].m2, pos, 2, s); - if (track == INVALID_TRACK) SB(_m[t].m2, 4, 2, s); + SB(_m[t].m2, pos, 3, s); + if (track == INVALID_TRACK) SB(_m[t].m2, 4, 3, s); } static inline bool IsPresignalEntry(TileIndex t, Track track) @@ -375,15 +380,15 @@ static inline void CycleSignalSide(TileIndex t, Track track) static inline SignalVariant GetSignalVariant(TileIndex t, Track track) { - byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 6 : 2; + byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 3; return (SignalVariant)GB(_m[t].m2, pos, 1); } static inline void SetSignalVariant(TileIndex t, Track track, SignalVariant v) { - byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 6 : 2; + byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 3; SB(_m[t].m2, pos, 1, v); - if (track == INVALID_TRACK) SB(_m[t].m2, 6, 1, v); + if (track == INVALID_TRACK) SB(_m[t].m2, 7, 1, v); } /** These are states in which a signal can be. Currently these are only two, so @@ -510,6 +515,19 @@ static inline void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, S } } +/** + * Is a pbs signal present along the trackdir? + * @param tile the tile to check + * @param td the trackdir to check + */ +static inline bool HasPbsSignalOnTrackdir(TileIndex tile, Trackdir td) +{ + return + IsTileType(tile, MP_RAILWAY) && + HasSignalOnTrackdir(tile, td) && + IsPbsSignal(GetSignalType(tile, TrackdirToTrack(td))); +} + /** * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile. -- cgit v1.2.3-70-g09d2