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 dP
parent 8edc88b7fe
commit ede3e19eb4
8 changed files with 115 additions and 43 deletions
+13
View File
@@ -239,8 +239,11 @@ private:
static uint size; ///< The number of tiles on the map
static uint tile_mask; ///< _map_size - 1 (to mask the mapsize)
static uint initial_land_count; ///< Initial number of land tiles on the map.
public:
static void Allocate(uint size_x, uint size_y);
static void CountLandTiles();
/**
* Logarithm of the map size along the X side.
@@ -307,6 +310,16 @@ public:
return Map::SizeY() - 1;
}
/**
* Scales the given value by the number of water tiles.
* @param n the value to scale
* @return the scaled size
*/
static inline uint ScaleByLandProportion(uint n)
{
/* Use 64-bit arithmetic to avoid overflow. */
return static_cast<uint>(static_cast<uint64_t>(n) * Map::initial_land_count / Map::size);
}
/**
* 'Wraps' the given "tile" so it is within the map.