mirror of https://github.com/OpenTTD/OpenTTD
(svn r5199) Make the control flow of GetTileTrackStatus_TunnelBridge() more comprehensible
parent
c1bcead499
commit
901e2d02b1
|
@ -1241,41 +1241,26 @@ static void ClickTile_TunnelBridge(TileIndex tile)
|
||||||
|
|
||||||
static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode)
|
static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode)
|
||||||
{
|
{
|
||||||
uint32 result;
|
|
||||||
|
|
||||||
if (IsTunnel(tile)) {
|
if (IsTunnel(tile)) {
|
||||||
if (GetTunnelTransportType(tile) == mode) {
|
if (GetTunnelTransportType(tile) != mode) return 0;
|
||||||
return DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? 0x101 : 0x202;
|
return (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
||||||
}
|
} else {
|
||||||
} else if (IsBridge(tile)) { // XXX is this necessary?
|
|
||||||
if (IsBridgeRamp(tile)) {
|
if (IsBridgeRamp(tile)) {
|
||||||
if (GetBridgeTransportType(tile) != mode) return 0;
|
if (GetBridgeTransportType(tile) != mode) return 0;
|
||||||
return (DiagDirToAxis(GetBridgeRampDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
return (DiagDirToAxis(GetBridgeRampDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
||||||
} else {
|
} else {
|
||||||
result = 0;
|
uint32 result = 0;
|
||||||
|
|
||||||
if (GetBridgeTransportType(tile) == mode) {
|
if (GetBridgeTransportType(tile) == mode) {
|
||||||
result = (GetBridgeAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
result = (GetBridgeAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
||||||
}
|
}
|
||||||
if (IsTransportUnderBridge(tile)) {
|
if ((IsTransportUnderBridge(tile) && mode == GetTransportTypeUnderBridge(tile)) ||
|
||||||
if (GetTransportTypeUnderBridge(tile) != mode) return result;
|
(IsWaterUnderBridge(tile) && mode == TRANSPORT_WATER)) {
|
||||||
} else {
|
result |= (GetBridgeAxis(tile) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X) * 0x101;
|
||||||
if (IsClearUnderBridge(tile)) {
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
if (mode != TRANSPORT_WATER) return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* If we've not returned yet, there is a compatible
|
return result;
|
||||||
* transport or water beneath, so we can add it to
|
|
||||||
* result */
|
|
||||||
/* Why is this xor'd ? Can't it just be or'd? */
|
|
||||||
result ^= (GetBridgeAxis(tile) == AXIS_X ? 0x202 : 0x101);
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
assert(0); /* This should never occur */
|
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
|
static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
|
||||||
|
|
Loading…
Reference in New Issue