1617 SignalVehicleCheckStruct dest; |
1617 SignalVehicleCheckStruct dest; |
1618 |
1618 |
1619 dest.tile = tile; |
1619 dest.tile = tile; |
1620 dest.track = track; |
1620 dest.track = track; |
1621 |
1621 |
|
1622 /** @todo "Hackish" fix for the tunnel problems. This is needed because a tunnel |
|
1623 * is some kind of invisible black hole, and there is some special magic going |
|
1624 * on in there. This 'workaround' can be removed once the maprewrite is done. |
|
1625 */ |
1622 if (GetTileType(tile)==MP_TUNNELBRIDGE && ((_map5[tile] & 0xF0)==0)) { |
1626 if (GetTileType(tile)==MP_TUNNELBRIDGE && ((_map5[tile] & 0xF0)==0)) { |
1623 // It is a tunnel we're checking, we need to do some special stuff |
1627 // It is a tunnel we're checking, we need to do some special stuff |
1624 // because VehicleFromPos will not find the vihicle otherwise |
1628 // because VehicleFromPos will not find the vihicle otherwise |
1625 byte direction = _map5[tile] & 3; |
1629 byte direction = _map5[tile] & 3; |
1626 FindLengthOfTunnelResult flotr; |
1630 FindLengthOfTunnelResult flotr; |
1627 flotr = FindLengthOfTunnel(tile, direction); |
1631 flotr = FindLengthOfTunnel(tile, direction); |
1628 dest.track = 1 << (direction & 1); // get the trackbit the vehicle would have if it has not entered the tunnel yet (ie is still visible) |
1632 dest.track = 1 << (direction & 1); // get the trackbit the vehicle would have if it has not entered the tunnel yet (ie is still visible) |
1629 |
1633 |
1630 // check for a vehicle with that trackdir on the start tile of the tunnel |
1634 // check for a vehicle with that trackdir on the start tile of the tunnel |
1631 if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) |
1635 if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true; |
1632 return true; |
|
1633 |
1636 |
1634 // check for a vehicle with that trackdir on the end tile of the tunnel |
1637 // check for a vehicle with that trackdir on the end tile of the tunnel |
1635 if (VehicleFromPos(flotr.tile, &dest, SignalVehicleCheckProc) != NULL) |
1638 if (VehicleFromPos(flotr.tile, &dest, SignalVehicleCheckProc) != NULL) return true; |
1636 return true; |
|
1637 |
1639 |
1638 // now check all tiles from start to end for a "hidden" vehicle |
1640 // now check all tiles from start to end for a "hidden" vehicle |
1639 // NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile? |
1641 // NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile? |
1640 dest.track = 0x40; // trackbit for vehicles "hidden" inside a tunnel |
1642 dest.track = 0x40; // trackbit for vehicles "hidden" inside a tunnel |
1641 for (; tile != flotr.tile; tile += TileOffsByDir(direction)) { |
1643 for (; tile != flotr.tile; tile += TileOffsByDir(direction)) { |