(svn r6676) -Fix: [vehicle list windows] mass start/stop now works correctly in shared orders and station lists
authorbjarni
Sat, 07 Oct 2006 08:24:11 +0000
changeset 4762 58d2f43ebdda
parent 4761 40beac850798
child 4763 cd72f1d9f4a6
(svn r6676) -Fix: [vehicle list windows] mass start/stop now works correctly in shared orders and station lists
depot_gui.c
vehicle.c
vehicle_gui.c
--- a/depot_gui.c	Sat Oct 07 07:24:45 2006 +0000
+++ b/depot_gui.c	Sat Oct 07 08:24:11 2006 +0000
@@ -699,7 +699,7 @@
 
 				case DEPOT_WIDGET_STOP_ALL:
 				case DEPOT_WIDGET_START_ALL:
-					DoCommandP(w->window_number, WP(w, depot_d).type, e->we.click.widget == DEPOT_WIDGET_START_ALL ? 1 : 0, NULL, CMD_MASS_START_STOP);
+					DoCommandP(w->window_number, 0, WP(w, depot_d).type | (e->we.click.widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), NULL, CMD_MASS_START_STOP);
 					break;
 
 				case DEPOT_WIDGET_SELL_ALL:
--- a/vehicle.c	Sat Oct 07 07:24:45 2006 +0000
+++ b/vehicle.c	Sat Oct 07 08:24:11 2006 +0000
@@ -1582,10 +1582,11 @@
 
 /** Starts or stops a lot of vehicles
  * @param tile Tile of the depot where the vehicles are started/stopped (only used for depots)
- * @param p1 Vehicle type
+ * @param p1 Station/Order/Depot ID (only used for vehicle list windows)
  * @param p2 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
+ *   - bit 0-4 Vehicle type
+ *   - bit 5 false = start vehicles, true = stop vehicles
+ *   - bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
  *   - bit 8-11 Vehicle List Window type (ignored unless bit 1 is set)
  */
 int32 CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -1596,9 +1597,9 @@
 	int32 return_value = CMD_ERROR;
 	uint i;
 	uint stop_command;
-	byte vehicle_type = GB(p1, 0, 8);
-	bool start_stop = HASBIT(p2, 0);
-	bool vehicle_list_window = HASBIT(p2, 1);
+	byte vehicle_type = GB(p2, 0, 5);
+	bool start_stop = HASBIT(p2, 5);
+	bool vehicle_list_window = HASBIT(p2, 6);
 
 	switch (vehicle_type) {
 		case VEH_Train:    stop_command = CMD_START_STOP_TRAIN;    break;
@@ -1609,9 +1610,10 @@
 	}
 
 	if (vehicle_list_window) {
+		uint16 id = GB(p1, 0, 16);
 		uint16 window_type = p2 & VLW_MASK;
 
-		engine_count = GenerateVehicleSortList((const Vehicle***)&vl, &engine_list_length, vehicle_type, _current_player, INVALID_STATION, INVALID_ORDER, INVALID_STATION, window_type);
+		engine_count = GenerateVehicleSortList((const Vehicle***)&vl, &engine_list_length, vehicle_type, _current_player, id, id, id, window_type);
 	} else {
 		/* Get the list of vehicles in the depot */
 		BuildDepotVehicleList(vehicle_type, tile, &vl, &engine_list_length, &engine_count, NULL, NULL, NULL);
--- a/vehicle_gui.c	Sat Oct 07 07:24:45 2006 +0000
+++ b/vehicle_gui.c	Sat Oct 07 08:24:11 2006 +0000
@@ -1720,7 +1720,7 @@
 
 				case VLW_WIDGET_STOP_ALL:
 				case VLW_WIDGET_START_ALL:
-					DoCommandP(0, vl->vehicle_type, (w->window_number & VLW_MASK) | (1 << 1) | (e->we.click.widget == VLW_WIDGET_START_ALL ? 1 : 0), NULL, CMD_MASS_START_STOP);
+					DoCommandP(0, GB(w->window_number, 16, 16), (w->window_number & VLW_MASK) | (1 << 6) | (e->we.click.widget == VLW_WIDGET_START_ALL ? (1 << 5) : 0) | vl->vehicle_type, NULL, CMD_MASS_START_STOP);
 					break;
 			}
 		}	break;