diff options
author | tron <tron@openttd.org> | 2006-03-19 17:15:33 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-19 17:15:33 +0000 |
commit | a751a796e13606d8ebd1a8fe720ff72e0b4c1b11 (patch) | |
tree | c0004e9fad3662ad459f4f0543ef414afdb47304 | |
parent | 7b21893adb7e2368a2402f2640164f3a4482cf5d (diff) | |
download | openttd-a751a796e13606d8ebd1a8fe720ff72e0b4c1b11.tar.xz |
(svn r3984) Add a function to get the road axis of a level crossing
-rw-r--r-- | road_cmd.c | 5 | ||||
-rw-r--r-- | 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; } |