From a757ed52fde3f02a122cba3929ea43949f750ce8 Mon Sep 17 00:00:00 2001 From: truelight Date: Fri, 13 Jul 2007 19:06:12 +0000 Subject: (svn r10552) -Fix [FS#1034, r10546]: opening Available Aircrafts segfaulted --- src/build_vehicle_gui.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit v1.2.3-70-g09d2