From f91462f54b3e660cb6bbd14453133f75b1569a8c Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 31 Oct 2023 01:29:16 +0000 Subject: [PATCH] Codechange: Don't access SmallMapWindow method directly from LinkGraphOverlay. --- src/linkgraph/linkgraph_gui.cpp | 2 +- src/smallmap_gui.cpp | 10 ++++++++++ src/smallmap_gui.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index e284a156be..18337ffa18 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -425,7 +425,7 @@ Point LinkGraphOverlay::GetStationMiddle(const Station *st) const return GetViewportStationMiddle(this->window->viewport, st); } else { /* assume this is a smallmap */ - return static_cast(this->window)->GetStationMiddle(st); + return GetSmallMapStationMiddle(this->window, st); } } diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 09f73b6d32..91f0ead98b 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1888,3 +1888,13 @@ bool ScrollMainWindowTo(int x, int y, int z, bool instant) return res; } + +/** + * Determine the middle of a station in the smallmap window. + * @param st The station we're looking for. + * @return Middle point of the station in the smallmap window. + */ +Point GetSmallMapStationMiddle(const Window *w, const Station *st) +{ + return static_cast(w)->GetStationMiddle(st); +} diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index 570a256f98..e051f788a8 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -212,4 +212,6 @@ public: void OnMouseOver([[maybe_unused]] Point pt, int widget) override; }; +Point GetSmallMapStationMiddle(const Window *w, const Station *st); + #endif /* SMALLMAP_GUI_H */