Changeset - r22470:ad7ada400287
[Not reviewed]
master
0 5 0
frosch - 8 years ago 2016-11-05 19:16:59
frosch@openttd.org
(svn r27677) -Codechange: Remove implicit VehicleListIdentifier from uint32 constructor, to make conversions more explicit.
5 files changed with 12 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/vehicle_cmd.cpp
Show inline comments
 
@@ -606,7 +606,7 @@ CommandCost CmdMassStartStopVehicle(Tile
 
	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 @@ CommandCost CmdSendVehicleToDepot(TileIn
 
	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);
 
	}
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -1638,7 +1638,7 @@ public:
 
				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;
 
			}
src/vehicle_gui_base.h
Show inline comments
 
@@ -38,7 +38,7 @@ struct BaseVehicleListWindow : public Wi
 
	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);
 
	}
src/vehiclelist.cpp
Show inline comments
 
@@ -37,7 +37,7 @@ uint32 VehicleListIdentifier::Pack() con
 
 * @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 @@ bool VehicleListIdentifier::Unpack(uint3
 
 * 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;
 
}
 

	
 
/**
src/vehiclelist.h
Show inline comments
 
@@ -35,7 +35,8 @@ struct VehicleListIdentifier {
 
	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 @@ struct VehicleListIdentifier {
 
	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. */
0 comments (0 inline, 0 general)