From a751a796e13606d8ebd1a8fe720ff72e0b4c1b11 Mon Sep 17 00:00:00 2001 From: tron Date: Sun, 19 Mar 2006 17:15:33 +0000 Subject: (svn r3984) Add a function to get the road axis of a level crossing --- road_cmd.c | 5 +++-- road_map.h | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/road_cmd.c b/road_cmd.c index 79c3e213c..3108c4536 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -778,7 +778,7 @@ static void DrawTile_Road(TileInfo *ti) image = GetRailTypeInfo(GetRailTypeCrossing(ti->tile))->base_sprites.crossing; - if (GB(ti->map5, 3, 1) == 0) image++; /* direction */ + if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++; if ((ti->map5 & 4) != 0) image += 2; @@ -1048,7 +1048,8 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode) 0 : _road_trackbits[GetRoadBits(tile)] * 0x101; case ROAD_CROSSING: { - uint32 r = (_m[tile].m5 & 8 ? 0x202 : 0x101); + uint32 r = (GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101; + if (_m[tile].m5 & 4) r *= 0x10001; return r; } diff --git a/road_map.h b/road_map.h index d40ddc92c..3e506bf72 100644 --- a/road_map.h +++ b/road_map.h @@ -39,14 +39,19 @@ static inline void SetRoadBits(TileIndex tile, RoadBits r) } +static inline Axis GetCrossingRoadAxis(TileIndex tile) +{ + return (Axis)GB(_m[tile].m5, 3, 1); +} + static inline RoadBits GetCrossingRoadBits(TileIndex tile) { - return _m[tile].m5 & 8 ? ROAD_Y : ROAD_X; + return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y; } static inline TrackBits GetCrossingRailBits(TileIndex tile) { - return _m[tile].m5 & 8 ? TRACK_BIT_X : TRACK_BIT_Y; + return GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X; } -- cgit v1.2.3-70-g09d2