* (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 */ static */
| 35 | * @param size_y the 'height' of the map along the SE/NW edge |
| 36 | */ |
| 37 | /* static */ void Map::Allocate(uint size_x, uint size_y) |
| 38 | { |
| 39 | /* Make sure that the map size is within the limits and that |
| 40 | * size of both axes is a power of 2. */ |
| 41 | if (!IsInsideMM(size_x, MIN_MAP_SIZE, MAX_MAP_SIZE + 1) || |
| 42 | !IsInsideMM(size_y, MIN_MAP_SIZE, MAX_MAP_SIZE + 1) || |
| 43 | (size_x & (size_x - 1)) != 0 || |
| 44 | (size_y & (size_y - 1)) != 0) { |
| 45 | FatalError("Invalid map size"); |
| 46 | } |
| 47 | |
| 48 | Debug(map, 1, "Allocating map of size {}x{}", size_x, size_y); |
| 49 | |
| 50 | Map::log_x = FindFirstBit(size_x); |
| 51 | Map::log_y = FindFirstBit(size_y); |
| 52 | Map::size_x = size_x; |
| 53 | Map::size_y = size_y; |
| 54 | Map::size = size_x * size_y; |
| 55 | Map::tile_mask = Map::size - 1; |
| 56 | |
| 57 | Tile::base_tiles = std::make_unique<Tile::TileBase[]>(Map::size); |
| 58 | Tile::extended_tiles = std::make_unique<Tile::TileExtended[]>(Map::size); |
| 59 | |
| 60 | AllocateWaterRegions(); |
| 61 | } |
| 62 | |
| 63 | /* static */ void Map::CountLandTiles() |
| 64 | { |
no test coverage detected