129 int i; |
129 int i; |
130 RememberData rd; |
130 RememberData rd; |
131 int owner = -1; |
131 int owner = -1; |
132 |
132 |
133 if (tpf->tracktype == TRANSPORT_RAIL) { |
133 if (tpf->tracktype == TRANSPORT_RAIL) { |
134 if ((IS_TILETYPE(tile, MP_RAILWAY) || IS_TILETYPE(tile, MP_STATION) || IS_TILETYPE(tile, MP_TUNNELBRIDGE))) { |
134 if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE)) { |
135 owner = _map_owner[tile]; |
135 owner = _map_owner[tile]; |
136 /* Check if we are on the middle of a bridge (has no owner) */ |
136 /* Check if we are on the middle of a bridge (has no owner) */ |
137 if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xC0) == 0xC0) |
137 if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xC0) == 0xC0) |
138 owner = -1; |
138 owner = -1; |
139 } |
139 } |
140 } |
140 } |
141 |
141 |
142 // This addition will sometimes overflow by a single tile. |
142 // This addition will sometimes overflow by a single tile. |
144 // tile, and then this tile will be in the sentinel row/col, so GetTileTrackStatus will fail. |
144 // tile, and then this tile will be in the sentinel row/col, so GetTileTrackStatus will fail. |
145 tile = TILE_MASK(tile + TileOffsByDir(direction)); |
145 tile = TILE_MASK(tile + TileOffsByDir(direction)); |
146 |
146 |
147 /* Check in case of rail if the owner is the same */ |
147 /* Check in case of rail if the owner is the same */ |
148 if (tpf->tracktype == TRANSPORT_RAIL) { |
148 if (tpf->tracktype == TRANSPORT_RAIL) { |
149 if ((IS_TILETYPE(tile, MP_RAILWAY) || IS_TILETYPE(tile, MP_STATION) || IS_TILETYPE(tile, MP_TUNNELBRIDGE))) |
149 if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE)) |
150 /* Check if we are on the middle of a bridge (has no owner) */ |
150 /* Check if we are on the middle of a bridge (has no owner) */ |
151 if (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0) |
151 if (!IsTileType(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0) |
152 if (owner != -1 && _map_owner[tile] != owner) |
152 if (owner != -1 && _map_owner[tile] != owner) |
153 return; |
153 return; |
154 } |
154 } |
155 |
155 |
156 if (++tpf->rd.cur_length > 50) |
156 if (++tpf->rd.cur_length > 50) |
229 x += _get_tunlen_inc[direction]; |
229 x += _get_tunlen_inc[direction]; |
230 y += _get_tunlen_inc[direction+1]; |
230 y += _get_tunlen_inc[direction+1]; |
231 |
231 |
232 tile = TILE_FROM_XY(x,y); |
232 tile = TILE_FROM_XY(x,y); |
233 |
233 |
234 if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && |
234 if (IsTileType(tile, MP_TUNNELBRIDGE) && |
235 (_map5[tile] & 0xF0) == 0 && // tunnel entrance/exit |
235 (_map5[tile] & 0xF0) == 0 && // tunnel entrance/exit |
236 //((_map5[tile]>>2)&3) == type && // rail/road-tunnel <-- This is not necesary to check, right? |
236 //((_map5[tile]>>2)&3) == type && // rail/road-tunnel <-- This is not necesary to check, right? |
237 ((_map5[tile] & 3)^2) == direction && // entrance towards: 0 = NE, 1 = SE, 2 = SW, 3 = NW |
237 ((_map5[tile] & 3)^2) == direction && // entrance towards: 0 = NE, 1 = SE, 2 = SW, 3 = NW |
238 GetSlopeZ(x+8, y+8) == z) |
238 GetSlopeZ(x+8, y+8) == z) |
239 break; |
239 break; |
279 uint bits; |
279 uint bits; |
280 int i; |
280 int i; |
281 RememberData rd; |
281 RememberData rd; |
282 uint tile_org = tile; |
282 uint tile_org = tile; |
283 |
283 |
284 if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0)==0) { |
284 if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0) == 0) { |
285 if ((_map5[tile] & 3) != direction || ((_map5[tile]>>2)&3) != tpf->tracktype) |
285 if ((_map5[tile] & 3) != direction || ((_map5[tile]>>2)&3) != tpf->tracktype) |
286 return; |
286 return; |
287 tile = SkipToEndOfTunnel(tpf, tile, direction); |
287 tile = SkipToEndOfTunnel(tpf, tile, direction); |
288 } |
288 } |
289 tile += TileOffsByDir(direction); |
289 tile += TileOffsByDir(direction); |
290 |
290 |
291 /* Check in case of rail if the owner is the same */ |
291 /* Check in case of rail if the owner is the same */ |
292 if (tpf->tracktype == TRANSPORT_RAIL) { |
292 if (tpf->tracktype == TRANSPORT_RAIL) { |
293 if ((IS_TILETYPE(tile_org, MP_RAILWAY) || IS_TILETYPE(tile_org, MP_STATION) || IS_TILETYPE(tile_org, MP_TUNNELBRIDGE))) |
293 if (IsTileType(tile_org, MP_RAILWAY) || IsTileType(tile_org, MP_STATION) || IsTileType(tile_org, MP_TUNNELBRIDGE)) |
294 if ((IS_TILETYPE(tile, MP_RAILWAY) || IS_TILETYPE(tile, MP_STATION) || IS_TILETYPE(tile, MP_TUNNELBRIDGE))) |
294 if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE)) |
295 /* Check if we are on a bridge (middle parts don't have an owner */ |
295 /* Check if we are on a bridge (middle parts don't have an owner */ |
296 if (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0) |
296 if (!IsTileType(tile, MP_TUNNELBRIDGE) || (_map5[tile] & 0xC0) != 0xC0) |
297 if (!IS_TILETYPE(tile_org, MP_TUNNELBRIDGE) || (_map5[tile_org] & 0xC0) != 0xC0) |
297 if (!IsTileType(tile_org, MP_TUNNELBRIDGE) || (_map5[tile_org] & 0xC0) != 0xC0) |
298 if (_map_owner[tile_org] != _map_owner[tile]) |
298 if (_map_owner[tile_org] != _map_owner[tile]) |
299 return; |
299 return; |
300 } |
300 } |
301 |
301 |
302 tpf->rd.cur_length++; |
302 tpf->rd.cur_length++; |
626 si.cur_length = 0; |
626 si.cur_length = 0; |
627 si.depth = 0; |
627 si.depth = 0; |
628 si.state = 0; |
628 si.state = 0; |
629 |
629 |
630 restart: |
630 restart: |
631 if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0)==0) { |
631 if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0) == 0) { |
632 /* This is a tunnel tile */ |
632 /* This is a tunnel tile */ |
633 if ( (uint)(_map5[tile] & 3) != (direction ^ 2)) { /* ^ 2 is reversing the direction */ |
633 if ( (uint)(_map5[tile] & 3) != (direction ^ 2)) { /* ^ 2 is reversing the direction */ |
634 /* We are not just driving out of the tunnel */ |
634 /* We are not just driving out of the tunnel */ |
635 if ( (uint)(_map5[tile] & 3) != direction || ((_map5[tile]>>1)&6) != tpf->tracktype) |
635 if ( (uint)(_map5[tile] & 3) != direction || ((_map5[tile]>>1)&6) != tpf->tracktype) |
636 /* We are not driving into the tunnel, or it |
636 /* We are not driving into the tunnel, or it |
651 // too long search length? bail out. |
651 // too long search length? bail out. |
652 if (++si.cur_length >= tpf->maxlength) |
652 if (++si.cur_length >= tpf->maxlength) |
653 goto popnext; |
653 goto popnext; |
654 |
654 |
655 // not a regular rail tile? |
655 // not a regular rail tile? |
656 if (!IS_TILETYPE(tile, MP_RAILWAY) || (bits = _map5[tile]) & 0xC0) { |
656 if (!IsTileType(tile, MP_RAILWAY) || (bits = _map5[tile]) & 0xC0) { |
657 bits = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _tpfmode1_and[direction]; |
657 bits = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _tpfmode1_and[direction]; |
658 bits = (bits | (bits >> 8)) & 0x3F; |
658 bits = (bits | (bits >> 8)) & 0x3F; |
659 break; |
659 break; |
660 } |
660 } |
661 |
661 |