changeset 14897:671004f47e42 draft

(svn r19493) -Codechange: Keep track of last error in CmdDepotSellAllVehicles().
author alberth <alberth@openttd.org>
date Sat, 20 Mar 2010 17:22:15 +0000
parents 67eefe61a8ee
children d4b66296e3f9
files src/vehicle_cmd.cpp
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -187,13 +187,19 @@
 	/* 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;
 }
 
 /**