summaryrefslogtreecommitdiff
path: root/pathfind.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
commitf2dc736554c06d69dd936131c4a09ddbc6b58083 (patch)
tree14ef1d7e7e885dff603aa06189b416a7bd2a6ae0 /pathfind.c
parent2d3c28f2b3d24c2b01e54a51e2dcf5ad7f4851c8 (diff)
downloadopenttd-f2dc736554c06d69dd936131c4a09ddbc6b58083.tar.xz
(svn r3777) Add some functions to handle tunnels
Diffstat (limited to 'pathfind.c')
-rw-r--r--pathfind.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/pathfind.c b/pathfind.c
index 8e0621bd9..b0518f6fd 100644
--- a/pathfind.c
+++ b/pathfind.c
@@ -8,6 +8,7 @@
#include "pathfind.h"
#include "rail.h"
#include "debug.h"
+#include "tunnel_map.h"
#include "variables.h"
// remember which tiles we have already visited so we don't visit them again.
@@ -232,8 +233,8 @@ FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, uint direction)
if (IsTileType(tile, MP_TUNNELBRIDGE) &&
GB(_m[tile].m5, 4, 4) == 0 && // tunnel entrance/exit
- // GB(_m[tile].m5, 2, 2) == type && // rail/road-tunnel <-- This is not necesary to check, right?
- (GB(_m[tile].m5, 0, 2) ^ 2) == direction && // entrance towards: 0 = NE, 1 = SE, 2 = SW, 3 = NW
+ // GetTunnelTransportType(tile) == type && // rail/road-tunnel <-- This is not necesary to check, right?
+ ReverseDiagDir(GetTunnelDirection(tile)) == direction &&
GetSlopeZ(x + 8, y + 8) == z) {
break;
}
@@ -283,8 +284,8 @@ static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection directi
TileIndex tile_org = tile;
if (IsTileType(tile, MP_TUNNELBRIDGE) && GB(_m[tile].m5, 4, 4) == 0) {
- if (GB(_m[tile].m5, 0, 2) != direction ||
- GB(_m[tile].m5, 2, 2) != tpf->tracktype) {
+ if (GetTunnelDirection(tile) != direction ||
+ GetTunnelTransportType(tile) != tpf->tracktype) {
return;
}
tile = SkipToEndOfTunnel(tpf, tile, direction);
@@ -717,13 +718,14 @@ start_at:
// need to find the exit of the tunnel.
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
if (GB(_m[tile].m5, 4, 4) == 0 &&
- GB(_m[tile].m5, 0, 2) != (direction ^ 2)) {
+ GetTunnelDirection(tile) != ReverseDiagDir(direction)) {
/* This is a tunnel tile */
/* We are not just driving out of the tunnel */
- if (GB(_m[tile].m5, 0, 2) != direction || GB(_m[tile].m5, 2, 2) != tpf->tracktype)
- /* We are not driving into the tunnel, or it
- * is an invalid tunnel */
+ if (GetTunnelDirection(tile) != direction ||
+ GetTunnelTransportType(tile) != tpf->tracktype) {
+ // We are not driving into the tunnel, or it is an invalid tunnel
continue;
+ }
flotr = FindLengthOfTunnel(tile, direction);
si.cur_length += flotr.length * DIAG_FACTOR;
tile = flotr.tile;