# HG changeset patch # User Rubidium # Date 2024-01-17 21:45:33 # Node ID 0cf4ddc7b995cee2c514255555f939a5917f8153 # Parent 34e4b1ae0c8a8f9ab1ee87f572d6547fc08cc9dd Fix #11801, 51f1e93: CalcClosestTownFromTile needs the kd-tree to be valid diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -499,7 +499,12 @@ static Town *RemapTown(TileIndex fallbac { /* 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; }