diff options
author | rubidium <rubidium@openttd.org> | 2008-06-11 13:54:01 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-06-11 13:54:01 +0000 |
commit | ee843728bf7e40b23b194520803dcd74cac1d25a (patch) | |
tree | 93d0cf5e2656fbaec389d945c2682c766b5756c8 /src/pathfind.cpp | |
parent | 2475d0010b9095de32a3104492f1139c224f1f86 (diff) | |
download | openttd-ee843728bf7e40b23b194520803dcd74cac1d25a.tar.xz |
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
Diffstat (limited to 'src/pathfind.cpp')
-rw-r--r-- | src/pathfind.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/pathfind.cpp b/src/pathfind.cpp index 1f8008364..9757b09af 100644 --- a/src/pathfind.cpp +++ b/src/pathfind.cpp @@ -112,10 +112,29 @@ static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir) static void TPFModeShip(TrackPathFinder* tpf, TileIndex tile, DiagDirection direction) { - RememberData rd; - assert(tpf->tracktype == TRANSPORT_WATER); + if (IsTileType(tile, MP_TUNNELBRIDGE)) { + /* wrong track type */ + if (GetTunnelBridgeTransportType(tile) != tpf->tracktype) return; + + DiagDirection dir = GetTunnelBridgeDirection(tile); + /* entering tunnel / bridge? */ + if (dir == direction) { + TileIndex endtile = GetOtherTunnelBridgeEnd(tile); + + tpf->rd.cur_length += GetTunnelBridgeLength(tile, endtile) + 1; + + TPFSetTileBit(tpf, tile, 14); + TPFSetTileBit(tpf, endtile, 14); + + tile = endtile; + } else { + /* leaving tunnel / bridge? */ + if (ReverseDiagDir(dir) != direction) return; + } + } + /* This addition will sometimes overflow by a single tile. * The use of TILE_MASK here makes sure that we still point at a valid * tile, and then this tile will be in the sentinel row/col, so GetTileTrackStatus will fail. */ @@ -133,7 +152,7 @@ static void TPFModeShip(TrackPathFinder* tpf, TileIndex tile, DiagDirection dire do { Track track = RemoveFirstTrack(&bits); if (bits != TRACK_BIT_NONE) only_one_track = false; - rd = tpf->rd; + RememberData rd = tpf->rd; /* Change direction 4 times only */ if (!only_one_track && track != tpf->rd.last_choosen_track) { |