summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-21 19:37:10 +0000
committertruelight <truelight@openttd.org>2004-12-21 19:37:10 +0000
commitaf4f4069ee48a235d1eaf8e52342dc45ce4f0bc2 (patch)
tree29b245b90aa9e17c5a921b786d0e9fca36f65c40
parentd9199657c1a67163a959a7567eb0e2980fe0c110 (diff)
downloadopenttd-af4f4069ee48a235d1eaf8e52342dc45ce4f0bc2.tar.xz
(svn r1208) -Fix: the owner-check introduced in r1203 now also works correctly for
bridges (the middle-parts don't have any owner)
-rw-r--r--pathfind.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/pathfind.c b/pathfind.c
index 6f68257a2..c3a300cbc 100644
--- a/pathfind.c
+++ b/pathfind.c
@@ -128,9 +128,14 @@ static void TPFMode2(TrackPathFinder *tpf, uint tile, int direction)
uint bits;
int i;
RememberData rd;
- byte owner;
+ int owner;
- owner = _map_owner[tile];
+ if (tpf->tracktype == TRANSPORT_RAIL) {
+ owner = _map_owner[tile];
+ /* Check if we are on the middle of a bridge (has no owner) */
+ if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xC0) == 0xC0)
+ owner = -1;
+ }
// This addition will sometimes overflow by a single tile.
// The use of TILE_MASK here makes sure that we still point at a valid
@@ -138,8 +143,12 @@ static void TPFMode2(TrackPathFinder *tpf, uint tile, int direction)
tile = TILE_MASK(tile + _tileoffs_by_dir[direction]);
/* Check in case of rail if the owner is the same */
- if (tpf->tracktype == TRANSPORT_RAIL && _map_owner[tile] != owner)
- return;
+ if (tpf->tracktype == TRANSPORT_RAIL) {
+ /* Check if we are on the middle of a bridge (has no owner) */
+ if (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0)
+ if (owner != -1 && _map_owner[tile] != owner)
+ return;
+ }
if (++tpf->rd.cur_length > 50)
return;
@@ -277,8 +286,13 @@ static void TPFMode1(TrackPathFinder *tpf, uint tile, int direction)
tile += _tileoffs_by_dir[direction];
/* Check in case of rail if the owner is the same */
- if (tpf->tracktype == TRANSPORT_RAIL && _map_owner[tile_org] != _map_owner[tile])
- return;
+ if (tpf->tracktype == TRANSPORT_RAIL) {
+ /* Check if we are on a bridge (middle parts don't have an owner */
+ if (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0)
+ if (!IS_TILETYPE(tile_org, MP_TUNNELBRIDGE) || (_map5[tile_org] & 0xC0) != 0xC0)
+ if (_map_owner[tile_org] != _map_owner[tile])
+ return;
+ }
tpf->rd.cur_length++;