mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
(svn r19493) -Codechange: Keep track of last error in CmdDepotSellAllVehicles().
This commit is contained in:
parent
66a2a84035
commit
a901ab5392
@ -187,13 +187,19 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32
|
|||||||
/* Get the list of vehicles in the depot */
|
/* Get the list of vehicles in the depot */
|
||||||
BuildDepotVehicleList(vehicle_type, tile, &list, &list);
|
BuildDepotVehicleList(vehicle_type, tile, &list, &list);
|
||||||
|
|
||||||
|
CommandCost last_error = CMD_ERROR;
|
||||||
|
bool had_success = false;
|
||||||
for (uint i = 0; i < list.Length(); i++) {
|
for (uint i = 0; i < list.Length(); i++) {
|
||||||
CommandCost ret = DoCommand(tile, list[i]->index, 1, flags, sell_command);
|
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 had_success ? cost : last_error;
|
||||||
return cost;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user