summaryrefslogtreecommitdiff
path: root/rail_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-06 20:55:24 +0000
committertron <tron@openttd.org>2006-03-06 20:55:24 +0000
commitaf42610321be880879f00753c0ead19352495b63 (patch)
tree14ef1d7e7e885dff603aa06189b416a7bd2a6ae0 /rail_cmd.c
parent49cb8eb470a886dcfebd827dec1fcd8a55c2dffb (diff)
downloadopenttd-af42610321be880879f00753c0ead19352495b63.tar.xz
(svn r3777) Add some functions to handle tunnels
Diffstat (limited to 'rail_cmd.c')
-rw-r--r--rail_cmd.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index f00ca595c..3aad4431e 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -10,6 +10,7 @@
#include "table/strings.h"
#include "map.h"
#include "tile.h"
+#include "tunnel_map.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
@@ -1627,21 +1628,21 @@ static bool SignalVehicleCheck(TileIndex tile, uint track)
if (IsTileType(tile, MP_TUNNELBRIDGE) && GB(_m[tile].m5, 4, 4) == 0) {
// It is a tunnel we're checking, we need to do some special stuff
// because VehicleFromPos will not find the vihicle otherwise
- byte direction = GB(_m[tile].m5, 0, 2);
- FindLengthOfTunnelResult flotr;
- flotr = FindLengthOfTunnel(tile, direction);
+ TileIndex end = GetOtherTunnelEnd(tile);
+ DiagDirection direction = GetTunnelDirection(tile);
+
dest.track = 1 << (direction & 1); // get the trackbit the vehicle would have if it has not entered the tunnel yet (ie is still visible)
// check for a vehicle with that trackdir on the start tile of the tunnel
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
// check for a vehicle with that trackdir on the end tile of the tunnel
- if (VehicleFromPos(flotr.tile, &dest, SignalVehicleCheckProc) != NULL) return true;
+ if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
// now check all tiles from start to end for a "hidden" vehicle
// NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile?
dest.track = 0x40; // trackbit for vehicles "hidden" inside a tunnel
- for (; tile != flotr.tile; tile += TileOffsByDir(direction)) {
+ for (; tile != end; tile += TileOffsByDir(direction)) {
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL)
return true;
}