summaryrefslogtreecommitdiff
path: root/rail.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-16 15:16:27 +0000
committertron <tron@openttd.org>2006-03-16 15:16:27 +0000
commitb8da06ddb11f234451864e0b454163ebb546e4cd (patch)
tree79a0e9518fd43cbe914bddcaebf4983201598bc8 /rail.c
parentd6134455a5aaa7b247545886be573a555cdfc2be (diff)
downloadopenttd-b8da06ddb11f234451864e0b454163ebb546e4cd.tar.xz
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
Diffstat (limited to 'rail.c')
-rw-r--r--rail.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/rail.c b/rail.c
index 94532e695..6ff2c54dc 100644
--- a/rail.c
+++ b/rail.c
@@ -2,6 +2,7 @@
#include "stdafx.h"
#include "openttd.h"
+#include "bridge_map.h"
#include "rail.h"
#include "station.h"
#include "tunnel_map.h"
@@ -124,18 +125,32 @@ RailType GetTileRailType(TileIndex tile, Trackdir trackdir)
type = _m[tile].m3 & RAILTYPE_MASK;
break;
case MP_TUNNELBRIDGE:
- if (IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) {
- return _m[tile].m3 & RAILTYPE_MASK;
+ if (IsTunnel(tile)) {
+ if (GetTunnelTransportType(tile) == TRANSPORT_RAIL) {
+ return _m[tile].m3 & RAILTYPE_MASK;
+ }
+ } else {
+ if (IsBridgeRamp(tile)) {
+ if (GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
+ return _m[tile].m3 & RAILTYPE_MASK;
+ }
+ } else {
+ if (GetBridgeAxis(tile) == DiagDirToAxis(exitdir)) {
+ if (GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
+ /* on the bridge */
+ return (_m[tile].m3 >> 4) & RAILTYPE_MASK;
+ }
+ } else {
+ if (IsTransportUnderBridge(tile) &&
+ GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL) {
+ /* under the bridge */
+ return _m[tile].m3 & RAILTYPE_MASK;
+ }
+ }
+ }
}
- /* railway bridge ending */
- if ((_m[tile].m5 & 0xC6) == 0x80) type = _m[tile].m3 & RAILTYPE_MASK;
- /* on railway bridge */
- if ((_m[tile].m5 & 0xC6) == 0xC0 && ((DiagDirection)(_m[tile].m5 & 0x1)) == (exitdir & 0x1))
- type = (_m[tile].m3 >> 4) & RAILTYPE_MASK;
- /* under bridge (any type) */
- if ((_m[tile].m5 & 0xF8) == 0xE0 && (_m[tile].m5 & 0x1U) != (exitdir & 0x1))
- type = _m[tile].m3 & RAILTYPE_MASK;
break;
+
default:
break;
}