summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-09-01 10:24:15 +0000
committerbjarni <bjarni@openttd.org>2006-09-01 10:24:15 +0000
commitd7e1d08d53d7d9885c747d7e1095d607f8f5cebe (patch)
treee86a7aeb29a672f565ab4b7aa38c5cb4a0010e93 /vehicle.c
parent7d3685a8ad0661c43dda4deb8c2559226b3370fe (diff)
downloadopenttd-d7e1d08d53d7d9885c747d7e1095d607f8f5cebe.tar.xz
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
-Codechange: unified the code for mass goto depot to avoid duplicated code -Fix: Vehicles already on the way to depots will not be cancelled by mass goto depot (made it really hard to send all vehicles at once)
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/vehicle.c b/vehicle.c
index 6ec79fcb7..8af90f895 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1969,24 +1969,26 @@ uint GenerateVehicleSortList(const Vehicle** sort_list, byte type, PlayerID owne
* @param flags the flags used for DoCommand()
* @param service should the vehicles only get service in the depots
* @param owner PlayerID of owner of the vehicles to send
+* @param VLW_flag tells what kind of list requested the goto depot
* @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
*/
-int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner)
+int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
{
const Vehicle** sort_list;
uint n, i;
sort_list = malloc(GetVehicleArraySize() * sizeof(sort_list[0]));
if (sort_list == NULL) {
- error("Could not allocate memory for the vehicle-sorting-list");
+ error("Could not allocate memory for the vehicle-goto-depot-list");
}
- n = GenerateVehicleSortList(sort_list, type, owner, INVALID_STATION, INVALID_ORDER, VLW_STANDARD);
+ n = GenerateVehicleSortList(sort_list, type, owner, (vlw_flag == VLW_STATION_LIST) ? id : INVALID_STATION, (vlw_flag == VLW_SHARED_ORDERS) ? id : INVALID_ORDER, vlw_flag);
/* Send all the vehicles to a depot */
for (i = 0; i < n; i++) {
const Vehicle *v = sort_list[i];
- if (!DoCommand(v->tile, v->index, service, flags, CMD_SEND_TO_DEPOT(type)) && !(flags & DC_EXEC)) {
+ if (!DoCommand(v->tile, v->index, service | DEPOT_DONT_CANCEL, flags, CMD_SEND_TO_DEPOT(type)) && !(flags & DC_EXEC)) {
+ /* At least one vehicle is valid to send the command to, so the mass goto depot is valid. No need to check the rest */
free((void*)sort_list);
return 0;
}