1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-17 09:22:42 +01:00

Change: Scale towns/industries by amount of land tiles. (#10063)

This commit is contained in:
Peter Nelson
2025-10-24 21:32:09 +01:00
committed by GitHub
parent 70bf84175f
commit a1920fc225
8 changed files with 115 additions and 43 deletions

View File

@@ -23,6 +23,8 @@
/* static */ uint Map::size; ///< The number of tiles on the map
/* static */ uint Map::tile_mask; ///< _map_size - 1 (to mask the mapsize)
/* static */ uint Map::initial_land_count; ///< Initial number of land tiles on the map.
/* static */ std::unique_ptr<Tile::TileBase[]> Tile::base_tiles; ///< Base tiles of the map
/* static */ std::unique_ptr<Tile::TileExtended[]> Tile::extended_tiles; ///< Extended tiles of the map
@@ -58,6 +60,20 @@
AllocateWaterRegions();
}
/* static */ void Map::CountLandTiles()
{
/* Count number of tiles that are land. */
Map::initial_land_count = 0;
for (const auto tile : Map::Iterate()) {
Map::initial_land_count += IsWaterTile(tile) ? 0 : 1;
}
/* Compensate for default values being set for (or users are most familiar with) at least
* very low sea level. Dividing by 12 adds roughly 8%. */
Map::initial_land_count += Map::initial_land_count / 12;
Map::initial_land_count = std::min(Map::initial_land_count, Map::size);
}
#ifdef _DEBUG
TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)