605 bv->filter.railtype = (w->window_number == 0) ? RAILTYPE_END : GetRailType(w->window_number); |
607 bv->filter.railtype = (w->window_number == 0) ? RAILTYPE_END : GetRailType(w->window_number); |
606 |
608 |
607 EngList_RemoveAll(&bv->eng_list); |
609 EngList_RemoveAll(&bv->eng_list); |
608 |
610 |
609 /* Make list of all available train engines and wagons. |
611 /* Make list of all available train engines and wagons. |
610 * Also check to see if the previously selected engine is still available, |
612 * Also check to see if the previously selected engine is still available, |
611 * and if not, reset selection to INVALID_ENGINE. This could be the case |
613 * and if not, reset selection to INVALID_ENGINE. This could be the case |
612 * when engines become obsolete and are removed */ |
614 * when engines become obsolete and are removed */ |
613 for (sel_id = INVALID_ENGINE, eid = 0; eid < NUM_TRAIN_ENGINES; eid++) { |
615 for (sel_id = INVALID_ENGINE, eid = 0; eid < NUM_TRAIN_ENGINES; eid++) { |
614 const RailVehicleInfo *rvi = RailVehInfo(eid); |
616 const RailVehicleInfo *rvi = RailVehInfo(eid); |
615 |
617 |
616 if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) continue; |
618 if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) continue; |
617 if (!IsEngineBuildable(eid, VEH_Train, _local_player)) continue; |
619 if (!IsEngineBuildable(eid, VEH_Train, _local_player)) continue; |
626 if (eid == bv->sel_engine) sel_id = eid; |
628 if (eid == bv->sel_engine) sel_id = eid; |
627 } |
629 } |
628 |
630 |
629 bv->sel_engine = sel_id; |
631 bv->sel_engine = sel_id; |
630 |
632 |
631 // make engines first, and then wagons, sorted by ListPositionOfEngine() |
633 /* make engines first, and then wagons, sorted by ListPositionOfEngine() */ |
632 _internal_sort_order = false; |
634 _internal_sort_order = false; |
633 EngList_Sort(&bv->eng_list, TrainEnginesThenWagonsSorter); |
635 EngList_Sort(&bv->eng_list, TrainEnginesThenWagonsSorter); |
634 |
636 |
635 // and then sort engines |
637 /* and then sort engines */ |
636 _internal_sort_order = bv->descending_sort_order; |
638 _internal_sort_order = bv->descending_sort_order; |
637 EngList_SortPartial(&bv->eng_list, _sorter[0][bv->sort_criteria], 0, num_engines); |
639 EngList_SortPartial(&bv->eng_list, _sorter[0][bv->sort_criteria], 0, num_engines); |
638 |
640 |
639 // and finally sort wagons |
641 /* and finally sort wagons */ |
640 EngList_SortPartial(&bv->eng_list, _sorter[0][bv->sort_criteria], num_engines, num_wagons); |
642 EngList_SortPartial(&bv->eng_list, _sorter[0][bv->sort_criteria], num_engines, num_wagons); |
641 } |
643 } |
642 |
644 |
643 /* Figure out what road vehicle EngineIDs to put in the list */ |
645 /* Figure out what road vehicle EngineIDs to put in the list */ |
644 static void GenerateBuildRoadVehList(Window *w) |
646 static void GenerateBuildRoadVehList(Window *w) |
692 * when planes become obsolete and are removed */ |
694 * when planes become obsolete and are removed */ |
693 sel_id = INVALID_ENGINE; |
695 sel_id = INVALID_ENGINE; |
694 for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { |
696 for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { |
695 if (IsEngineBuildable(eid, VEH_Aircraft, _local_player)) { |
697 if (IsEngineBuildable(eid, VEH_Aircraft, _local_player)) { |
696 const AircraftVehicleInfo *avi = AircraftVehInfo(eid); |
698 const AircraftVehicleInfo *avi = AircraftVehInfo(eid); |
697 switch (bv->filter.flags & ~AirportFTAClass::SHORT_STRIP /* we don't care about the length of the runway here */) { |
699 switch (bv->filter.flags & ~AirportFTAClass::SHORT_STRIP) { // we don't care about the length of the runway here |
698 case AirportFTAClass::HELICOPTERS: |
700 case AirportFTAClass::HELICOPTERS: |
699 if (avi->subtype != AIR_HELI) continue; |
701 if (avi->subtype != AIR_HELI) continue; |
700 break; |
702 break; |
701 |
703 |
702 case AirportFTAClass::AIRPLANES: |
704 case AirportFTAClass::AIRPLANES: |
932 DoCommandP(0, bv->rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(str)); |
934 DoCommandP(0, bv->rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(str)); |
933 } |
935 } |
934 break; |
936 break; |
935 } |
937 } |
936 |
938 |
937 case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
939 case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list |
938 if (bv->sort_criteria != e->we.dropdown.index) { |
940 if (bv->sort_criteria != e->we.dropdown.index) { |
939 bv->sort_criteria = e->we.dropdown.index; |
941 bv->sort_criteria = e->we.dropdown.index; |
940 _last_sort_criteria[bv->vehicle_type] = bv->sort_criteria; |
942 _last_sort_criteria[bv->vehicle_type] = bv->sort_criteria; |
941 bv->regenerate_list = true; |
943 bv->regenerate_list = true; |
942 } |
944 } |