29 { |
29 { |
30 assert(IsTileType(t, MP_WATER)); |
30 assert(IsTileType(t, MP_WATER)); |
31 |
31 |
32 if (_m[t].m5 == 0) return WATER_TILE_CLEAR; |
32 if (_m[t].m5 == 0) return WATER_TILE_CLEAR; |
33 if (_m[t].m5 == 1) return WATER_TILE_COAST; |
33 if (_m[t].m5 == 1) return WATER_TILE_COAST; |
34 if (IS_INT_INSIDE(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK; |
34 if (IsInsideMM(_m[t].m5, LOCK_MIDDLE, LOCK_END)) return WATER_TILE_LOCK; |
35 |
35 |
36 assert(IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END)); |
36 assert(IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END)); |
37 return WATER_TILE_DEPOT; |
37 return WATER_TILE_DEPOT; |
38 } |
38 } |
39 |
39 |
40 /** IsWater return true if any type of clear water like ocean, river, canal */ |
40 /** IsWater return true if any type of clear water like ocean, river, canal */ |
41 static inline bool IsWater(TileIndex t) |
41 static inline bool IsWater(TileIndex t) |
70 return t + (HasBit(_m[t].m5, 0) ? -1 : 1) * (HasBit(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); |
70 return t + (HasBit(_m[t].m5, 0) ? -1 : 1) * (HasBit(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); |
71 } |
71 } |
72 |
72 |
73 static inline TileIndex IsShipDepot(TileIndex t) |
73 static inline TileIndex IsShipDepot(TileIndex t) |
74 { |
74 { |
75 return IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END); |
75 return IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END); |
76 } |
76 } |
77 |
77 |
78 static inline Axis GetShipDepotAxis(TileIndex t) |
78 static inline Axis GetShipDepotAxis(TileIndex t) |
79 { |
79 { |
80 return (Axis)GB(_m[t].m5, 1, 1); |
80 return (Axis)GB(_m[t].m5, 1, 1); |
81 } |
81 } |
82 |
82 |
83 static inline DiagDirection GetShipDepotDirection(TileIndex t) |
83 static inline DiagDirection GetShipDepotDirection(TileIndex t) |
84 { |
84 { |
85 return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1)); |
85 return XYNSToDiagDir(GetShipDepotAxis(t), GB(_m[t].m5, 0, 1)); |
|
86 } |
|
87 |
|
88 static inline Owner GetShipDepotWaterOwner(TileIndex t) |
|
89 { |
|
90 return (Owner)_m[t].m4; |
86 } |
91 } |
87 |
92 |
88 static inline DiagDirection GetLockDirection(TileIndex t) |
93 static inline DiagDirection GetLockDirection(TileIndex t) |
89 { |
94 { |
90 return (DiagDirection)GB(_m[t].m5, 0, 2); |
95 return (DiagDirection)GB(_m[t].m5, 0, 2); |
126 _m[t].m3 = 0; |
131 _m[t].m3 = 0; |
127 _m[t].m4 = 0; |
132 _m[t].m4 = 0; |
128 _m[t].m5 = 0; |
133 _m[t].m5 = 0; |
129 } |
134 } |
130 |
135 |
131 static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a) |
136 static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, Owner original_owner) |
132 { |
137 { |
133 SetTileType(t, MP_WATER); |
138 SetTileType(t, MP_WATER); |
134 SetTileOwner(t, o); |
139 SetTileOwner(t, o); |
135 _m[t].m2 = 0; |
140 _m[t].m2 = 0; |
136 _m[t].m3 = 0; |
141 _m[t].m3 = 0; |
137 _m[t].m4 = 0; |
142 _m[t].m4 = original_owner; |
138 _m[t].m5 = base + a * 2; |
143 _m[t].m5 = base + a * 2; |
139 } |
144 } |
140 |
145 |
141 static inline void MakeLockTile(TileIndex t, Owner o, byte section) |
146 static inline void MakeLockTile(TileIndex t, Owner o, byte section) |
142 { |
147 { |