summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-03-20 17:22:15 +0000
committeralberth <alberth@openttd.org>2010-03-20 17:22:15 +0000
commita901ab53925857a3f6ae70a045a9f0ec6362107e (patch)
tree970f1f5a3f25bde15a5e374d647a6a3df90a63d2
parent66a2a84035d1dfccf608f6efd7e2aa4913c973b8 (diff)
downloadopenttd-a901ab53925857a3f6ae70a045a9f0ec6362107e.tar.xz
(svn r19493) -Codechange: Keep track of last error in CmdDepotSellAllVehicles().
-rw-r--r--src/vehicle_cmd.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index d42467c92..87cad761c 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -187,13 +187,19 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32
/* Get the list of vehicles in the depot */
BuildDepotVehicleList(vehicle_type, tile, &list, &list);
+ CommandCost last_error = CMD_ERROR;
+ bool had_success = false;
for (uint i = 0; i < list.Length(); i++) {
CommandCost ret = DoCommand(tile, list[i]->index, 1, flags, sell_command);
- if (ret.Succeeded()) cost.AddCost(ret);
+ if (ret.Succeeded()) {
+ cost.AddCost(ret);
+ had_success = true;
+ } else {
+ last_error = ret;
+ }
}
- if (cost.GetCost() == 0) return CMD_ERROR; // no vehicles to sell
- return cost;
+ return had_success ? cost : last_error;
}
/**