diff options
author | alberth <alberth@openttd.org> | 2010-03-20 17:10:14 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-03-20 17:10:14 +0000 |
commit | 8b785ccb8a009a7e3a2378fda68cf0844a90502a (patch) | |
tree | 32ca9ab83d9a9ce9b47da8133f6636c361f9d4b3 /src | |
parent | c9b0e9d25f444f628d1f88f177fee062f7ef95c4 (diff) | |
download | openttd-8b785ccb8a009a7e3a2378fda68cf0844a90502a.tar.xz |
(svn r19489) -Codechange: Introduce a had_success variable in SendAllVehiclesToDepot().
Diffstat (limited to 'src')
-rw-r--r-- | src/vehicle_cmd.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 974b83bab..d42467c92 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -586,20 +586,23 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool s GenerateVehicleSortList(&list, type, owner, id, vlw_flag); /* Send all the vehicles to a depot */ + bool had_success = false; for (uint i = 0; i < list.Length(); i++) { const Vehicle *v = list[i]; CommandCost ret = DoCommand(v->tile, v->index, (service ? 1 : 0) | DEPOT_DONT_CANCEL, flags, GetCmdSendToDepot(type)); - /* Return 0 if DC_EXEC is not set this is a valid goto depot command) - * In this case we know that at least one vehicle can be sent to a depot - * and we will issue the command. We can now safely quit the loop, knowing - * it will succeed at least once. With DC_EXEC we really need to send them to the depot */ - if (ret.Succeeded() && !(flags & DC_EXEC)) { - return CommandCost(); + if (ret.Succeeded()) { + had_success = true; + + /* Return 0 if DC_EXEC is not set this is a valid goto depot command) + * In this case we know that at least one vehicle can be sent to a depot + * and we will issue the command. We can now safely quit the loop, knowing + * it will succeed at least once. With DC_EXEC we really need to send them to the depot */ + if (!(flags & DC_EXEC)) break; } } - return (flags & DC_EXEC) ? CommandCost() : CMD_ERROR; + return had_success ? CommandCost() : CMD_ERROR; } /** Give a custom name to your vehicle |