Changeset - r14887:9be0a7fee8be
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2010-03-20 17:22:15
alberth@openttd.org
(svn r19493) -Codechange: Keep track of last error in CmdDepotSellAllVehicles().
1 file changed with 9 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/vehicle_cmd.cpp
Show inline comments
 
@@ -187,13 +187,19 @@ CommandCost CmdDepotSellAllVehicles(Tile
 
	/* 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;
 
}
 

	
 
/**
0 comments (0 inline, 0 general)