mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
Codechange: Use std::array for cached town zone radius.
This commit is contained in:
parent
d57bf84196
commit
fe7bd3a266
@ -42,7 +42,7 @@ struct TownCache {
|
||||
uint32_t population; ///< Current population of people
|
||||
TrackedViewportSign sign; ///< Location of name sign, UpdateVirtCoord updates this
|
||||
PartOfSubsidy part_of_subsidy; ///< Is this town a source/destination of a subsidy?
|
||||
uint32_t squared_town_zone_radius[HZB_END]; ///< UpdateTownRadius updates this given the house count
|
||||
std::array<uint32_t, HZB_END> squared_town_zone_radius; ///< UpdateTownRadius updates this given the house count
|
||||
BuildingCounts<uint16_t> building_counts; ///< The number of each type of building in the town
|
||||
};
|
||||
|
||||
|
@ -1902,7 +1902,7 @@ static bool GrowTown(Town *t)
|
||||
*/
|
||||
void UpdateTownRadius(Town *t)
|
||||
{
|
||||
static const uint32_t _town_squared_town_zone_radius_data[23][HZB_END] = {
|
||||
static const std::array<std::array<uint32_t, HZB_END>, 23> _town_squared_town_zone_radius_data = {{
|
||||
{ 4, 0, 0, 0, 0}, // 0
|
||||
{ 16, 0, 0, 0, 0},
|
||||
{ 25, 0, 0, 0, 0},
|
||||
@ -1926,10 +1926,10 @@ void UpdateTownRadius(Town *t)
|
||||
{121, 81, 0, 49, 25}, // 80
|
||||
{121, 81, 0, 49, 25},
|
||||
{121, 81, 0, 49, 36}, // 88
|
||||
};
|
||||
}};
|
||||
|
||||
if (t->cache.num_houses < 92) {
|
||||
memcpy(t->cache.squared_town_zone_radius, _town_squared_town_zone_radius_data[t->cache.num_houses / 4], sizeof(t->cache.squared_town_zone_radius));
|
||||
if (t->cache.num_houses < std::size(_town_squared_town_zone_radius_data) * 4) {
|
||||
t->cache.squared_town_zone_radius = _town_squared_town_zone_radius_data[t->cache.num_houses / 4];
|
||||
} else {
|
||||
int mass = t->cache.num_houses / 8;
|
||||
/* Actually we are proportional to sqrt() but that's right because we are covering an area.
|
||||
|
Loading…
Reference in New Issue
Block a user