105 { |
105 { |
106 return GetTileType(tile) == type; |
106 return GetTileType(tile) == type; |
107 } |
107 } |
108 |
108 |
109 /** |
109 /** |
|
110 * Checks if a tile is valid |
|
111 * |
|
112 * @param tile The tile to check |
|
113 * @return True if the tile is on the map and not one of MP_VOID. |
|
114 */ |
|
115 static inline bool IsValidTile(TileIndex tile) |
|
116 { |
|
117 return tile < MapSize() && !IsTileType(tile, MP_VOID); |
|
118 } |
|
119 |
|
120 /** |
110 * Returns the owner of a tile |
121 * Returns the owner of a tile |
111 * |
122 * |
112 * This function returns the owner of a tile. This cannot used |
123 * This function returns the owner of a tile. This cannot used |
113 * for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY |
124 * for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY |
114 * as no player owned any of these buildings. |
125 * as no player owned any of these buildings. |
115 * |
126 * |
116 * @param tile The tile to check |
127 * @param tile The tile to check |
117 * @return The owner of the tile |
128 * @return The owner of the tile |
118 * @pre tile < MapSize() |
129 * @pre IsValidTile(tile) |
119 * @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY |
130 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY |
120 */ |
131 */ |
121 static inline Owner GetTileOwner(TileIndex tile) |
132 static inline Owner GetTileOwner(TileIndex tile) |
122 { |
133 { |
123 assert(tile < MapSize()); |
134 assert(IsValidTile(tile)); |
124 assert(!IsTileType(tile, MP_HOUSE)); |
135 assert(!IsTileType(tile, MP_HOUSE)); |
125 assert(!IsTileType(tile, MP_VOID)); |
|
126 assert(!IsTileType(tile, MP_INDUSTRY)); |
136 assert(!IsTileType(tile, MP_INDUSTRY)); |
127 |
137 |
128 return (Owner)_m[tile].m1; |
138 return (Owner)_m[tile].m1; |
129 } |
139 } |
130 |
140 |
134 * This function sets the owner status of a tile. Note that you cannot |
144 * This function sets the owner status of a tile. Note that you cannot |
135 * set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY. |
145 * set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY. |
136 * |
146 * |
137 * @param tile The tile to change the owner status. |
147 * @param tile The tile to change the owner status. |
138 * @param owner The new owner. |
148 * @param owner The new owner. |
139 * @pre tile < MapSize() |
149 * @pre IsValidTile(tile) |
140 * @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY |
150 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY |
141 */ |
151 */ |
142 static inline void SetTileOwner(TileIndex tile, Owner owner) |
152 static inline void SetTileOwner(TileIndex tile, Owner owner) |
143 { |
153 { |
144 assert(tile < MapSize()); |
154 assert(IsValidTile(tile)); |
145 assert(!IsTileType(tile, MP_HOUSE)); |
155 assert(!IsTileType(tile, MP_HOUSE)); |
146 assert(!IsTileType(tile, MP_VOID)); |
|
147 assert(!IsTileType(tile, MP_INDUSTRY)); |
156 assert(!IsTileType(tile, MP_INDUSTRY)); |
148 |
157 |
149 _m[tile].m1 = owner; |
158 _m[tile].m1 = owner; |
150 } |
159 } |
151 |
160 |
163 |
172 |
164 /** |
173 /** |
165 * Set the tropic zone |
174 * Set the tropic zone |
166 * @param tile the tile to set the zone of |
175 * @param tile the tile to set the zone of |
167 * @param type the new type |
176 * @param type the new type |
168 * @pre assert(tile < MapSize()); |
177 * @pre tile < MapSize() |
169 */ |
178 */ |
170 static inline void SetTropicZone(TileIndex tile, TropicZone type) |
179 static inline void SetTropicZone(TileIndex tile, TropicZone type) |
171 { |
180 { |
172 assert(tile < MapSize()); |
181 assert(tile < MapSize()); |
173 SB(_m[tile].m6, 0, 2, type); |
182 SB(_m[tile].m6, 0, 2, type); |
174 } |
183 } |
175 |
184 |
176 /** |
185 /** |
177 * Get the tropic zone |
186 * Get the tropic zone |
178 * @param tile the tile to get the zone of |
187 * @param tile the tile to get the zone of |
179 * @pre assert(tile < MapSize()); |
188 * @pre tile < MapSize() |
180 * @return the zone type |
189 * @return the zone type |
181 */ |
190 */ |
182 static inline TropicZone GetTropicZone(TileIndex tile) |
191 static inline TropicZone GetTropicZone(TileIndex tile) |
183 { |
192 { |
184 assert(tile < MapSize()); |
193 assert(tile < MapSize()); |