00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef BRIDGE_MAP_H
00013 #define BRIDGE_MAP_H
00014
00015 #include "road_map.h"
00016 #include "bridge.h"
00017
00024 static inline bool IsBridge(TileIndex t)
00025 {
00026 assert(IsTileType(t, MP_TUNNELBRIDGE));
00027 return HasBit(_m[t].m5, 7);
00028 }
00029
00035 static inline bool IsBridgeTile(TileIndex t)
00036 {
00037 return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
00038 }
00039
00046 static inline bool MayHaveBridgeAbove(TileIndex t)
00047 {
00048 return IsTileType(t, MP_CLEAR) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_ROAD) ||
00049 IsTileType(t, MP_WATER) || IsTileType(t, MP_TUNNELBRIDGE) || IsTileType(t, MP_OBJECT);
00050 }
00051
00058 static inline bool IsBridgeAbove(TileIndex t)
00059 {
00060 assert(MayHaveBridgeAbove(t));
00061 return GB(_m[t].m6, 6, 2) != 0;
00062 }
00063
00070 static inline BridgeType GetBridgeType(TileIndex t)
00071 {
00072 assert(IsBridgeTile(t));
00073 return GB(_m[t].m6, 2, 4);
00074 }
00075
00082 static inline Axis GetBridgeAxis(TileIndex t)
00083 {
00084 assert(IsBridgeAbove(t));
00085 return (Axis)(GB(_m[t].m6, 6, 2) - 1);
00086 }
00087
00092 TileIndex GetNorthernBridgeEnd(TileIndex t);
00093
00098 TileIndex GetSouthernBridgeEnd(TileIndex t);
00099
00100
00105 TileIndex GetOtherBridgeEnd(TileIndex t);
00106
00112 uint GetBridgeHeight(TileIndex tile);
00113
00120 static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
00121 {
00122 assert(MayHaveBridgeAbove(t));
00123 ClrBit(_m[t].m6, 6 + a);
00124 }
00125
00131 static inline void ClearBridgeMiddle(TileIndex t)
00132 {
00133 ClearSingleBridgeMiddle(t, AXIS_X);
00134 ClearSingleBridgeMiddle(t, AXIS_Y);
00135 }
00136
00143 static inline void SetBridgeMiddle(TileIndex t, Axis a)
00144 {
00145 assert(MayHaveBridgeAbove(t));
00146 SetBit(_m[t].m6, 6 + a);
00147 }
00148
00159 static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt, uint rt)
00160 {
00161 SetTileType(t, MP_TUNNELBRIDGE);
00162 SetTileOwner(t, o);
00163 _m[t].m2 = 0;
00164 _m[t].m3 = rt;
00165 _m[t].m4 = 0;
00166 _m[t].m5 = 1 << 7 | tt << 2 | d;
00167 SB(_m[t].m6, 2, 4, bridgetype);
00168 _me[t].m7 = 0;
00169 }
00170
00179 static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RoadTypes r)
00180 {
00181 MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, 0);
00182 SetRoadOwner(t, ROADTYPE_ROAD, o);
00183 if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o);
00184 SetRoadTypes(t, r);
00185 }
00186
00195 static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType r)
00196 {
00197 MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL, r);
00198 }
00199
00206 static inline void MakeAqueductBridgeRamp(TileIndex t, Owner o, DiagDirection d)
00207 {
00208 MakeBridgeRamp(t, o, 0, d, TRANSPORT_WATER, 0);
00209 }
00210
00211 #endif