summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-03-22 10:56:08 +0000
committerrubidium <rubidium@openttd.org>2008-03-22 10:56:08 +0000
commitf0538b4b622a80a93d27e7dc9f1cb05620eebb90 (patch)
treec70cc515d076c09e820b06aa4af1dbdb1fe37307 /src
parent5d747802f28d6fd6ad2527aa04f418ce09c00f6c (diff)
downloadopenttd-f0538b4b622a80a93d27e7dc9f1cb05620eebb90.tar.xz
(svn r12390) -Fix [FS#1851]: trams failing to turn on bridge heads/tunnel entrances.
Diffstat (limited to 'src')
-rw-r--r--src/road_func.h14
-rw-r--r--src/road_map.cpp6
-rw-r--r--src/road_map.h7
-rw-r--r--src/roadveh_cmd.cpp4
4 files changed, 26 insertions, 5 deletions
diff --git a/src/road_func.h b/src/road_func.h
index 3139ea022..46269f29d 100644
--- a/src/road_func.h
+++ b/src/road_func.h
@@ -115,6 +115,20 @@ static inline RoadBits DiagDirToRoadBits(DiagDirection d)
}
/**
+ * Create the road-part which belongs to the given Axis
+ *
+ * This function returns a RoadBits value which belongs to
+ * the given Axis.
+ *
+ * @param a The Axis
+ * @return The result RoadBits which the selected road-part set
+ */
+static inline RoadBits AxisToRoadBits(Axis a)
+{
+ return a == AXIS_X ? ROAD_X : ROAD_Y;
+}
+
+/**
* Finds out, whether given player has all given RoadTypes available
* @param PlayerID ID of player
* @param rts RoadTypes to test
diff --git a/src/road_map.cpp b/src/road_map.cpp
index 2d236b504..a39fa5fc9 100644
--- a/src/road_map.cpp
+++ b/src/road_map.cpp
@@ -14,7 +14,7 @@
#include "tunnelbridge_map.h"
-RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt)
+RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
{
if (!HasTileRoadType(tile, rt)) return ROAD_NONE;
@@ -34,7 +34,9 @@ RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt)
case MP_TUNNELBRIDGE:
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
- return DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
+ return straight_tunnel_bridge_entrance ?
+ AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) :
+ DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
default: return ROAD_NONE;
}
diff --git a/src/road_map.h b/src/road_map.h
index 35a3f9cf2..2f29a97be 100644
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -328,11 +328,16 @@ static inline DiagDirection GetRoadDepotDirection(TileIndex t)
* - road tunnels: entrance is treated as road piece
* - bridge ramps: start of the ramp is treated as road piece
* - bridge middle parts: bridge itself is ignored
+ *
+ * If straight_tunnel_bridge_entrance is set a ROAD_X or ROAD_Y
+ * for bridge ramps and tunnel entrances is returned depending
+ * on the orientation of the tunnel or bridge.
* @param tile the tile to get the road bits for
* @param rt the road type to get the road bits form
+ * @param stbe whether to return straight road bits for tunnels/bridges.
* @return the road bits of the given tile
*/
-RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt);
+RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance = false);
/**
* Get the accessible track bits for the given tile.
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 0a9733209..d4cb02163 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1461,7 +1461,7 @@ static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev,
};
RoadBits required = required_roadbits[dir & 0x07];
- if ((required & GetAnyRoadBits(tile, v->u.road.roadtype)) == ROAD_NONE) {
+ if ((required & GetAnyRoadBits(tile, v->u.road.roadtype, true)) == ROAD_NONE) {
dir = INVALID_TRACKDIR;
}
@@ -1698,7 +1698,7 @@ again:
uint turn_around_start_frame = RVC_TURN_AROUND_START_FRAME;
RoadBits tram;
- if (v->u.road.roadtype == ROADTYPE_TRAM && CountBits(tram = GetAnyRoadBits(v->tile, ROADTYPE_TRAM)) == 1) {
+ if (v->u.road.roadtype == ROADTYPE_TRAM && CountBits(tram = GetAnyRoadBits(v->tile, ROADTYPE_TRAM, true)) == 1) {
/*
* The tram is turning around with one tram 'roadbit'. This means that
* it is using the 'big' corner 'drive data'. However, to support the