| Old revision #puhsjpjyc | New revision #p9hlizjtm | ||
|---|---|---|---|
| 2 | =================================================================== | 2 | =================================================================== |
| 3 | --- src/autoreplace_cmd.cpp (revision 27930) | 3 | --- src/autoreplace_cmd.cpp (revision 27930) |
| 4 | +++ src/autoreplace_cmd.cpp (working copy) | 4 | +++ src/autoreplace_cmd.cpp (working copy) |
| 5 | @@ -79,8 +79,12 @@ | 5 | @@ -78,11 +78,6 @@ |
| 6 | if (HasBit(e_from->info.misc_flags, EF_ROAD_TRAM) != HasBit(e_to->info.misc_flags, EF_ROAD_TRAM)) return false; | ||
| 6 | break; | 7 | break; |
| 7 | 8 | ||
| 8 | 8 | - case VEH_AIRCRAFT: | |
| 9 | - /* make sure that we do not replace a plane with a helicopter or vice versa */ | 10 | - /* make sure that we do not replace a plane with a helicopter or vice versa */ |
| 10 | - if ((e_from->u.air.subtype & AIR_CTOL) != (e_to->u.air.subtype & AIR_CTOL)) return false; | 11 | - if ((e_from->u.air.subtype & AIR_CTOL) != (e_to->u.air.subtype & AIR_CTOL)) return false; |
| 11 | + if (_settings_client.gui.autoreplace_match_aircraft_type) { | 11 | - break; |
| 12 | + /* make sure that we do not replace a mismatching aircraft type */ | 12 | - |
| 13 | + if ((e_from->u.air.subtype == AIR_CTOL) != (e_to->u.air.subtype == AIR_CTOL)) return false; | ||
| 14 | + if ((e_from->u.air.subtype == AIR_HELI) != (e_to->u.air.subtype == AIR_HELI)) return false; | ||
| 15 | + if ((e_from->u.air.subtype == (AIR_CTOL | AIR_FAST)) != (e_to->u.air.subtype == (AIR_CTOL | AIR_FAST))) return false; | ||
| 16 | + } | ||
| 17 | break; | ||
| 18 | |||
| 19 | default: break; | 14 | default: break; |
| 15 | } | ||
| 16 | |||
| 20 | Index: src/autoreplace_gui.cpp | 17 | Index: src/autoreplace_gui.cpp |
| 21 | =================================================================== | 18 | =================================================================== |
| 22 | --- src/autoreplace_gui.cpp (revision 27930) | 19 | --- src/autoreplace_gui.cpp (revision 27930) |
| 23 | +++ src/autoreplace_gui.cpp (working copy) | 20 | +++ src/autoreplace_gui.cpp (working copy) |
| 24 | @@ -229,6 +229,12 @@ | 21 | @@ -111,7 +111,27 @@ |
| 22 | return true; | ||
| 23 | } | ||
| 24 | |||
| 25 | + /** | ||
| 26 | + * Figure out if an aircraft should be added to the right list, regarding its type. | ||
| 27 | + * @param from The EngineID of the selected aircraft on the left list. | ||
| 28 | + * @param to The EngineID of the aircraft to be added to the right list. | ||
| 29 | + * @return \c true if the engine should be added to the right list, else \c false. | ||
| 30 | + */ | ||
| 31 | + bool GenerateReplaceAircraftList(EngineID from, EngineID to) | ||
| 32 | + { | ||
| 33 | + const Engine *e_from = Engine::Get(from); | ||
| 34 | + const Engine *e_to = Engine::Get(to); | ||
| 35 | |||
| 36 | + if (_settings_client.gui.autoreplace_match_aircraft_type) { | ||
| 37 | + /* make sure that we do not replace a mismatching aircraft type */ | ||
| 38 | + if ((e_from->u.air.subtype == AIR_CTOL) != (e_to->u.air.subtype == AIR_CTOL)) return false; | ||
| 39 | + if ((e_from->u.air.subtype == AIR_HELI) != (e_to->u.air.subtype == AIR_HELI)) return false; | ||
| 40 | + if ((e_from->u.air.subtype == (AIR_CTOL | AIR_FAST)) != (e_to->u.air.subtype == (AIR_CTOL | AIR_FAST))) return false; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + return true; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | /** | ||
| 47 | * Generate an engines list | ||
| 48 | * @param draw_left true if generating the left list, otherwise false | ||
| 49 | @@ -138,6 +158,7 @@ | ||
| 50 | if (num_engines == 0 && EngineReplacementForCompany(Company::Get(_local_company), eid, this->sel_group) == INVALID_ENGINE) continue; | ||
| 51 | } else { | ||
| 52 | if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue; | ||
| 53 | + if (type == VEH_AIRCRAFT && !this->GenerateReplaceAircraftList(this->sel_engine[0], eid)) continue; | ||
| 54 | } | ||
| 55 | |||
| 56 | *list->Append() = eid; | ||
| 57 | @@ -229,6 +250,12 @@ | ||
| 25 | widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype; | 58 | widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype; |
| 26 | widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype; | 59 | widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype; |
| 27 | widget->SetLowered(this->show_hidden_engines); | 60 | widget->SetLowered(this->show_hidden_engines); | … | … |
| 34 | this->FinishInitNested(vehicletype); | 67 | this->FinishInitNested(vehicletype); |
| 35 | 68 | ||
| 36 | this->sort_criteria = _engine_sort_last_criteria[vehicletype]; | 69 | this->sort_criteria = _engine_sort_last_criteria[vehicletype]; |
| 37 | @@ -475,6 + | 37 | @@ -475,6 +502,13 @@ |
| 38 | DoCommandP(0, GetCompanySettingIndex("company.renew_keep_length"), Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING); | 71 | DoCommandP(0, GetCompanySettingIndex("company.renew_keep_length"), Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING); |
| 39 | break; | 72 | break; |
| 40 | 73 | … | … |
| 48 | case WID_RV_START_REPLACE: { // Start replacing | 81 | case WID_RV_START_REPLACE: { // Start replacing |
| 49 | if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) { | 82 | if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) { |
| 50 | this->HandleButtonClick(WID_RV_START_REPLACE); | 83 | this->HandleButtonClick(WID_RV_START_REPLACE); |
| 51 | @@ -697,6 +7 | 51 | @@ -697,6 +731,60 @@ |
| 52 | _nested_replace_vehicle_widgets, lengthof(_nested_replace_vehicle_widgets) | 85 | _nested_replace_vehicle_widgets, lengthof(_nested_replace_vehicle_widgets) |
| 53 | ); | 86 | ); |
| 54 | 87 | … | … |
| 109 | /** | 142 | /** |
| 110 | * Show the autoreplace configuration window for a particular group. | 143 | * Show the autoreplace configuration window for a particular group. |
| 111 | * @param id_g The group to replace the vehicles for. | 144 | * @param id_g The group to replace the vehicles for. |
| 112 | @@ -705,5 +7 | 112 | @@ -705,5 +793,11 @@ |
| 113 | void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype) | 146 | void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype) |
| 114 | { | 147 | { |
| 115 | DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype); | 148 | DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype); |