summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-07-13 19:06:12 +0000
committertruelight <truelight@openttd.org>2007-07-13 19:06:12 +0000
commita757ed52fde3f02a122cba3929ea43949f750ce8 (patch)
treea497d69c10ce3d5a47f260ce2fe53a5946afe621
parent90a9c3acb8d69412c18ee80717d968298c591073 (diff)
downloadopenttd-a757ed52fde3f02a122cba3929ea43949f750ce8.tar.xz
(svn r10552) -Fix [FS#1034, r10546]: opening Available Aircrafts segfaulted
-rw-r--r--src/build_vehicle_gui.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 0c3c5d8a5..980de4c36 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -672,7 +672,7 @@ static void GenerateBuildTrainList(Window *w)
int num_wagons = 0;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
- bv->filter.railtype = (w->window_number == 0) ? RAILTYPE_END : GetRailType(w->window_number);
+ bv->filter.railtype = (w->window_number <= VEH_END) ? RAILTYPE_END : GetRailType(w->window_number);
EngList_RemoveAll(&bv->eng_list);
@@ -764,7 +764,8 @@ static void GenerateBuildAircraftList(Window *w)
sel_id = INVALID_ENGINE;
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
- if (w->window_number != 0 && !IsAircraftBuildableAtStation(eid, w->window_number)) continue;
+ /* First VEH_END window_numbers are fake to allow a window open for all different types at once */
+ if (w->window_number > VEH_END && !IsAircraftBuildableAtStation(eid, w->window_number)) continue;
EngList_Add(&bv->eng_list, eid);
if (eid == bv->sel_engine) sel_id = eid;
@@ -887,7 +888,7 @@ static void DrawBuildVehicleWindow(Window *w)
const buildvehicle_d *bv = &WP(w, buildvehicle_d);
uint max = min(w->vscroll.pos + w->vscroll.cap, EngList_Count(&bv->eng_list));
- SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number == 0);
+ SetWindowWidgetDisabledState(w, BUILD_VEHICLE_WIDGET_BUILD, w->window_number <= VEH_END);
SetVScrollCount(w, EngList_Count(&bv->eng_list));
SetDParam(0, bv->filter.railtype + STR_881C_NEW_RAIL_VEHICLES); // This should only affect rail vehicles