--- a/src/build_vehicle_gui.cpp Sun Feb 03 01:34:21 2008 +0000
+++ b/src/build_vehicle_gui.cpp Sun Feb 03 20:34:26 2008 +0000
@@ -773,7 +773,8 @@
* 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
* when engines become obsolete and are removed */
- for (EngineID eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
+ EngineID eid;
+ FOR_ALL_ENGINEIDS_OF_TYPE(eid, VEH_TRAIN) {
const RailVehicleInfo *rvi = RailVehInfo(eid);
if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) continue;
@@ -811,7 +812,8 @@
EngList_RemoveAll(&bv->eng_list);
- for (EngineID eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
+ EngineID eid;
+ FOR_ALL_ENGINEIDS_OF_TYPE(eid, VEH_ROAD) {
if (!IsEngineBuildable(eid, VEH_ROAD, _local_player)) continue;
if (!HasBit(bv->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
EngList_Add(&bv->eng_list, eid);
@@ -829,7 +831,8 @@
EngList_RemoveAll(&bv->eng_list);
- for (EngineID eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
+ EngineID eid;
+ FOR_ALL_ENGINEIDS_OF_TYPE(eid, VEH_SHIP) {
if (!IsEngineBuildable(eid, VEH_SHIP, _local_player)) continue;
EngList_Add(&bv->eng_list, eid);
@@ -850,7 +853,8 @@
* 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 */
- for (EngineID eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
+ EngineID eid;
+ FOR_ALL_ENGINEIDS_OF_TYPE(eid, VEH_AIRCRAFT) {
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) 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 && !CanAircraftUseStation(eid, w->window_number)) continue;
@@ -954,23 +958,6 @@
}
}
-static void ExpandPurchaseInfoWidget(Window *w, int expand_by)
-{
- Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
-
- SetWindowDirty(w);
- wi->bottom += expand_by;
-
- for (uint i = BUILD_VEHICLE_WIDGET_BUILD; i < BUILD_VEHICLE_WIDGET_END; i++) {
- wi = &w->widget[i];
- wi->top += expand_by;
- wi->bottom += expand_by;
- }
-
- w->height += expand_by;
- SetWindowDirty(w);
-}
-
static void DrawBuildVehicleWindow(Window *w)
{
const buildvehicle_d *bv = &WP(w, buildvehicle_d);
@@ -992,7 +979,11 @@
const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
int text_end = DrawVehiclePurchaseInfo(2, wi->top + 1, wi->right - wi->left - 2, bv->sel_engine);
- if (text_end > wi->bottom) ExpandPurchaseInfoWidget(w, text_end - wi->bottom);
+ if (text_end > wi->bottom) {
+ SetWindowDirty(w);
+ ResizeWindowForWidget(w, BUILD_VEHICLE_WIDGET_PANEL, 0, text_end - wi->bottom);
+ SetWindowDirty(w);
+ }
}
DrawSortButtonState(w, BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING, bv->descending_sort_order ? SBS_DOWN : SBS_UP);