tron@3146: /* $Id$ */ tron@3146: tron@3146: #include "stdafx.h" tron@3146: #include "openttd.h" tron@3150: #include "functions.h" tron@3146: #include "road_map.h" tron@3146: #include "station.h" tron@3154: #include "tunnel_map.h" tron@3146: tron@3146: tron@3146: RoadBits GetAnyRoadBits(TileIndex tile) tron@3146: { tron@3146: switch (GetTileType(tile)) { tron@3146: case MP_STREET: tron@3146: switch (GetRoadType(tile)) { tron@3146: default: tron@3146: case ROAD_NORMAL: return GetRoadBits(tile); tron@3146: case ROAD_CROSSING: return GetCrossingRoadBits(tile); tron@3167: case ROAD_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile)); tron@3146: } tron@3146: tron@3146: case MP_STATION: tron@3146: if (!IsRoadStationTile(tile)) return 0; tron@3146: return DiagDirToRoadBits(GetRoadStationDir(tile)); tron@3146: tron@3146: case MP_TUNNELBRIDGE: tron@3146: if (_m[tile].m5 & 0x80) { tron@3146: // bridge tron@3146: if (_m[tile].m5 & 0x40) { tron@3146: // middle part tron@3146: if ((_m[tile].m5 & 0x38) != 0x28) return 0; // no road under bridge tron@3146: return _m[tile].m5 & 1 ? ROAD_X : ROAD_Y; tron@3146: } else { tron@3146: // ending tron@3146: if (GB(_m[tile].m5, 1, 2) != TRANSPORT_ROAD) return 0; // not a road bridge tron@3146: return _m[tile].m5 & 1 ? ROAD_Y : ROAD_X; tron@3146: } tron@3146: } else { tron@3146: // tunnel tron@3154: if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return 0; tron@3154: return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile))); tron@3146: } tron@3146: tron@3146: default: return 0; tron@3146: } tron@3146: } tron@3150: tron@3150: tron@3150: TrackBits GetAnyRoadTrackBits(TileIndex tile) tron@3150: { tron@3150: uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD); tron@3150: return (byte)(r | (r >> 8)); tron@3150: }