From a901ab53925857a3f6ae70a045a9f0ec6362107e Mon Sep 17 00:00:00 2001 From: alberth Date: Sat, 20 Mar 2010 17:22:15 +0000 Subject: (svn r19493) -Codechange: Keep track of last error in CmdDepotSellAllVehicles(). --- src/vehicle_cmd.cpp | 12 +++++++++--- 1 file 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; } /** -- cgit v1.2.3-70-g09d2