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

Function UpdateNearestTownForRoadTiles

src/road_cmd.cpp:1944–1958  ·  view source on GitHub ↗

* Updates cached nearest town for all road tiles * @param invalidate are we just invalidating cached data? * @pre invalidate == true implies _generating_world == true */

Source from the content-addressed store, hash-verified

1942 * @pre invalidate == true implies _generating_world == true
1943 */
1944void UpdateNearestTownForRoadTiles(bool invalidate)
1945{
1946 assert(!invalidate || _generating_world);
1947
1948 for (const auto t : Map::Iterate()) {
1949 if (IsTileType(t, MP_ROAD) && !IsRoadDepot(t) && !HasTownOwnedRoad(t)) {
1950 TownID tid = TownID::Invalid();
1951 if (!invalidate) {
1952 const Town *town = CalcClosestTownFromTile(t);
1953 if (town != nullptr) tid = town->index;
1954 }
1955 SetTownIndex(t, tid);
1956 }
1957 }
1958}
1959
1960static int GetSlopePixelZ_Road(TileIndex tile, uint x, uint y, bool)
1961{

Callers 4

OnQueryTextFinishedMethod · 0.85
PostDestructorMethod · 0.85
CmdFoundTownFunction · 0.85
AfterLoadGameFunction · 0.85

Calls 6

IsTileTypeFunction · 0.85
IsRoadDepotFunction · 0.85
HasTownOwnedRoadFunction · 0.85
InvalidFunction · 0.85
CalcClosestTownFromTileFunction · 0.85
SetTownIndexFunction · 0.85

Tested by

no test coverage detected