Fix #11801, 51f1e93: CalcClosestTownFromTile needs the kd-tree to be valid

(cherry picked from commit 4cc97e04e6)
pull/642/head
Rubidium 5 months ago committed by Jonathan G Rennison
parent eb6c64cc04
commit 5c5057e0fc

@ -497,7 +497,12 @@ static Town *RemapTown(TileIndex fallback)
{
/* In some cases depots, industries and stations could refer to a missing town. */
Town *t = Town::GetIfValid(RemapTownIndex(_old_town_index));
if (t == nullptr) t = CalcClosestTownFromTile(fallback);
if (t == nullptr) {
/* In case the town that was refered to does not exist, find the closest.
* However, this needs the kd-tree to be present. */
RebuildTownKdtree();
t = CalcClosestTownFromTile(fallback);
}
return t;
}

Loading…
Cancel
Save