Index: src/vehicle_cmd.cpp =================================================================== --- src/vehicle_cmd.cpp (revision 27675) +++ src/vehicle_cmd.cpp (working copy) @@ -606,7 +606,7 @@ bool vehicle_list_window = HasBit(p1, 1); VehicleListIdentifier vli; - if (!vli.Unpack(p2)) return CMD_ERROR; + if (!vli.UnpackIfValid(p2)) return CMD_ERROR; if (!IsCompanyBuildableVehicleType(vli.vtype)) return CMD_ERROR; if (vehicle_list_window) { @@ -1001,7 +1001,7 @@ if (p1 & DEPOT_MASS_SEND) { /* Mass goto depot requested */ VehicleListIdentifier vli; - if (!vli.Unpack(p2)) return CMD_ERROR; + if (!vli.UnpackIfValid(p2)) return CMD_ERROR; return SendAllVehiclesToDepot(flags, (p1 & DEPOT_SERVICE) != 0, vli); } Index: src/vehicle_gui.cpp =================================================================== --- src/vehicle_gui.cpp (revision 27675) +++ src/vehicle_gui.cpp (working copy) @@ -1638,7 +1638,7 @@ break; case WID_VL_MANAGE_VEHICLES_DROPDOWN: { - DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier(this->window_number).type == VL_STANDARD, false); + DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier::UnPack(this->window_number).type == VL_STANDARD, false); ShowDropDownList(this, list, 0, WID_VL_MANAGE_VEHICLES_DROPDOWN); break; } Index: src/vehicle_gui_base.h =================================================================== --- src/vehicle_gui_base.h (revision 27675) +++ src/vehicle_gui_base.h (working copy) @@ -38,7 +38,7 @@ static const StringID vehicle_sorter_names[]; static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[]; - BaseVehicleListWindow(WindowDesc *desc, WindowNumber wno) : Window(desc), vli(wno) + BaseVehicleListWindow(WindowDesc *desc, WindowNumber wno) : Window(desc), vli(VehicleListIdentifier::UnPack(wno)) { this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs); } Index: src/vehiclelist.cpp =================================================================== --- src/vehiclelist.cpp (revision 27675) +++ src/vehiclelist.cpp (working copy) @@ -37,7 +37,7 @@ * @param data The data to unpack. * @return true iff the data was valid (enough). */ -bool VehicleListIdentifier::Unpack(uint32 data) +bool VehicleListIdentifier::UnpackIfValid(uint32 data) { byte c = GB(data, 28, 4); this->company = c == 0xF ? OWNER_NONE : (CompanyID)c; @@ -52,10 +52,12 @@ * Decode a packed vehicle list identifier into a new one. * @param data The data to unpack. */ -VehicleListIdentifier::VehicleListIdentifier(uint32 data) +/* static */ VehicleListIdentifier VehicleListIdentifier::UnPack(uint32 data) { - bool ret = this->Unpack(data); + VehicleListIdentifier result; + bool ret = result.UnpackIfValid(data); assert(ret); + return result; } /** Index: src/vehiclelist.h =================================================================== --- src/vehiclelist.h (revision 27675) +++ src/vehiclelist.h (working copy) @@ -35,7 +35,8 @@ uint32 index; ///< A vehicle list type specific index. uint32 Pack() const; - bool Unpack(uint32 data); + bool UnpackIfValid(uint32 data); + static VehicleListIdentifier UnPack(uint32 data); /** * Create a simple vehicle list. @@ -47,7 +48,7 @@ VehicleListIdentifier(VehicleListType type, VehicleType vtype, CompanyID company, uint index = 0) : type(type), vtype(vtype), company(company), index(index) {} - VehicleListIdentifier(uint32 data = 0); + VehicleListIdentifier() : type(), vtype(), company(), index() {} }; /** A list of vehicles. */