2006-03-05 12:22:20 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "openttd.h"
|
2006-03-14 12:00:11 +00:00
|
|
|
#include "bridge_map.h"
|
2006-03-06 13:11:08 +00:00
|
|
|
#include "functions.h"
|
2006-03-05 12:22:20 +00:00
|
|
|
#include "road_map.h"
|
|
|
|
#include "station.h"
|
2006-03-06 20:55:24 +00:00
|
|
|
#include "tunnel_map.h"
|
2006-03-31 19:10:54 +00:00
|
|
|
#include "station_map.h"
|
2006-05-31 20:08:55 +00:00
|
|
|
#include "depot.h"
|
2006-03-05 12:22:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
RoadBits GetAnyRoadBits(TileIndex tile)
|
|
|
|
{
|
|
|
|
switch (GetTileType(tile)) {
|
|
|
|
case MP_STREET:
|
2006-05-09 08:25:31 +00:00
|
|
|
switch (GetRoadTileType(tile)) {
|
2006-03-05 12:22:20 +00:00
|
|
|
default:
|
2006-05-09 08:25:31 +00:00
|
|
|
case ROAD_TILE_NORMAL: return GetRoadBits(tile);
|
|
|
|
case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile);
|
|
|
|
case ROAD_TILE_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile));
|
2006-03-05 12:22:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case MP_STATION:
|
2006-03-31 19:10:54 +00:00
|
|
|
if (!IsRoadStopTile(tile)) return 0;
|
|
|
|
return DiagDirToRoadBits(GetRoadStopDir(tile));
|
2006-03-05 12:22:20 +00:00
|
|
|
|
|
|
|
case MP_TUNNELBRIDGE:
|
2006-06-07 19:35:21 +00:00
|
|
|
if (IsBridge(tile)) {
|
|
|
|
if (IsBridgeMiddle(tile)) {
|
|
|
|
if (!IsTransportUnderBridge(tile) ||
|
|
|
|
GetBridgeTransportType(tile) != TRANSPORT_ROAD) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return GetRoadBitsUnderBridge(tile);
|
|
|
|
} else {
|
|
|
|
// ending
|
|
|
|
if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return 0;
|
|
|
|
return DiagDirToRoadBits(ReverseDiagDir(GetBridgeRampDirection(tile)));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// tunnel
|
2006-03-06 20:55:24 +00:00
|
|
|
if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return 0;
|
|
|
|
return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile)));
|
2006-03-05 12:22:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
2006-03-06 13:11:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
TrackBits GetAnyRoadTrackBits(TileIndex tile)
|
|
|
|
{
|
2006-08-07 06:21:59 +00:00
|
|
|
uint32 r;
|
|
|
|
|
2006-09-17 16:23:30 +00:00
|
|
|
// Don't allow local authorities to build roads through road depots or road stops.
|
|
|
|
if ((IsTileType(tile, MP_STREET) && IsTileDepotType(tile, TRANSPORT_ROAD)) || IsTileType(tile, MP_STATION)) {
|
2006-08-07 06:21:59 +00:00
|
|
|
return 0;
|
2006-05-31 20:08:55 +00:00
|
|
|
}
|
2006-08-07 06:21:59 +00:00
|
|
|
|
|
|
|
r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
|
|
|
|
return (byte)(r | (r >> 8));
|
2006-03-06 13:11:08 +00:00
|
|
|
}
|