Codechange: migrate size related functions to Map structure

This commit is contained in:
Rubidium
2023-01-21 10:43:03 +01:00
committed by rubidium42
parent d481f78b24
commit fe2bcd2a58
56 changed files with 334 additions and 343 deletions

View File

@@ -164,9 +164,9 @@ struct HeightMap
std::vector<height_t> h; //< array of heights
/* Even though the sizes are always positive, there are many cases where
* X and Y need to be signed integers due to subtractions. */
int dim_x; //< height map size_x MapSizeX() + 1
int size_x; //< MapSizeX()
int size_y; //< MapSizeY()
int dim_x; //< height map size_x Map::SizeX() + 1
int size_x; //< Map::SizeX()
int size_y; //< Map::SizeY()
/**
* Height map accessor
@@ -220,7 +220,7 @@ static height_t TGPGetMaxHeight()
/**
* Desired maximum height - indexed by:
* - _settings_game.difficulty.terrain_type
* - min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS
* - min(Map::LogX(), Map::LogY()) - MIN_MAP_SIZE_BITS
*
* It is indexed by map size as well as terrain type since the map size limits the height of
* a usable mountain. For example, on a 64x64 map a 24 high single peak mountain (as if you
@@ -236,7 +236,7 @@ static height_t TGPGetMaxHeight()
{ 12, 19, 25, 31, 67, 75, 87 }, ///< Alpinist
};
int map_size_bucket = std::min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS;
int map_size_bucket = std::min(Map::LogX(), Map::LogY()) - MIN_MAP_SIZE_BITS;
int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][map_size_bucket];
/* If there is a manual map height limit, clamp to it. */
@@ -322,8 +322,8 @@ static inline bool AllocHeightMap()
{
assert(_height_map.h.empty());
_height_map.size_x = MapSizeX();
_height_map.size_y = MapSizeY();
_height_map.size_x = Map::SizeX();
_height_map.size_y = Map::SizeY();
/* Allocate memory block for height map row pointers */
size_t total_size = static_cast<size_t>(_height_map.size_x + 1) * (_height_map.size_y + 1);
@@ -362,7 +362,7 @@ static void HeightMapGenerate()
/* Trying to apply noise to uninitialized height map */
assert(!_height_map.h.empty());
int start = std::max(MAX_TGP_FREQUENCIES - (int)std::min(MapLogX(), MapLogY()), 0);
int start = std::max(MAX_TGP_FREQUENCIES - (int)std::min(Map::LogX(), Map::LogY()), 0);
bool first = true;
for (int frequency = start; frequency < MAX_TGP_FREQUENCIES; frequency++) {
@@ -1004,8 +1004,8 @@ void GenerateTerrainPerlin()
/* First make sure the tiles at the north border are void tiles if needed. */
if (_settings_game.construction.freeform_edges) {
for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, 0));
for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(0, y));
for (uint x = 0; x < Map::SizeX(); x++) MakeVoid(TileXY(x, 0));
for (uint y = 0; y < Map::SizeY(); y++) MakeVoid(TileXY(0, y));
}
int max_height = H2I(TGPGetMaxHeight());