src/tunnel_map.cpp
changeset 8579 3efbb430092e
parent 7819 694a7dacd30a
child 8604 8afdd9877afd
equal deleted inserted replaced
8578:55218950ce2d 8579:3efbb430092e
     4 
     4 
     5 #include "stdafx.h"
     5 #include "stdafx.h"
     6 #include "openttd.h"
     6 #include "openttd.h"
     7 #include "tile.h"
     7 #include "tile.h"
     8 #include "tunnel_map.h"
     8 #include "tunnel_map.h"
       
     9 #include "tunnelbridge_map.h"
       
    10 
     9 
    11 
    10 /**
    12 /**
    11  * Gets the other end of the tunnel. Where a vehicle would reappear when it
    13  * Gets the other end of the tunnel. Where a vehicle would reappear when it
    12  * enters at the given tile.
    14  * enters at the given tile.
    13  * @param tile the tile to search from.
    15  * @param tile the tile to search from.
    14  * @return the tile of the other end of the tunnel.
    16  * @return the tile of the other end of the tunnel.
    15  */
    17  */
    16 TileIndex GetOtherTunnelEnd(TileIndex tile)
    18 TileIndex GetOtherTunnelEnd(TileIndex tile)
    17 {
    19 {
    18 	DiagDirection dir = GetTunnelDirection(tile);
    20 	DiagDirection dir = GetTunnelBridgeDirection(tile);
    19 	TileIndexDiff delta = TileOffsByDiagDir(dir);
    21 	TileIndexDiff delta = TileOffsByDiagDir(dir);
    20 	uint z = GetTileZ(tile);
    22 	uint z = GetTileZ(tile);
    21 
    23 
    22 	dir = ReverseDiagDir(dir);
    24 	dir = ReverseDiagDir(dir);
    23 	do {
    25 	do {
    24 		tile += delta;
    26 		tile += delta;
    25 	} while (
    27 	} while (
    26 		!IsTunnelTile(tile) ||
    28 		!IsTunnelTile(tile) ||
    27 		GetTunnelDirection(tile) != dir ||
    29 		GetTunnelBridgeDirection(tile) != dir ||
    28 		GetTileZ(tile) != z
    30 		GetTileZ(tile) != z
    29 	);
    31 	);
    30 
    32 
    31 	return tile;
    33 	return tile;
    32 }
    34 }
    50 	} while (z < height);
    52 	} while (z < height);
    51 
    53 
    52 	return
    54 	return
    53 		z == height &&
    55 		z == height &&
    54 		IsTunnelTile(tile) &&
    56 		IsTunnelTile(tile) &&
    55 		GetTunnelDirection(tile) == dir;
    57 		GetTunnelBridgeDirection(tile) == dir;
    56 }
    58 }
    57 
    59 
    58 /**
    60 /**
    59  * Is there a tunnel in the way in any direction?
    61  * Is there a tunnel in the way in any direction?
    60  * @param tile the tile to search from.
    62  * @param tile the tile to search from.