From af42610321be880879f00753c0ead19352495b63 Mon Sep 17 00:00:00 2001 From: tron Date: Mon, 6 Mar 2006 20:55:24 +0000 Subject: (svn r3777) Add some functions to handle tunnels --- rail_cmd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'rail_cmd.c') 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; } -- cgit v1.2.3-54-g00ecf