2006-03-05 12:22:20 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file road_map.cpp Complex road accessors. */
|
2007-03-28 20:41:35 +00:00
|
|
|
|
2006-03-05 12:22:20 +00:00
|
|
|
#include "stdafx.h"
|
2006-03-31 19:10:54 +00:00
|
|
|
#include "station_map.h"
|
2007-12-16 15:38:51 +00:00
|
|
|
#include "tunnelbridge_map.h"
|
2006-03-05 12:22:20 +00:00
|
|
|
|
|
|
|
|
2008-03-22 10:56:08 +00:00
|
|
|
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
|
2006-03-05 12:22:20 +00:00
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
if (!HasTileRoadType(tile, rt)) return ROAD_NONE;
|
2007-05-20 19:14:08 +00:00
|
|
|
|
2006-03-05 12:22:20 +00:00
|
|
|
switch (GetTileType(tile)) {
|
2007-07-29 23:42:59 +00:00
|
|
|
case MP_ROAD:
|
2006-05-09 08:25:31 +00:00
|
|
|
switch (GetRoadTileType(tile)) {
|
2006-03-05 12:22:20 +00:00
|
|
|
default:
|
2007-05-20 19:14:08 +00:00
|
|
|
case ROAD_TILE_NORMAL: return GetRoadBits(tile, rt);
|
2006-05-09 08:25:31 +00:00
|
|
|
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:
|
2007-01-10 18:56:51 +00:00
|
|
|
if (!IsRoadStopTile(tile)) return ROAD_NONE;
|
2007-02-14 16:37:16 +00:00
|
|
|
if (IsDriveThroughStopTile(tile)) return (GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y;
|
2006-03-31 19:10:54 +00:00
|
|
|
return DiagDirToRoadBits(GetRoadStopDir(tile));
|
2006-03-05 12:22:20 +00:00
|
|
|
|
|
|
|
case MP_TUNNELBRIDGE:
|
2007-12-16 19:30:42 +00:00
|
|
|
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
|
2008-03-22 10:56:08 +00:00
|
|
|
return straight_tunnel_bridge_entrance ?
|
|
|
|
AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) :
|
|
|
|
DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
|
2006-03-05 12:22:20 +00:00
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
default: return ROAD_NONE;
|
2006-03-05 12:22:20 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-06 13:11:08 +00:00
|
|
|
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
|
2006-03-06 13:11:08 +00:00
|
|
|
{
|
2007-04-03 21:51:40 +00:00
|
|
|
/* Don't allow local authorities to build roads through road depots or road stops. */
|
2008-02-14 15:59:16 +00:00
|
|
|
if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) {
|
2007-01-10 18:56:51 +00:00
|
|
|
return TRACK_BIT_NONE;
|
2006-05-31 20:08:55 +00:00
|
|
|
}
|
2006-08-07 06:21:59 +00:00
|
|
|
|
2008-02-20 17:49:50 +00:00
|
|
|
return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)));
|
2006-03-06 13:11:08 +00:00
|
|
|
}
|