summaryrefslogtreecommitdiff
path: root/rail.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-17 10:10:31 +0000
committertron <tron@openttd.org>2006-03-17 10:10:31 +0000
commit89090790c2405a738f5977310549cf94df9c06cb (patch)
tree0fa3ce74d133cc13b1aaf01d162e59d16ce3371e /rail.c
parentd8677f1afad4e706b92689b471d6c7a6c210aa82 (diff)
downloadopenttd-89090790c2405a738f5977310549cf94df9c06cb.tar.xz
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
Diffstat (limited to 'rail.c')
-rw-r--r--rail.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/rail.c b/rail.c
index 6ff2c54dc..6ca3959ac 100644
--- a/rail.c
+++ b/rail.c
@@ -108,43 +108,39 @@ const Trackdir _reverse_trackdir[] = {
RailType GetTileRailType(TileIndex tile, Trackdir trackdir)
{
- RailType type = INVALID_RAILTYPE;
DiagDirection exitdir = TrackdirToExitdir(trackdir);
switch (GetTileType(tile)) {
case MP_RAILWAY:
- /* railway track */
- type = _m[tile].m3 & RAILTYPE_MASK;
- break;
+ return GetRailType(tile);
+
case MP_STREET:
/* rail/road crossing */
- if (IsLevelCrossing(tile))
- type = _m[tile].m4 & RAILTYPE_MASK;
+ if (IsLevelCrossing(tile)) return GetRailTypeCrossing(tile);
break;
+
case MP_STATION:
- if (IsTrainStationTile(tile))
- type = _m[tile].m3 & RAILTYPE_MASK;
+ if (IsTrainStationTile(tile)) return GetRailType(tile);
break;
+
case MP_TUNNELBRIDGE:
if (IsTunnel(tile)) {
if (GetTunnelTransportType(tile) == TRANSPORT_RAIL) {
- return _m[tile].m3 & RAILTYPE_MASK;
+ return GetRailType(tile);
}
} else {
if (IsBridgeRamp(tile)) {
if (GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
- return _m[tile].m3 & RAILTYPE_MASK;
+ return GetRailType(tile);
}
} else {
if (GetBridgeAxis(tile) == DiagDirToAxis(exitdir)) {
if (GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
- /* on the bridge */
- return (_m[tile].m3 >> 4) & RAILTYPE_MASK;
+ return GetRailTypeOnBridge(tile);
}
} else {
if (IsTransportUnderBridge(tile) &&
GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL) {
- /* under the bridge */
- return _m[tile].m3 & RAILTYPE_MASK;
+ return GetRailType(tile);
}
}
}
@@ -154,5 +150,5 @@ RailType GetTileRailType(TileIndex tile, Trackdir trackdir)
default:
break;
}
- return type;
+ return INVALID_RAILTYPE;
}