274 } |
274 } |
275 tile = SkipToEndOfTunnel(tpf, tile, direction); |
275 tile = SkipToEndOfTunnel(tpf, tile, direction); |
276 } |
276 } |
277 tile += TileOffsByDiagDir(direction); |
277 tile += TileOffsByDiagDir(direction); |
278 |
278 |
279 /* Check in case of rail if the owner is the same */ |
279 /* check if the new tile can be entered from that direction */ |
280 if (tpf->tracktype == TRANSPORT_RAIL) { |
280 /* Inside this block we should not use 'return' to indicate 'no way' condition (at least for rail transport type) */ |
281 // don't enter train depot from the back |
281 if (tpf->tracktype == TRANSPORT_ROAD || tpf->tracktype == TRANSPORT_RAIL) { |
282 if (IsTileDepotType(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) == direction) return; |
282 if (tpf->tracktype == TRANSPORT_RAIL) { |
283 |
283 /* don't enter train depot from the back */ |
284 if (IsTileType(tile_org, MP_RAILWAY) || IsTileType(tile_org, MP_STATION) || IsTileType(tile_org, MP_TUNNELBRIDGE)) |
284 if (IsTileDepotType(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) == direction) goto no_way; |
285 if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE)) |
285 |
286 /* Check if we are on a bridge (middle parts don't have an owner */ |
286 /* Check in case of rail if the owner is the same */ |
287 if (!IsBridgeTile(tile) || !IsBridgeMiddle(tile)) |
287 if (IsTileType(tile_org, MP_RAILWAY) || IsTileType(tile_org, MP_STATION) || IsTileType(tile_org, MP_TUNNELBRIDGE)) |
288 if (!IsBridgeTile(tile_org) || !IsBridgeMiddle(tile_org)) |
288 if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION) || IsTileType(tile, MP_TUNNELBRIDGE)) |
289 if (GetTileOwner(tile_org) != GetTileOwner(tile)) |
289 /* Check if we are on a bridge (middle parts don't have an owner */ |
290 return; |
290 if (!IsBridgeTile(tile) || !IsBridgeMiddle(tile)) |
291 } |
291 if (!IsBridgeTile(tile_org) || !IsBridgeMiddle(tile_org)) |
292 |
292 if (GetTileOwner(tile_org) != GetTileOwner(tile)) goto no_way; |
293 // check if the new tile can be entered from that direction |
293 |
294 if (tpf->tracktype == TRANSPORT_ROAD) { |
294 } else if (tpf->tracktype == TRANSPORT_ROAD) { |
295 // road stops and depots now have a track (r4419) |
295 /* road stops and depots now have a track (r4419) */ |
296 // don't enter road stop from the back |
296 /* don't enter road stop from the back */ |
297 if (IsRoadStopTile(tile) && ReverseDiagDir(GetRoadStopDir(tile)) != direction) return; |
297 if (IsRoadStopTile(tile) && ReverseDiagDir(GetRoadStopDir(tile)) != direction) goto no_way; |
298 // don't enter road depot from the back |
298 /* don't enter road depot from the back */ |
299 if (IsTileDepotType(tile, TRANSPORT_ROAD) && ReverseDiagDir(GetRoadDepotDirection(tile)) != direction) return; |
299 if (IsTileDepotType(tile, TRANSPORT_ROAD) && ReverseDiagDir(GetRoadDepotDirection(tile)) != direction) goto no_way; |
300 } |
300 } |
|
301 |
|
302 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
|
303 if (IsTunnel(tile)) { |
|
304 /* tunnel hole can be entered only from one direction */ |
|
305 if (GetTunnelDirection(tile) != direction) goto no_way; |
|
306 } |
|
307 } |
|
308 if (tpf->tracktype == TRANSPORT_RAIL) { |
|
309 /* check for the rail type compatibility */ |
|
310 Trackdir td = DiagdirToDiagTrackdir(direction); |
|
311 RailType type_org = GetTileRailType(tile_org, td); |
|
312 RailType type = GetTileRailType(tile, td); |
|
313 if (type != type_org) { |
|
314 // they can be compatible only if one is normal and the other one is elrail |
|
315 if (type_org == RAILTYPE_RAIL && type != RAILTYPE_ELECTRIC) goto no_way; |
|
316 if (type == RAILTYPE_RAIL && type_org != RAILTYPE_ELECTRIC) goto no_way; |
|
317 } |
|
318 } |
|
319 } |
|
320 |
|
321 /* the next line is skipped when the new tile can't be entered from tile_org */ |
|
322 bits = GetTileTrackStatus(tile, tpf->tracktype); |
|
323 no_way: |
301 |
324 |
302 tpf->rd.cur_length++; |
325 tpf->rd.cur_length++; |
303 |
|
304 bits = GetTileTrackStatus(tile, tpf->tracktype); |
|
305 |
326 |
306 if ((byte)bits != tpf->var2) { |
327 if ((byte)bits != tpf->var2) { |
307 bits &= _tpfmode1_and[direction]; |
328 bits &= _tpfmode1_and[direction]; |
308 bits = bits | (bits>>8); |
329 bits = bits | (bits>>8); |
309 } |
330 } |