diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 175c24c7a4..baca06595f 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -51,6 +51,21 @@ void Waypoint::GetTileArea(TileArea *ta, StationType type) const } } +/** + * Move the waypoint main coordinate somewhere else. + * @param new_xy new tile location of the sign + */ +void Waypoint::MoveSign(TileIndex new_xy) +{ + if (this->xy == new_xy) return; + + if (_viewport_sign_kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index, this->viewport_sign_kdtree_pt)); + + this->BaseStation::MoveSign(new_xy); + + if (_viewport_sign_kdtree_valid) _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeWaypoint(this->index)); +} + Waypoint::~Waypoint() { if (CleaningPool()) return; diff --git a/src/waypoint_base.h b/src/waypoint_base.h index c11c2f2b2f..be1d0bd0df 100644 --- a/src/waypoint_base.h +++ b/src/waypoint_base.h @@ -27,6 +27,8 @@ struct Waypoint FINAL : SpecializedStation { void UpdateVirtCoord() override; + void MoveSign(TileIndex new_xy) override; + inline bool TileBelongsToRailStation(TileIndex tile) const override { return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;