diff --git a/src/citymania/cm_station_gui.cpp b/src/citymania/cm_station_gui.cpp index a2b3d6a056..c44c54e587 100644 --- a/src/citymania/cm_station_gui.cpp +++ b/src/citymania/cm_station_gui.cpp @@ -155,12 +155,29 @@ void OnStationTileSetChange(const Station *station, bool adding, StationType typ if (station == _viewport_highlight_station) MarkCoverageAreaDirty(_viewport_highlight_station); } +void OnStationDeleted(const Station *station) { + if (_highlight_station_to_join == station) { + MarkCoverageAreaDirty(station); + _highlight_station_to_join = nullptr; + } +} + const Station *_last_built_station; void OnStationPartBuilt(const Station *station) { _last_built_station = station; CheckRedrawStationCoverage(); } +void OnStationRemoved(const Station *station) { + if (_last_built_station == station) _last_built_station = nullptr; + if (_station_to_join == station) { + // TODO MarkJoinHighlight + MarkCoverageAreaDirty(station); + _station_to_join = nullptr; + } +} + + const Station *CheckClickOnDeadStationSign() { int x = _cursor.pos.x; int y = _cursor.pos.y; diff --git a/src/citymania/cm_station_gui.hpp b/src/citymania/cm_station_gui.hpp index ea60c45420..b1739e55f4 100644 --- a/src/citymania/cm_station_gui.hpp +++ b/src/citymania/cm_station_gui.hpp @@ -27,6 +27,7 @@ enum class StationBuildingStatus { bool UseImprovedStationJoin(); void OnStationTileSetChange(const Station *station, bool adding, StationType type); void OnStationPartBuilt(const Station *station); +void OnStationRemoved(const Station *station); void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg); void HandleStationPlacement(TileIndex start, TileIndex end); void PlaceRail_Station(TileIndex tile); diff --git a/src/station.cpp b/src/station.cpp index c75870bebe..ca38a5b7d5 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -30,6 +30,8 @@ #include "table/strings.h" +#include "citymania/cm_station_gui.hpp" + #include "safeguards.h" /** The pool of stations. */ @@ -87,6 +89,8 @@ Station::Station(TileIndex tile) : */ Station::~Station() { + citymania::OnStationRemoved(this); + for (Town *t : Town::Iterate()) { // Using poiter comparison instead of cycling cargos if (t->ad_ref_goods_entry >= this->goods &&