summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2011-01-09 15:21:55 +0000
committeralberth <alberth@openttd.org>2011-01-09 15:21:55 +0000
commit9845f106687fba49b31afa696f4f16c4ad044a93 (patch)
tree644834b5576d84d976ae4f8efa18262034cc0c46
parente898a6a9f6977d273a264d900e054c41834151bd (diff)
downloadopenttd-9845f106687fba49b31afa696f4f16c4ad044a93.tar.xz
(svn r21751) -Fix: Re-initialize the stationpicker data when newgrf classes have disappeared.
-rw-r--r--src/rail_gui.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 79ec40661..cb2ed5b20 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -980,17 +980,19 @@ public:
_railstation.newstations = newstation;
+ if (!newstation || _railstation.station_class >= (int)StationClass::GetCount()) {
+ /* New stations are not available or changed, so ensure the default station
+ * type is 'selected'. */
+ _railstation.station_class = STAT_CLASS_DFLT;
+ _railstation.station_type = 0;
+ }
if (newstation) {
_railstation.station_count = StationClass::GetCount(_railstation.station_class);
+ _railstation.station_type = min(_railstation.station_type, _railstation.station_count - 1);
this->vscroll->SetCount(_railstation.station_count);
this->vscroll->SetCapacity(GB(this->GetWidget<NWidgetCore>(BRSW_NEWST_LIST)->widget_data, MAT_ROW_START, MAT_ROW_BITS));
this->vscroll->SetPosition(Clamp(_railstation.station_type - 2, 0, max(this->vscroll->GetCount() - this->vscroll->GetCapacity(), 0)));
- } else {
- /* New stations are not available, so ensure the default station
- * type is 'selected'. */
- _railstation.station_class = STAT_CLASS_DFLT;
- _railstation.station_type = 0;
}
}