diff --git a/rail_gui.c b/rail_gui.c index 313ea819a0..2f6136c01c 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -590,6 +590,7 @@ void ShowBuildRailToolbar(RailType railtype, int button) Window *w; if (_current_player == OWNER_SPECTATOR) return; + if (!ValParamRailtype(railtype)) return; // don't recreate the window if we're clicking on a button and the window exists. if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {