mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-07 06:46:43 +00:00
(svn r11638) -Codechange: use faster check in SignalVehicleCheck for tunnel/bridge
This commit is contained in:
parent
4b22e57b33
commit
d0ad7688f2
@ -1917,42 +1917,14 @@ static void *SignalVehicleCheckProc(Vehicle *v, void *data)
|
|||||||
/* Special check for SetSignalsAfterProc, to see if there is a vehicle on this tile */
|
/* Special check for SetSignalsAfterProc, to see if there is a vehicle on this tile */
|
||||||
static bool SignalVehicleCheck(TileIndex tile, uint track)
|
static bool SignalVehicleCheck(TileIndex tile, uint track)
|
||||||
{
|
{
|
||||||
SignalVehicleCheckStruct dest;
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
|
/* Locate vehicles in tunnels or on bridges */
|
||||||
dest.tile = tile;
|
TileIndex endtile = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
|
||||||
dest.track = track;
|
return GetVehicleTunnelBridge(tile, endtile) != NULL;
|
||||||
|
} else {
|
||||||
/* Locate vehicles in tunnels or on bridges */
|
SignalVehicleCheckStruct dest = {tile, track};
|
||||||
if (IsTunnelTile(tile) || IsBridgeTile(tile)) {
|
return VehicleFromPos(tile, &dest, &SignalVehicleCheckProc) != NULL;
|
||||||
TileIndex end;
|
|
||||||
DiagDirection direction;
|
|
||||||
|
|
||||||
if (IsTunnelTile(tile)) {
|
|
||||||
end = GetOtherTunnelEnd(tile);
|
|
||||||
direction = GetTunnelDirection(tile);
|
|
||||||
} else {
|
|
||||||
end = GetOtherBridgeEnd(tile);
|
|
||||||
direction = GetBridgeRampDirection(tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
dest.track = 1 << (direction & 1); // get the trackbit the vehicle would have if it has not entered the tunnel yet (ie is still visible)
|
|
||||||
|
|
||||||
/* check for a vehicle with that trackdir on the start tile of the tunnel */
|
|
||||||
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
|
|
||||||
|
|
||||||
/* check for a vehicle with that trackdir on the end tile of the tunnel */
|
|
||||||
if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
|
|
||||||
|
|
||||||
/* now check all tiles from start to end for a warping vehicle */
|
|
||||||
dest.track = 0x40; //Vehicle inside a tunnel or on a bridge
|
|
||||||
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
|
|
||||||
if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
|
|
||||||
|
|
||||||
/* no vehicle found */
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetSignalsAfterProc(TrackPathFinder *tpf)
|
static void SetSignalsAfterProc(TrackPathFinder *tpf)
|
||||||
|
Loading…
Reference in New Issue
Block a user