diff options
author | peter1138 <peter1138@openttd.org> | 2008-05-25 11:18:57 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-05-25 11:18:57 +0000 |
commit | f6ea07e7d8ebfebe817eca368df24383887d732a (patch) | |
tree | fbfe014982b14a60a941cd6a1e65c5a7735bc1d7 /src | |
parent | d9805b46b91a16daf53658c6fe37f5568e32e0cc (diff) | |
download | openttd-f6ea07e7d8ebfebe817eca368df24383887d732a.tar.xz |
(svn r13241) -Codechange: Simplify CmdDepotSellAllVehicles() a bit
Diffstat (limited to 'src')
-rw-r--r-- | src/vehicle.cpp | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ae77c96fd..3dd260277 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1051,14 +1051,11 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uin CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) { Vehicle **engines = NULL; - Vehicle **wagons = NULL; uint16 engine_list_length = 0; uint16 engine_count = 0; - uint16 wagon_list_length = 0; - uint16 wagon_count = 0; CommandCost cost(EXPENSES_NEW_VEHICLES); - uint sell_command, total_number_vehicles; + uint sell_command; VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8); switch (vehicle_type) { @@ -1071,25 +1068,14 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uin /* Get the list of vehicles in the depot */ BuildDepotVehicleList(vehicle_type, tile, &engines, &engine_list_length, &engine_count, - &wagons, &wagon_list_length, &wagon_count); - - total_number_vehicles = engine_count + wagon_count; - for (uint i = 0; i < total_number_vehicles; i++) { - const Vehicle *v; - - if (i < engine_count) { - v = engines[i]; - } else { - v = wagons[i - engine_count]; - } - - CommandCost ret = DoCommand(tile, v->index, 1, flags, sell_command); + &engines, &engine_list_length, &engine_count); + for (uint i = 0; i < engine_count; i++) { + CommandCost ret = DoCommand(tile, engines[i]->index, 1, flags, sell_command); if (CmdSucceeded(ret)) cost.AddCost(ret); } free(engines); - free(wagons); if (cost.GetCost() == 0) return CMD_ERROR; // no vehicles to sell return cost; } |