summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-19 17:15:33 +0000
committertron <tron@openttd.org>2006-03-19 17:15:33 +0000
commita2572f91baf86b1ce829ec4b1c28df41abb31632 (patch)
treec0004e9fad3662ad459f4f0543ef414afdb47304
parent4d71a903b5c7c4163efa7137c6ce632dd738cc4c (diff)
downloadopenttd-a2572f91baf86b1ce829ec4b1c28df41abb31632.tar.xz
(svn r3984) Add a function to get the road axis of a level crossing
-rw-r--r--road_cmd.c5
-rw-r--r--road_map.h9
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;
}