From 7bd9fbc733dd57d138bd8c0944954f83c22e2ffb Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 20 Jun 2026 22:14:05 +0200 Subject: [PATCH] Codechange: make VehicleListType scoped --- src/autoreplace_cmd.cpp | 2 +- src/depot.cpp | 2 +- src/depot_cmd.cpp | 2 +- src/depot_gui.cpp | 4 ++-- src/group_cmd.cpp | 14 +++++++------- src/group_gui.cpp | 4 ++-- src/station.cpp | 8 ++++---- src/station_gui.cpp | 8 ++++---- src/vehicle.cpp | 2 +- src/vehicle_gui.cpp | 34 +++++++++++++++++----------------- src/vehiclelist.cpp | 22 +++++++++++----------- src/vehiclelist.h | 26 +++++++++++++------------- src/waypoint_gui.cpp | 2 +- 13 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 23108a6c5b..b3596b04be 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -856,7 +856,7 @@ CommandCost CmdSetAutoReplace(DoCommandFlags flags, GroupID id_g, EngineID old_e if (IsLocalCompany()) SetWindowDirty(WindowClass::ReplaceVehicle, Engine::Get(old_engine_type)->type); const VehicleType vt = Engine::Get(old_engine_type)->type; - SetWindowDirty(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, _current_company).ToWindowNumber()); + SetWindowDirty(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VehicleListType::Group, vt, _current_company).ToWindowNumber()); } if (flags.Test(DoCommandFlag::Execute) && IsLocalCompany()) InvalidateAutoreplaceWindow(old_engine_type, id_g); diff --git a/src/depot.cpp b/src/depot.cpp index cba5745304..3f790850d0 100644 --- a/src/depot.cpp +++ b/src/depot.cpp @@ -45,5 +45,5 @@ Depot::~Depot() /* Delete the depot list */ VehicleType vt = GetDepotVehicleType(this->xy); - CloseWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(this->xy), this->index).ToWindowNumber()); + CloseWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VehicleListType::Depot, vt, GetTileOwner(this->xy), this->index).ToWindowNumber()); } diff --git a/src/depot_cmd.cpp b/src/depot_cmd.cpp index 2eb8c77d8e..9d2e722cf1 100644 --- a/src/depot_cmd.cpp +++ b/src/depot_cmd.cpp @@ -72,7 +72,7 @@ CommandCost CmdRenameDepot(DoCommandFlags flags, DepotID depot_id, const std::st /* Update the depot list */ VehicleType vt = GetDepotVehicleType(d->xy); - SetWindowDirty(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_DEPOT_LIST, vt, GetTileOwner(d->xy), d->index).ToWindowNumber()); + SetWindowDirty(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VehicleListType::Depot, vt, GetTileOwner(d->xy), d->index).ToWindowNumber()); } return CommandCost(); } diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 3e2f331b07..79e18c12f2 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -302,7 +302,7 @@ struct DepotWindow : Window { void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WindowClass::BuildVehicle, this->window_number); - CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDestinationIndex()).ToWindowNumber(), false); + CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VehicleListType::Depot, this->type, this->owner, this->GetDestinationIndex()).ToWindowNumber(), false); OrderBackup::Reset(TileIndex(this->window_number)); this->Window::Close(); } @@ -840,7 +840,7 @@ struct DepotWindow : Window { case WID_D_STOP_ALL: case WID_D_START_ALL: { - VehicleListIdentifier vli(VL_DEPOT_LIST, this->type, this->owner); + VehicleListIdentifier vli(VehicleListType::Depot, this->type, this->owner); Command::Post(TileIndex(this->window_number), widget == WID_D_START_ALL, false, vli); break; } diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 919061a344..6d905e27a6 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -376,7 +376,7 @@ std::tuple CmdCreateGroup(DoCommandFlags flags, VehicleTyp pg->children.insert(g->index); } - InvalidateWindowData(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, _current_company).ToWindowNumber()); + InvalidateWindowData(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VehicleListType::Group, vt, _current_company).ToWindowNumber()); InvalidateWindowData(WindowClass::CompanyLivery, g->owner, g->vehicle_type); return { CommandCost(), g->index }; @@ -432,7 +432,7 @@ CommandCost CmdDeleteGroup(DoCommandFlags flags, GroupID group_id) CloseWindowById(WindowClass::ReplaceVehicle, g->vehicle_type); delete g; - InvalidateWindowData(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, _current_company).ToWindowNumber()); + InvalidateWindowData(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VehicleListType::Group, vt, _current_company).ToWindowNumber()); InvalidateWindowData(WindowClass::CompanyLivery, _current_company, vt); } @@ -508,7 +508,7 @@ CommandCost CmdAlterGroup(DoCommandFlags flags, AlterGroupMode mode, GroupID gro if (flags.Test(DoCommandFlag::Execute)) { InvalidateWindowData(WindowClass::ReplaceVehicle, g->vehicle_type, 1); - InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).ToWindowNumber()); + InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VehicleListType::Group, g->vehicle_type, _current_company).ToWindowNumber()); InvalidateWindowData(WindowClass::CompanyLivery, g->owner, g->vehicle_type); InvalidateWindowClassesData(WindowClass::VehicleView); InvalidateWindowClassesData(WindowClass::VehicleDetails); @@ -613,7 +613,7 @@ std::tuple CmdAddVehicleGroup(DoCommandFlags flags, GroupI /* Update the Replace Vehicle Windows */ SetWindowDirty(WindowClass::ReplaceVehicle, vtype); - InvalidateWindowData(GetWindowClassForVehicleType(vtype), VehicleListIdentifier(VL_GROUP_LIST, vtype, _current_company).ToWindowNumber()); + InvalidateWindowData(GetWindowClassForVehicleType(vtype), VehicleListIdentifier(VehicleListType::Group, vtype, _current_company).ToWindowNumber()); } return { CommandCost(), new_g }; @@ -644,7 +644,7 @@ CommandCost CmdAddSharedVehicleGroup(DoCommandFlags flags, GroupID id_g, Vehicle } } - InvalidateWindowData(GetWindowClassForVehicleType(type), VehicleListIdentifier(VL_GROUP_LIST, type, _current_company).ToWindowNumber()); + InvalidateWindowData(GetWindowClassForVehicleType(type), VehicleListIdentifier(VehicleListType::Group, type, _current_company).ToWindowNumber()); } return CommandCost(); @@ -674,7 +674,7 @@ CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlags flags, GroupID group_id) } } - InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).ToWindowNumber()); + InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VehicleListType::Group, g->vehicle_type, _current_company).ToWindowNumber()); } return CommandCost(); @@ -755,7 +755,7 @@ CommandCost CmdSetGroupFlag(DoCommandFlags flags, GroupID group_id, GroupFlag fl if (flags.Test(DoCommandFlag::Execute)) { SetGroupFlag(g, flag, value, recursive); - SetWindowDirty(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VL_GROUP_LIST, g->vehicle_type, _current_company).ToWindowNumber()); + SetWindowDirty(GetWindowClassForVehicleType(g->vehicle_type), VehicleListIdentifier(VehicleListType::Group, g->vehicle_type, _current_company).ToWindowNumber()); InvalidateWindowData(WindowClass::ReplaceVehicle, g->vehicle_type); } diff --git a/src/group_gui.cpp b/src/group_gui.cpp index dbb2ace5b3..c61d0a0ddc 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -1231,7 +1231,7 @@ static void ShowCompanyGroupInternal(CompanyID company, VehicleType vehicle_type if (!Company::IsValidID(company)) return; assert(to_underlying(vehicle_type) < std::size(_vehicle_group_desc)); - VehicleListIdentifier vli(VL_GROUP_LIST, vehicle_type, company); + VehicleListIdentifier vli(VehicleListType::Group, vehicle_type, company); VehicleGroupWindow *w = AllocateWindowDescFront(_vehicle_group_desc[vehicle_type], vli.ToWindowNumber(), vli); if (w != nullptr) w->SelectGroup(group); } @@ -1264,7 +1264,7 @@ void ShowCompanyGroupForVehicle(const Vehicle *v) */ static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner owner) { - return dynamic_cast(FindWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, owner).ToWindowNumber())); + return dynamic_cast(FindWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VehicleListType::Group, vt, owner).ToWindowNumber())); } /** diff --git a/src/station.cpp b/src/station.cpp index 0f69a915b6..b277c88c22 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -53,10 +53,10 @@ BaseStation::~BaseStation() { if (CleaningPool()) return; - CloseWindowById(WindowClass::TrainList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Train, this->owner, this->index).ToWindowNumber()); - CloseWindowById(WindowClass::RoadVehicleList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Road, this->owner, this->index).ToWindowNumber()); - CloseWindowById(WindowClass::ShipList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Ship, this->owner, this->index).ToWindowNumber()); - CloseWindowById(WindowClass::AircraftList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Aircraft, this->owner, this->index).ToWindowNumber()); + CloseWindowById(WindowClass::TrainList, VehicleListIdentifier(VehicleListType::Station, VehicleType::Train, this->owner, this->index).ToWindowNumber()); + CloseWindowById(WindowClass::RoadVehicleList, VehicleListIdentifier(VehicleListType::Station, VehicleType::Road, this->owner, this->index).ToWindowNumber()); + CloseWindowById(WindowClass::ShipList, VehicleListIdentifier(VehicleListType::Station, VehicleType::Ship, this->owner, this->index).ToWindowNumber()); + CloseWindowById(WindowClass::AircraftList, VehicleListIdentifier(VehicleListType::Station, VehicleType::Aircraft, this->owner, this->index).ToWindowNumber()); this->sign.MarkDirty(); } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index fb0aa7a340..52e5957ea8 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1362,10 +1362,10 @@ struct StationViewWindow : public Window { void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(WindowClass::TrainList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Train, this->owner, this->window_number).ToWindowNumber(), false); - CloseWindowById(WindowClass::RoadVehicleList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Road, this->owner, this->window_number).ToWindowNumber(), false); - CloseWindowById(WindowClass::ShipList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Ship, this->owner, this->window_number).ToWindowNumber(), false); - CloseWindowById(WindowClass::AircraftList, VehicleListIdentifier(VL_STATION_LIST, VehicleType::Aircraft, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(WindowClass::TrainList, VehicleListIdentifier(VehicleListType::Station, VehicleType::Train, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(WindowClass::RoadVehicleList, VehicleListIdentifier(VehicleListType::Station, VehicleType::Road, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(WindowClass::ShipList, VehicleListIdentifier(VehicleListType::Station, VehicleType::Ship, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(WindowClass::AircraftList, VehicleListIdentifier(VehicleListType::Station, VehicleType::Aircraft, this->owner, this->window_number).ToWindowNumber(), false); SetViewportCatchmentStation(Station::Get(this->window_number), false); this->Window::Close(); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 0698808b7c..4ecd5cccae 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -3048,7 +3048,7 @@ void Vehicle::RemoveFromShared() /* Remember if we were first and the old window number before RemoveVehicle() * as this changes first if needed. */ bool were_first = (this->FirstShared() == this); - VehicleListIdentifier vli(VL_SHARED_ORDERS, this->type, this->owner, this->FirstShared()->index); + VehicleListIdentifier vli(VehicleListType::VehicleSharedOrders, this->type, this->owner, this->FirstShared()->index); this->orders->RemoveVehicle(this); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 60a1c5519f..a350bca7f2 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -50,7 +50,7 @@ #include "safeguards.h" -static std::array, VLT_END> _grouping{}; +static EnumIndexArray, VehicleListType, VehicleListType::End> _grouping{}; static std::array _sorting{}; static BaseVehicleListWindow::VehicleIndividualSortFunction VehicleNumberSorter; @@ -1939,7 +1939,7 @@ public: { this->CreateNestedTree(); - this->GetWidget(WID_VL_FILTER_BY_CARGO_SEL)->SetDisplayedPlane((this->vli.type == VL_SHARED_ORDERS) ? SZSP_NONE : 0); + this->GetWidget(WID_VL_FILTER_BY_CARGO_SEL)->SetDisplayedPlane((this->vli.type == VehicleListType::VehicleSharedOrders) ? SZSP_NONE : 0); this->vscroll = this->GetScrollbar(WID_VL_SCROLLBAR); @@ -1947,7 +1947,7 @@ public: this->GetWidget(WID_VL_LIST)->SetToolTip(STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + to_underlying(this->vli.vtype)); NWidgetStacked *nwi = this->GetWidget(WID_VL_CAPTION_SELECTION); - if (this->vli.type == VL_SHARED_ORDERS) { + if (this->vli.type == VehicleListType::VehicleSharedOrders) { this->GetWidget(WID_VL_CAPTION_SHARED_ORDERS)->SetString(STR_VEHICLE_LIST_SHARED_ORDERS_LIST_CAPTION); /* If we are in the shared orders window, then disable the group-by dropdown menu. * Remove this when the group-by dropdown menu has another option apart from grouping by shared orders. */ @@ -2016,7 +2016,7 @@ public: break; case WID_VL_MANAGE_VEHICLES_DROPDOWN: { - Dimension d = this->GetActionDropdownSize(this->vli.type == VL_STANDARD, false, true); + Dimension d = this->GetActionDropdownSize(this->vli.type == VehicleListType::Company, false, true); d.height += padding.height; d.width += padding.width; size = maxdim(size, d); @@ -2043,16 +2043,16 @@ public: case WID_VL_CAPTION: case WID_VL_CAPTION_SHARED_ORDERS: { switch (this->vli.type) { - case VL_SHARED_ORDERS: // Shared Orders + case VehicleListType::VehicleSharedOrders: // Shared Orders return GetString(stringid, this->vehicles.size()); - case VL_STANDARD: // Company Name + case VehicleListType::Company: // Company Name return GetString(stringid, STR_COMPANY_NAME, this->vli.ToCompanyID(), std::monostate{}, this->vehicles.size()); - case VL_STATION_LIST: // Station/Waypoint Name + case VehicleListType::Station: // Station/Waypoint Name return GetString(stringid, Station::IsExpected(BaseStation::Get(this->vli.ToStationID())) ? STR_STATION_NAME : STR_WAYPOINT_NAME, this->vli.ToStationID(), std::monostate{}, this->vehicles.size()); - case VL_DEPOT_LIST: + case VehicleListType::Depot: return GetString(stringid, STR_DEPOT_CAPTION, this->vli.vtype, this->vli.ToDestinationID(), this->vehicles.size()); default: NOT_REACHED(); @@ -2096,7 +2096,7 @@ public: nwi->SetDirty(this); } if (this->owner == _local_company) { - this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD); + this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VehicleListType::Company); this->SetWidgetsDisabledState(this->vehicles.empty(), WID_VL_MANAGE_VEHICLES_DROPDOWN, WID_VL_STOP_ALL, @@ -2119,7 +2119,7 @@ public: { switch (widget) { case WID_VL_ORDER_VIEW: // Open the shared orders window - assert(this->vli.type == VL_SHARED_ORDERS); + assert(this->vli.type == VehicleListType::VehicleSharedOrders); assert(!this->vehicles.empty()); ShowOrdersWindow(this->vehicles[0]); break; @@ -2190,7 +2190,7 @@ public: break; case WID_VL_MANAGE_VEHICLES_DROPDOWN: { - ShowDropDownList(this, this->BuildActionDropdownList(this->vli.type == VL_STANDARD, false, true), 0, WID_VL_MANAGE_VEHICLES_DROPDOWN); + ShowDropDownList(this, this->BuildActionDropdownList(this->vli.type == VehicleListType::Company, false, true), 0, WID_VL_MANAGE_VEHICLES_DROPDOWN); break; } @@ -2244,7 +2244,7 @@ public: void OnGameTick() override { if (this->vehgroups.NeedResort()) { - StationID station = (this->vli.type == VL_STATION_LIST) ? this->vli.ToStationID() : StationID::Invalid(); + StationID station = (this->vli.type == VehicleListType::Station) ? this->vli.ToStationID() : StationID::Invalid(); Debug(misc, 3, "Periodic resort {} list company {} at station {}", this->vli.vtype, this->owner, station); this->SetDirty(); @@ -2263,7 +2263,7 @@ public: */ void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override { - if (!gui_scope && HasBit(data, 31) && this->vli.type == VL_SHARED_ORDERS) { + if (!gui_scope && HasBit(data, 31) && this->vli.type == VehicleListType::VehicleSharedOrders) { /* Needs to be done in command-scope, so everything stays valid */ this->vli.SetIndex(GB(data, 0, 20)); this->window_number = this->vli.ToWindowNumber(); @@ -2327,23 +2327,23 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type) if ((_settings_client.gui.advanced_vehicle_list > (uint)(company != _local_company)) != _ctrl_pressed) { ShowCompanyGroup(company, vehicle_type); } else { - ShowVehicleListWindowLocal(company, VL_STANDARD, vehicle_type, company.base()); + ShowVehicleListWindowLocal(company, VehicleListType::Company, vehicle_type, company.base()); } } void ShowVehicleListWindow(const Vehicle *v) { - ShowVehicleListWindowLocal(v->owner, VL_SHARED_ORDERS, v->type, v->FirstShared()->index.base()); + ShowVehicleListWindowLocal(v->owner, VehicleListType::VehicleSharedOrders, v->type, v->FirstShared()->index.base()); } void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station) { - ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station.base()); + ShowVehicleListWindowLocal(company, VehicleListType::Station, vehicle_type, station.base()); } void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile) { - ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, GetDepotDestinationIndex(depot_tile).base()); + ShowVehicleListWindowLocal(company, VehicleListType::Depot, vehicle_type, GetDepotDestinationIndex(depot_tile).base()); } diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index 6cecfb0ee6..6ab94b0aa2 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -23,13 +23,13 @@ WindowNumber VehicleListIdentifier::ToWindowNumber() const { uint8_t c = this->company == OWNER_NONE ? 0xF : this->company.base(); - assert(c < (1 << 4)); - assert(to_underlying(this->vtype) < (1 << 2)); - assert(this->index < (1 << 20)); - assert(this->type < VLT_END); - static_assert(VLT_END <= (1 << 3)); + assert(c < (1 << 4)); + assert(to_underlying(this->vtype) < (1 << 2)); + assert(this->index < (1 << 20)); + assert(this->type < VehicleListType::End); + static_assert(to_underlying(VehicleListType::End) <= (1 << 3)); - return c << 28 | this->type << 23 | to_underlying(this->vtype) << 26 | this->index; + return c << 28 | to_underlying(this->type) << 23 | to_underlying(this->vtype) << 26 | this->index; } /** @@ -71,7 +71,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli list->clear(); switch (vli.type) { - case VL_STATION_LIST: + case VehicleListType::Station: FindVehiclesWithOrder( [&vli](const Vehicle *v) { return v->type == vli.vtype; }, [&vli](const Order *order) { return (order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT)) && order->GetDestination() == vli.ToStationID(); }, @@ -79,7 +79,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli ); break; - case VL_SHARED_ORDERS: { + case VehicleListType::VehicleSharedOrders: { /* Add all vehicles from this vehicle's shared order list */ const Vehicle *v = Vehicle::GetIfValid(vli.ToVehicleID()); if (v == nullptr || v->type != vli.vtype || !v->IsPrimaryVehicle()) return false; @@ -90,7 +90,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli break; } - case VL_GROUP_LIST: + case VehicleListType::Group: if (vli.ToGroupID() != ALL_GROUP) { for (const Vehicle *v : Vehicle::Iterate()) { if (v->type == vli.vtype && v->IsPrimaryVehicle() && @@ -102,7 +102,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli } [[fallthrough]]; - case VL_STANDARD: + case VehicleListType::Company: for (const Vehicle *v : Vehicle::Iterate()) { if (v->type == vli.vtype && v->owner == vli.company && v->IsPrimaryVehicle()) { list->push_back(v); @@ -110,7 +110,7 @@ bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli } break; - case VL_DEPOT_LIST: + case VehicleListType::Depot: FindVehiclesWithOrder( [&vli](const Vehicle *v) { return v->type == vli.vtype; }, [&vli](const Order *order) { return order->IsType(OT_GOTO_DEPOT) && !order->GetDepotActionType().Test(OrderDepotActionFlag::NearestDepot) && order->GetDestination() == vli.ToDestinationID(); }, diff --git a/src/vehiclelist.h b/src/vehiclelist.h index ffba2e48a4..f997d2e1d3 100644 --- a/src/vehiclelist.h +++ b/src/vehiclelist.h @@ -19,13 +19,13 @@ #include "window_type.h" /** Vehicle List type flags */ -enum VehicleListType : uint8_t { - VL_STANDARD, ///< Index is the company. - VL_SHARED_ORDERS, ///< Index is the first vehicle of the shared orders. - VL_STATION_LIST, ///< Index is the station. - VL_DEPOT_LIST, ///< Index is the destination (station for hangar of aircraft, depot for others) - VL_GROUP_LIST, ///< Index is the group. - VLT_END +enum class VehicleListType : uint8_t { + Company, ///< Index is the company. + VehicleSharedOrders, ///< Index is the first vehicle of the shared orders. + Station, ///< Index is the station. + Depot, ///< Index is the destination (station for hangar of aircraft, depot for others) + Group, ///< Index is the group. + End, ///< End marker }; /** The information about a vehicle list. */ @@ -37,13 +37,13 @@ struct VehicleListIdentifier { WindowNumber ToWindowNumber() const; - bool Valid() const { return this->type < VLT_END; } + bool Valid() const { return this->type < VehicleListType::End; } - constexpr CompanyID ToCompanyID() const { assert(this->type == VL_STANDARD); return CompanyID(this->index); } - constexpr DestinationID ToDestinationID() const { assert(this->type == VL_DEPOT_LIST); return DestinationID(this->index); } - constexpr GroupID ToGroupID() const { assert(this->type == VL_GROUP_LIST); return GroupID(this->index); } - constexpr StationID ToStationID() const { assert(this->type == VL_STATION_LIST); return StationID(this->index); } - constexpr VehicleID ToVehicleID() const { assert(this->type == VL_SHARED_ORDERS); return VehicleID(this->index); } + constexpr CompanyID ToCompanyID() const { assert(this->type == VehicleListType::Company); return CompanyID(this->index); } + constexpr DestinationID ToDestinationID() const { assert(this->type == VehicleListType::Depot); return DestinationID(this->index); } + constexpr GroupID ToGroupID() const { assert(this->type == VehicleListType::Group); return GroupID(this->index); } + constexpr StationID ToStationID() const { assert(this->type == VehicleListType::Station); return StationID(this->index); } + constexpr VehicleID ToVehicleID() const { assert(this->type == VehicleListType::VehicleSharedOrders); return VehicleID(this->index); } constexpr void SetIndex(uint32_t index) { this->index = index; } constexpr void SetIndex(ConvertibleThroughBase auto index) { this->index = index.base(); } diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index d459bb33e1..c21c3371d0 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -104,7 +104,7 @@ public: void Close([[maybe_unused]] int data = 0) override { - CloseWindowById(GetWindowClassForVehicleType(this->vt), VehicleListIdentifier(VL_STATION_LIST, this->vt, this->owner, this->window_number).ToWindowNumber(), false); + CloseWindowById(GetWindowClassForVehicleType(this->vt), VehicleListIdentifier(VehicleListType::Station, this->vt, this->owner, this->window_number).ToWindowNumber(), false); SetViewportCatchmentWaypoint(Waypoint::Get(this->window_number), false); this->Window::Close(); }