|
|
|
@ -32,17 +32,14 @@ uint _map_tile_mask; ///< _map_size - 1 (to mask the mapsize)
|
|
|
|
|
Tile *_m = NULL; ///< Tiles of the map
|
|
|
|
|
TileExtended *_me = NULL; ///< Extended Tiles of the map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* (Re)allocates a map with the given dimension
|
|
|
|
|
* Validates whether a map with the given dimension is valid
|
|
|
|
|
* @param size_x the width of the map along the NE/SW edge
|
|
|
|
|
* @param size_y the 'height' of the map along the SE/NW edge
|
|
|
|
|
* @return true if valid, or false if not valid
|
|
|
|
|
*/
|
|
|
|
|
void AllocateMap(uint size_x, uint size_y)
|
|
|
|
|
bool ValidateMapSize(uint size_x, uint size_y)
|
|
|
|
|
{
|
|
|
|
|
DEBUG(map, 2, "Min/max map size %d/%d, max map tiles %d", MIN_MAP_SIZE, MAX_MAP_SIZE, MAX_MAP_TILES);
|
|
|
|
|
DEBUG(map, 1, "Allocating map of size %dx%d", size_x, size_y);
|
|
|
|
|
|
|
|
|
|
/* Make sure that the map size is within the limits and that
|
|
|
|
|
* size of both axes is a power of 2. */
|
|
|
|
|
if (size_x * size_y > MAX_MAP_TILES ||
|
|
|
|
@ -50,6 +47,22 @@ void AllocateMap(uint size_x, uint size_y)
|
|
|
|
|
size_y < MIN_MAP_SIZE ||
|
|
|
|
|
(size_x & (size_x - 1)) != 0 ||
|
|
|
|
|
(size_y & (size_y - 1)) != 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* (Re)allocates a map with the given dimension
|
|
|
|
|
* @param size_x the width of the map along the NE/SW edge
|
|
|
|
|
* @param size_y the 'height' of the map along the SE/NW edge
|
|
|
|
|
*/
|
|
|
|
|
void AllocateMap(uint size_x, uint size_y)
|
|
|
|
|
{
|
|
|
|
|
DEBUG(map, 2, "Min/max map size %d/%d, max map tiles %d", MIN_MAP_SIZE, MAX_MAP_SIZE, MAX_MAP_TILES);
|
|
|
|
|
DEBUG(map, 1, "Allocating map of size %dx%d", size_x, size_y);
|
|
|
|
|
|
|
|
|
|
if (!ValidateMapSize(size_x, size_y)) {
|
|
|
|
|
error("Invalid map size");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|