tron@10032: /* $Id$ */ tron@10032: tron@10032: #ifndef BRIDGE_MAP_H tron@10032: #define BRIDGE_MAP_H tron@10032: tron@10032: #include "direction.h" tron@10032: #include "macros.h" tron@10032: #include "map.h" tron@10032: #include "rail.h" tron@10032: #include "tile.h" tron@10032: tron@10032: tron@10032: static inline bool IsBridge(TileIndex t) tron@10032: { tron@10032: assert(IsTileType(t, MP_TUNNELBRIDGE)); tron@10032: return HASBIT(_m[t].m5, 7); tron@10032: } tron@10032: tron@10032: static inline bool IsBridgeTile(TileIndex t) tron@10032: { tron@10032: return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t); tron@10032: } tron@10032: tron@10032: tron@10032: static inline bool IsBridgeRamp(TileIndex t) tron@10032: { tron@10032: assert(IsBridgeTile(t)); tron@10032: return !HASBIT(_m[t].m5, 6); tron@10032: } tron@10032: tron@10032: static inline bool IsBridgeMiddle(TileIndex t) tron@10032: { tron@10032: assert(IsBridgeTile(t)); tron@10032: return HASBIT(_m[t].m5, 6); tron@10032: } tron@10032: tron@10032: tron@10032: /** tron@10032: * Get the direction pointing onto the bridge tron@10032: */ tron@10032: static inline DiagDirection GetBridgeRampDirection(TileIndex t) tron@10032: { tron@10032: assert(IsBridgeRamp(t)); tron@10032: /* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of tron@10032: * bridges to a DiagDirection tron@10032: */ tron@10032: return (DiagDirection)((6 - (_m[t].m5 >> 4 & 2) - (_m[t].m5 & 1)) % 4); tron@10032: } tron@10032: tron@10032: tron@10032: static inline Axis GetBridgeAxis(TileIndex t) tron@10032: { tron@10032: assert(IsBridgeMiddle(t)); tron@10032: return (Axis)GB(_m[t].m5, 0, 1); tron@10032: } tron@10032: tron@10032: tron@10032: static inline bool IsTransportUnderBridge(TileIndex t) tron@10032: { tron@10032: assert(IsBridgeMiddle(t)); tron@10032: return HASBIT(_m[t].m5, 5); tron@10032: } tron@10032: tron@10032: #endif