rail_cmd.c
changeset 1818 56af6f0d6123
parent 1816 732d82acc97e
child 1891 862800791170
equal deleted inserted replaced
1817:5a284107f72b 1818:56af6f0d6123
  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)) {
  1643 				return true;
  1645 				return true;
  1644 		}
  1646 		}
  1645 
  1647 
  1646 		// no vehicle found
  1648 		// no vehicle found
  1647 		return false;
  1649 		return false;
  1648 	} else {
  1650 	}
  1649 		return VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL;
  1651 
  1650 	};
  1652 	return VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL;
  1651 }
  1653 }
  1652 
  1654 
  1653 static void SetSignalsAfterProc(TrackPathFinder *tpf)
  1655 static void SetSignalsAfterProc(TrackPathFinder *tpf)
  1654 {
  1656 {
  1655 	SetSignalsData *ssd = tpf->userdata;
  1657 	SetSignalsData *ssd = tpf->userdata;