summaryrefslogtreecommitdiff
path: root/rail_gui.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-07 15:25:07 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-07 15:25:07 +0000
commit9dfc42bb8400511b44fad5f2bc69bd9b6ecf8c16 (patch)
treeab9a77da3d1cb041ce5c87b05df10b86117f2e2f /rail_gui.c
parentc4e4fa98fde0570e9f45050e286fca17de7113b6 (diff)
downloadopenttd-9dfc42bb8400511b44fad5f2bc69bd9b6ecf8c16.tar.xz
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
Diffstat (limited to 'rail_gui.c')
-rw-r--r--rail_gui.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/rail_gui.c b/rail_gui.c
index bf8fb3bcc..98a8e20f8 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -631,6 +631,30 @@ static void HandleStationPlacement(TileIndex start, TileIndex end)
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
}
+/* Check if the currently selected station size is allowed */
+static void CheckSelectedSize(Window *w, const StationSpec *statspec)
+{
+ if (statspec == NULL || _railstation.dragdrop) return;
+
+ if (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
+ RaiseWindowWidget(w, _railstation.numtracks + 4);
+ _railstation.numtracks = 1;
+ while (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
+ _railstation.numtracks++;
+ }
+ LowerWindowWidget(w, _railstation.numtracks + 4);
+ }
+
+ if (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
+ RaiseWindowWidget(w, _railstation.platlength + 11);
+ _railstation.platlength = 1;
+ while (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
+ _railstation.platlength++;
+ }
+ LowerWindowWidget(w, _railstation.platlength + 11);
+ }
+}
+
static void StationBuildWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
@@ -824,6 +848,9 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return;
_railstation.station_type = y;
+
+ CheckSelectedSize(w, statspec);
+
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;
@@ -837,6 +864,8 @@ static void StationBuildWndProc(Window *w, WindowEvent *e)
_railstation.station_type = 0;
_railstation.station_count = GetNumCustomStations(_railstation.station_class);
+ CheckSelectedSize(w, GetCustomStationSpec(_railstation.station_class, _railstation.station_type));
+
w->vscroll.count = _railstation.station_count;
w->vscroll.pos = _railstation.station_type;
}