Skip to content

Commit

Permalink
Fix #7371: Avoid dependency on foundations of town tile during saveload
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsmh committed Apr 1, 2019
1 parent 92d5835 commit 97e92ff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/viewport.cpp
Expand Up @@ -2119,7 +2119,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;

Expand Down

0 comments on commit 97e92ff

Please sign in to comment.