summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/vehicle_cmd.cpp17
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