MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetTownRadiusGroup

Function GetTownRadiusGroup

src/town_cmd.cpp:2516–2528  ·  view source on GitHub ↗

* Returns the bit corresponding to the town zone of the specified tile. * @param t Town on which town zone is to be found. * @param tile TileIndex where town zone needs to be found. * @return the bit position of the given zone, as defined in HouseZones. */

Source from the content-addressed store, hash-verified

2514 * @return the bit position of the given zone, as defined in HouseZones.
2515 */
2516HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
2517{
2518 uint dist = DistanceSquare(tile, t->xy);
2519
2520 if (t->fund_buildings_months != 0 && dist <= 25) return HouseZone::TownCentre;
2521
2522 HouseZone smallest = HouseZone::TownEdge;
2523 for (HouseZone i : HZ_ZONE_ALL) {
2524 if (dist < t->cache.squared_town_zone_radius[to_underlying(i)]) smallest = i;
2525 }
2526
2527 return smallest;
2528}
2529
2530/**
2531 * Clears tile and builds a house or house part.

Callers 11

GetVariableMethod · 0.85
GetVariableMethod · 0.85
GetVariableMethod · 0.85
GetVariableMethod · 0.85
GetVariableMethod · 0.85
TileLoop_StationFunction · 0.85
GetVariableMethod · 0.85
GetVariableMethod · 0.85
GetVariableMethod · 0.85
TryBuildTownHouseFunction · 0.85
TileLoop_RoadFunction · 0.85

Calls 2

DistanceSquareFunction · 0.85
to_underlyingFunction · 0.85

Tested by

no test coverage detected