Codechange: add helpers to VehicleListIdentifier for ConvertibleThroughBase

This commit is contained in:
Rubidium 2025-02-09 15:13:43 +01:00 committed by rubidium42
parent f60b3d7f79
commit 6535fc1f80
2 changed files with 5 additions and 1 deletions

View File

@ -299,7 +299,7 @@ struct DepotWindow : Window {
void Close([[maybe_unused]] int data = 0) override
{
CloseWindowById(WC_BUILD_VEHICLE, this->window_number);
CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDestinationIndex().base()).ToWindowNumber(), false);
CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDestinationIndex()).ToWindowNumber(), false);
OrderBackup::Reset(TileIndex(this->window_number));
this->Window::Close();
}

View File

@ -46,6 +46,7 @@ struct VehicleListIdentifier {
constexpr VehicleID ToVehicleID() const { assert(this->type == VL_SHARED_ORDERS); return VehicleID(this->index); }
constexpr void SetIndex(uint32_t index) { this->index = index; }
constexpr void SetIndex(ConvertibleThroughBase auto index) { this->index = index.base(); }
/**
* Create a simple vehicle list.
@ -57,6 +58,9 @@ struct VehicleListIdentifier {
VehicleListIdentifier(VehicleListType type, VehicleType vtype, CompanyID company, uint index = 0) :
type(type), vtype(vtype), company(company), index(index) {}
VehicleListIdentifier(VehicleListType type, VehicleType vtype, CompanyID company, ConvertibleThroughBase auto index) :
type(type), vtype(vtype), company(company), index(index.base()) {}
VehicleListIdentifier() = default;
};