Changeset - r7251:4216e7899b68
[Not reviewed]
master
0 1 0
truelight - 17 years ago 2007-07-13 19:06:12
truelight@openttd.org
(svn r10552) -Fix [FS#1034, r10546]: opening Available Aircrafts segfaulted
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -669,13 +669,13 @@ static void GenerateBuildTrainList(Windo
 
{
 
	EngineID eid, sel_id;
 
	int num_engines = 0;
 
	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);
 

	
 
	/* Make list of all available train engines and wagons.
 
	 * Also check to see if the previously selected engine is still available,
 
	 * and if not, reset selection to INVALID_ENGINE. This could be the case
 
@@ -761,13 +761,14 @@ static void GenerateBuildAircraftList(Wi
 
	 * Also check to see if the previously selected plane is still available,
 
	 * and if not, reset selection to INVALID_ENGINE. This could be the case
 
	 * when planes become obsolete and are removed */
 
	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;
 
	}
 

	
 
	bv->sel_engine = sel_id;
 
@@ -884,13 +885,13 @@ static void ExpandPurchaseInfoWidget(Win
 

	
 
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
 
	DrawWindowWidgets(w);
 

	
 
	DrawEngineList(bv->vehicle_type, 2, 27, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false, DEFAULT_GROUP);
0 comments (0 inline, 0 general)