summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2019-03-23 11:17:27 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-05-11 14:58:00 +0200
commitc9fe6e7b8fde3a23f6aab3b55fd8cca639d49696 (patch)
treeda89620223aef75b521239c31c36ba9431da0f65 /src
parent0344e7a0a14e0e2661cc0fb4fca142720aabf2b5 (diff)
downloadopenttd-c9fe6e7b8fde3a23f6aab3b55fd8cca639d49696.tar.xz
Fix #7371: Avoid dependency on foundations of town tile during saveload
Diffstat (limited to 'src')
-rw-r--r--src/viewport.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 8a1319072..da1e01feb 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2183,7 +2183,9 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeTown(TownID id)
item.id.town = id;
const Town *town = Town::Get(id);
- Point pt = RemapCoords2(TileX(town->xy) * TILE_SIZE, TileY(town->xy) * TILE_SIZE);
+ /* Avoid using RemapCoords2, it has dependency on the foundations status of the tile, and that can be unavailable during saveload, leading to crashes.
+ * Instead "fake" foundations by taking the highest Z coordinate of any corner of the tile. */
+ Point pt = RemapCoords(TileX(town->xy) * TILE_SIZE, TileY(town->xy) * TILE_SIZE, GetTileMaxZ(town->xy) * TILE_HEIGHT);
pt.y -= 24 * ZOOM_LVL_BASE;