diff options
Diffstat (limited to 'src/town_cmd.cpp')
-rw-r--r-- | src/town_cmd.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 139e0217d..fbfd87492 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -394,12 +394,17 @@ static bool IsCloseToTown(TileIndex tile, uint dist) void Town::UpdateVirtCoord() { Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE); + + if (this->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(this->index)); + SetDParam(0, this->index); SetDParam(1, this->cache.population); this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE, _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN, STR_VIEWPORT_TOWN); + _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(this->index)); + SetWindowDirty(WC_TOWN_VIEW, this->index); } @@ -1782,7 +1787,6 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize t->townnameparts = townnameparts; t->UpdateVirtCoord(); - _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeTown(t->index)); InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 0); t->InitializeLayout(layout); @@ -2942,7 +2946,7 @@ CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 /* The town destructor will delete the other things related to the town. */ if (flags & DC_EXEC) { _town_kdtree.Remove(t->index); - _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(t->index)); + if (t->cache.sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeTown(t->index)); delete t; } |