Changeset - r16070:3f71fb537bd5
[Not reviewed]
master
0 4 0
rubidium - 14 years ago 2010-09-08 21:40:00
rubidium@openttd.org
(svn r20773) -Codechange: use packed VehicleListIdentifiers for some commands as well
4 files changed with 24 insertions and 51 deletions:
0 comments (0 inline, 0 general)
src/group_gui.cpp
Show inline comments
 
@@ -482,10 +482,10 @@ public:
 

	
 
			case GRP_WIDGET_START_ALL:
 
			case GRP_WIDGET_STOP_ALL: { // Start/stop all vehicles of the list
 
				DoCommandP(0, (1 << 1) | (widget == GRP_WIDGET_START_ALL ? (1 << 0) : 0),
 
													((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
 
													| (this->group_sel << 16)
 
													| this->vehicle_type, CMD_MASS_START_STOP);
 
				VehicleListIdentifier vli(this->window_number);
 
				vli.type = IsAllGroupID(this->group_sel) ? VL_STANDARD : VL_GROUP_LIST;
 
				vli.index = this->group_sel;
 
				DoCommandP(0, (1 << 1) | (widget == GRP_WIDGET_START_ALL ? (1 << 0) : 0), vli.Pack(), CMD_MASS_START_STOP);
 
				break;
 
			}
 

	
 
@@ -573,13 +573,14 @@ public:
 
						ShowReplaceGroupVehicleWindow(this->group_sel, this->vehicle_type);
 
						break;
 
					case ADI_SERVICE: // Send for servicing
 
						DoCommandP(0, this->group_sel | DEPOT_MASS_SEND | DEPOT_SERVICE, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) |
 
									this->vehicle_type << 11, GetCmdSendToDepot(this->vehicle_type));
 
					case ADI_DEPOT: { // Send to Depots
 
						VehicleListIdentifier vli(this->window_number);
 
						vli.type = IsAllGroupID(this->group_sel) ? VL_STANDARD : VL_GROUP_LIST;
 
						vli.index = this->group_sel;
 
						DoCommandP(0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : 0U), vli.Pack(), GetCmdSendToDepot(this->vehicle_type));
 
						break;
 
					case ADI_DEPOT: // Send to Depots
 
						DoCommandP(0, this->group_sel | DEPOT_MASS_SEND, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) |
 
									this->vehicle_type << 11, GetCmdSendToDepot(this->vehicle_type));
 
						break;
 
					}
 

	
 
					case ADI_ADD_SHARED: // Add shared Vehicles
 
						assert(Group::IsValidID(this->group_sel));
 

	
src/vehicle_cmd.cpp
Show inline comments
 
@@ -436,31 +436,25 @@ CommandCost CmdStartStopVehicle(TileInde
 
 * @param p1 bitmask
 
 *   - bit 0 false = start vehicles, true = stop vehicles
 
 *   - bit 1 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
 
 * @param p2 bitmask
 
 *   - bit 0-4 Vehicle type
 
 *   - bit 8-11 Vehicle List Window type (ignored unless bit 6 is set)
 
 *   - bit 16-31 Station/Order/Depot ID (only used for vehicle list windows)
 
 * @param p2 packed VehicleListIdentifier
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	VehicleList list;
 
	VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p2);
 
	bool start_stop = HasBit(p1, 0);
 
	bool vehicle_list_window = HasBit(p1, 1);
 

	
 
	if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
 
	VehicleListIdentifier vli;
 
	if (!vli.Unpack(p2)) return CMD_ERROR;
 
	if (!IsCompanyBuildableVehicleType(vli.vtype)) return CMD_ERROR;
 

	
 
	if (vehicle_list_window) {
 
		uint32 id = GB(p2, 16, 16);
 
		uint16 window_type = p2 & VLW_MASK;
 

	
 
		VehicleListIdentifier vli((VehicleListType)(window_type >> 8), vehicle_type, _current_company, id);
 
		if (!GenerateVehicleSortList(&list, vli)) return CMD_ERROR;
 
	} else {
 
		/* Get the list of vehicles in the depot */
 
		BuildDepotVehicleList(vehicle_type, tile, &list, NULL);
 
		BuildDepotVehicleList(vli.vtype, tile, &list, NULL);
 
	}
 

	
 
	for (uint i = 0; i < list.Length(); i++) {
 
@@ -469,7 +463,7 @@ CommandCost CmdMassStartStopVehicle(Tile
 
		if (!!(v->vehstatus & VS_STOPPED) != start_stop) continue;
 

	
 
		if (!vehicle_list_window) {
 
			if (vehicle_type == VEH_TRAIN) {
 
			if (vli.vtype == VEH_TRAIN) {
 
				if (!Train::From(v)->IsInDepot()) continue;
 
			} else {
 
				if (!(v->vehstatus & VS_HIDDEN)) continue;
 
@@ -812,7 +806,7 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
 * @param vli     identifier of the vehicle list
 
 * @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
 
 */
 
CommandCost SendAllVehiclesToDepot(DoCommandFlag flags, bool service, const VehicleListIdentifier &vli)
 
static CommandCost SendAllVehiclesToDepot(DoCommandFlag flags, bool service, const VehicleListIdentifier &vli)
 
{
 
	VehicleList list;
 

	
 
@@ -845,10 +839,7 @@ CommandCost SendAllVehiclesToDepot(DoCom
 
 * @param p1 bitmask
 
 * - p1 0-20: bitvehicle ID to send to the depot
 
 * - p1 bits 25-8  - DEPOT_ flags (see vehicle_type.h)
 
 * @param p2 various bitmasked elements
 
 * - p2 bit  0-3  - DEPOT_ flags (see vehicle.h)
 
 * - p2 bit  8-10 - VLW flag (for mass goto depot)
 
 * - p2 bit 10-11 - Vehicle type
 
 * @param p2 packed VehicleListIdentifier.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
@@ -856,9 +847,9 @@ CommandCost CmdSendVehicleToDepot(TileIn
 
{
 
	if (p1 & DEPOT_MASS_SEND) {
 
		/* Mass goto depot requested */
 
		if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
 
		VehicleListIdentifier vli((VehicleListType)((p2 & VLW_MASK) >> 8), (VehicleType)GB(p2, 11, 2), _current_company, GB(p1, 0, 20));
 
		return SendAllVehiclesToDepot(flags, (p2 & DEPOT_SERVICE) != 0, vli);
 
		VehicleListIdentifier vli;
 
		if (!vli.Unpack(p2)) return CMD_ERROR;
 
		return SendAllVehiclesToDepot(flags, (p1 & DEPOT_SERVICE) != 0, vli);
 
	}
 

	
 
	Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
src/vehicle_gui.cpp
Show inline comments
 
@@ -1284,7 +1284,7 @@ public:
 

	
 
			case VLW_WIDGET_STOP_ALL:
 
			case VLW_WIDGET_START_ALL:
 
				DoCommandP(0, (1 << 1) | (widget == VLW_WIDGET_START_ALL ? (1 << 0) : 0), GB(this->window_number, 16, 16) << 16 | (this->window_number & VLW_MASK) | this->vehicle_type, CMD_MASS_START_STOP);
 
				DoCommandP(0, (1 << 1) | (widget == VLW_WIDGET_START_ALL ? (1 << 0) : 0), this->window_number, CMD_MASS_START_STOP);
 
				break;
 
		}
 
	}
 
@@ -1303,12 +1303,8 @@ public:
 
						ShowReplaceGroupVehicleWindow(DEFAULT_GROUP, this->vehicle_type);
 
						break;
 
					case ADI_SERVICE: // Send for servicing
 
						DoCommandP(0, GB(this->window_number, 16, 16) | DEPOT_MASS_SEND | DEPOT_SERVICE /* StationID or OrderID (depending on VLW) */,
 
							(this->window_number & VLW_MASK) | this->vehicle_type << 11, GetCmdSendToDepot(this->vehicle_type));
 
						break;
 
					case ADI_DEPOT: // Send to Depots
 
						DoCommandP(0, GB(this->window_number, 16, 16) | DEPOT_MASS_SEND /* StationID or OrderID (depending on VLW) */,
 
							(this->window_number & VLW_MASK) | this->vehicle_type << 11, GetCmdSendToDepot(this->vehicle_type));
 
						DoCommandP(0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : (DepotCommand)0), this->window_number, GetCmdSendToDepot(this->vehicle_type));
 
						break;
 

	
 
					default: NOT_REACHED();
src/vehicle_gui.h
Show inline comments
 
@@ -46,21 +46,6 @@ enum TrainDetailsWindowTabs {
 
	TDW_TAB_TOTALS,    ///< Tab with sum of total cargo transported
 
};
 

	
 
/** Vehicle List Window type flags */
 
enum VehicleListWindowType {
 
	VLW_STANDARD      = 0 << 8,
 
	VLW_SHARED_ORDERS = 1 << 8,
 
	VLW_STATION_LIST  = 2 << 8,
 
	VLW_DEPOT_LIST    = 3 << 8,
 
	VLW_GROUP_LIST    = 4 << 8,
 
	VLW_MASK          = 0x700,
 
};
 

	
 
static inline bool ValidVLWFlags(uint16 flags)
 
{
 
	return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST || flags == VLW_GROUP_LIST);
 
}
 

	
 
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number);
 

	
 
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, int skip, VehicleID drag_dest = INVALID_VEHICLE);
0 comments (0 inline, 0 general)