changeset 4681 | 7d7a89b32dd0 |
parent 4678 | 073e56e25e83 |
child 4683 | 13d7b7d779cf |
4680:dbeabe6cbdbb | 4681:7d7a89b32dd0 |
---|---|
1604 } |
1604 } |
1605 |
1605 |
1606 if (vehicle_list_window) { |
1606 if (vehicle_list_window) { |
1607 uint16 window_type = p2 & VLW_MASK; |
1607 uint16 window_type = p2 & VLW_MASK; |
1608 |
1608 |
1609 engine_count = GenerateVehicleSortList((const Vehicle***)&vl, &engine_list_length, vehicle_type, _current_player, INVALID_STATION, INVALID_ORDER, window_type); |
1609 engine_count = GenerateVehicleSortList((const Vehicle***)&vl, &engine_list_length, vehicle_type, _current_player, INVALID_STATION, INVALID_ORDER, INVALID_STATION, window_type); |
1610 } else { |
1610 } else { |
1611 /* Get the list of vehicles in the depot */ |
1611 /* Get the list of vehicles in the depot */ |
1612 BuildDepotVehicleList(vehicle_type, tile, &vl, &engine_list_length, &engine_count, NULL, NULL, NULL); |
1612 BuildDepotVehicleList(vehicle_type, tile, &vl, &engine_list_length, &engine_count, NULL, NULL, NULL); |
1613 } |
1613 } |
1614 |
1614 |
2290 * @param station index of station to generate a list for. INVALID_STATION when not used |
2290 * @param station index of station to generate a list for. INVALID_STATION when not used |
2291 * @param order index of oder to generate a list for. INVALID_ORDER when not used |
2291 * @param order index of oder to generate a list for. INVALID_ORDER when not used |
2292 * @param window_type tells what kind of window the list is for. Use the VLW flags in vehicle_gui.h |
2292 * @param window_type tells what kind of window the list is for. Use the VLW flags in vehicle_gui.h |
2293 * @return the number of vehicles added to the list |
2293 * @return the number of vehicles added to the list |
2294 */ |
2294 */ |
2295 uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, byte type, PlayerID owner, StationID station, OrderID order, uint16 window_type) |
2295 uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, byte type, PlayerID owner, StationID station, OrderID order, uint16 depot_airport_index, uint16 window_type) |
2296 { |
2296 { |
2297 const uint subtype = (type != VEH_Aircraft) ? Train_Front : 2; |
2297 const uint subtype = (type != VEH_Aircraft) ? Train_Front : 2; |
2298 uint n = 0; |
2298 uint n = 0; |
2299 const Vehicle *v; |
2299 const Vehicle *v; |
2300 |
2300 |
2345 } |
2345 } |
2346 } |
2346 } |
2347 break; |
2347 break; |
2348 } |
2348 } |
2349 |
2349 |
2350 case VLW_DEPOT_LIST: { |
|
2351 FOR_ALL_VEHICLES(v) { |
|
2352 if (v->type == type && ( |
|
2353 (type == VEH_Train && IsFrontEngine(v)) || |
|
2354 (type != VEH_Train && v->subtype <= subtype))) { |
|
2355 const Order *order; |
|
2356 |
|
2357 FOR_VEHICLE_ORDERS(v, order) { |
|
2358 if (order->type == OT_GOTO_DEPOT && order->dest == depot_airport_index) { |
|
2359 if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, 25); |
|
2360 (*sort_list)[n++] = v; |
|
2361 break; |
|
2362 } |
|
2363 } |
|
2364 } |
|
2365 } |
|
2366 break; |
|
2367 } |
|
2368 |
|
2350 default: NOT_REACHED(); break; |
2369 default: NOT_REACHED(); break; |
2351 } |
2370 } |
2352 |
2371 |
2353 if ((n + 100) < *length_of_array) { |
2372 if ((n + 100) < *length_of_array) { |
2354 /* We allocated way too much for sort_list. |
2373 /* We allocated way too much for sort_list. |
2374 { |
2393 { |
2375 const Vehicle **sort_list = NULL; |
2394 const Vehicle **sort_list = NULL; |
2376 uint n, i; |
2395 uint n, i; |
2377 uint16 array_length = 0; |
2396 uint16 array_length = 0; |
2378 |
2397 |
2379 n = GenerateVehicleSortList(&sort_list, &array_length, type, owner, (vlw_flag == VLW_STATION_LIST) ? id : INVALID_STATION, (vlw_flag == VLW_SHARED_ORDERS) ? id : INVALID_ORDER, vlw_flag); |
2398 n = GenerateVehicleSortList(&sort_list, &array_length, type, owner, id, id, id, vlw_flag); |
2380 |
2399 |
2381 /* Send all the vehicles to a depot */ |
2400 /* Send all the vehicles to a depot */ |
2382 for (i = 0; i < n; i++) { |
2401 for (i = 0; i < n; i++) { |
2383 const Vehicle *v = sort_list[i]; |
2402 const Vehicle *v = sort_list[i]; |
2384 int32 ret = DoCommand(v->tile, v->index, service | DEPOT_DONT_CANCEL, flags, CMD_SEND_TO_DEPOT(type)); |
2403 int32 ret = DoCommand(v->tile, v->index, service | DEPOT_DONT_CANCEL, flags, CMD_SEND_TO_DEPOT(type)); |