equal
deleted
inserted
replaced
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 |
9 |
|
10 /** |
|
11 * Gets the other end of the tunnel. Where a vehicle would reappear when it |
|
12 * enters at the given tile. |
|
13 * @param tile the tile to search from. |
|
14 * @return the tile of the other end of the tunnel. |
|
15 */ |
10 TileIndex GetOtherTunnelEnd(TileIndex tile) |
16 TileIndex GetOtherTunnelEnd(TileIndex tile) |
11 { |
17 { |
12 DiagDirection dir = GetTunnelDirection(tile); |
18 DiagDirection dir = GetTunnelDirection(tile); |
13 TileIndexDiff delta = TileOffsByDiagDir(dir); |
19 TileIndexDiff delta = TileOffsByDiagDir(dir); |
14 uint z = GetTileZ(tile); |
20 uint z = GetTileZ(tile); |
24 |
30 |
25 return tile; |
31 return tile; |
26 } |
32 } |
27 |
33 |
28 |
34 |
|
35 /** |
|
36 * Is there a tunnel in the way in the given direction? |
|
37 * @param tile the tile to search from. |
|
38 * @param z the 'z' to search on. |
|
39 * @param dir the direction to start searching to. |
|
40 * @return true if and only if there is a tunnel. |
|
41 */ |
29 static bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir) |
42 static bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir) |
30 { |
43 { |
31 TileIndexDiff delta = TileOffsByDiagDir(dir); |
44 TileIndexDiff delta = TileOffsByDiagDir(dir); |
32 uint height; |
45 uint height; |
33 |
46 |
40 z == height && |
53 z == height && |
41 IsTunnelTile(tile) && |
54 IsTunnelTile(tile) && |
42 GetTunnelDirection(tile) == dir; |
55 GetTunnelDirection(tile) == dir; |
43 } |
56 } |
44 |
57 |
|
58 /** |
|
59 * Is there a tunnel in the way in any direction? |
|
60 * @param tile the tile to search from. |
|
61 * @param z the 'z' to search on. |
|
62 * @return true if and only if there is a tunnel. |
|
63 */ |
45 bool IsTunnelInWay(TileIndex tile, uint z) |
64 bool IsTunnelInWay(TileIndex tile, uint z) |
46 { |
65 { |
47 return |
66 return |
48 IsTunnelInWayDir(tile, z, DIAGDIR_NE) || |
67 IsTunnelInWayDir(tile, z, DIAGDIR_NE) || |
49 IsTunnelInWayDir(tile, z, DIAGDIR_SE) || |
68 IsTunnelInWayDir(tile, z, DIAGDIR_SE) || |