summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rail_gui.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 3977bfc63..783723863 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -851,13 +851,13 @@ static void SetupRailToolbar(RailType railtype, Window *w)
*/
void ShowBuildRailToolbar(RailType railtype, int button)
{
- BuildRailToolbarWindow *w;
-
if (!Company::IsValidID(_local_company)) return;
if (!ValParamRailtype(railtype)) return;
+ BuildRailToolbarWindow *w = (BuildRailToolbarWindow *)FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
+
/* don't recreate the window if we're clicking on a button and the window exists. */
- if (button < 0 || !(w = dynamic_cast<BuildRailToolbarWindow*>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL)))) {
+ if (button < 0 || w == NULL) {
DeleteWindowByClass(WC_BUILD_TOOLBAR);
_cur_railtype = railtype;
w = AllocateWindowDescFront<BuildRailToolbarWindow>(&_build_rail_desc, TRANSPORT_RAIL);