tron@3146: /* $Id$ */ tron@3146: belugas@6393: /** @file road_map.cpp */ belugas@6393: tron@3146: #include "stdafx.h" tron@3146: #include "openttd.h" tron@3196: #include "bridge_map.h" rubidium@8119: #include "tile_cmd.h" tron@3146: #include "road_map.h" tron@3146: #include "station.h" tron@3154: #include "tunnel_map.h" celestar@3404: #include "station_map.h" KUDr@3927: #include "depot.h" smatz@8083: #include "tunnelbridge_map.h" tron@3146: tron@3146: rubidium@6661: RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt) tron@3146: { skidd13@7928: if (!HasBit(GetRoadTypes(tile), rt)) return ROAD_NONE; rubidium@6661: tron@3146: switch (GetTileType(tile)) { rubidium@7370: case MP_ROAD: rubidium@3793: switch (GetRoadTileType(tile)) { tron@3146: default: rubidium@6661: case ROAD_TILE_NORMAL: return GetRoadBits(tile, rt); rubidium@3793: case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile); rubidium@3793: case ROAD_TILE_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile)); tron@3146: } tron@3146: tron@3146: case MP_STATION: rubidium@5587: if (!IsRoadStopTile(tile)) return ROAD_NONE; rubidium@6012: if (IsDriveThroughStopTile(tile)) return (GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y; celestar@3404: return DiagDirToRoadBits(GetRoadStopDir(tile)); tron@3146: tron@3146: case MP_TUNNELBRIDGE: smatz@8088: if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE; smatz@8088: return DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile))); tron@3146: rubidium@5587: default: return ROAD_NONE; tron@3146: } tron@3146: } tron@3150: tron@3150: rubidium@6661: TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt) tron@3150: { peter1138@4233: uint32 r; peter1138@4233: rubidium@6418: /* Don't allow local authorities to build roads through road depots or road stops. */ skidd13@7928: if ((IsTileType(tile, MP_ROAD) && IsTileDepotType(tile, TRANSPORT_ROAD)) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasBit(GetRoadTypes(tile), rt)) { rubidium@5587: return TRACK_BIT_NONE; KUDr@3927: } peter1138@4233: rubidium@6683: r = GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)); rubidium@6661: rubidium@5587: return (TrackBits)(byte)(r | (r >> 8)); tron@3150: }