summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-05-25 17:36:49 +0000
committerpeter1138 <peter1138@openttd.org>2008-05-25 17:36:49 +0000
commit26ee8f3ca10d1d277b5faaa8554b0a8305711664 (patch)
tree585af0ab8754a6ddc1e6ab9103db8c0596ceb05d /src
parentc9ef11159f07664607e7b1acc898b698ebf30a7e (diff)
downloadopenttd-26ee8f3ca10d1d277b5faaa8554b0a8305711664.tar.xz
(svn r13250) -Codechange: Use VehicleList in SendAllVehiclesToDepot()
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 67eed7a0d..e8793a126 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1462,14 +1462,13 @@ void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner
*/
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
{
- const Vehicle **sort_list = NULL;
- uint16 array_length = 0;
+ VehicleList list;
- uint n = GenerateVehicleSortList(&sort_list, &array_length, type, owner, id, vlw_flag);
+ GenerateVehicleSortList(&list, type, owner, id, vlw_flag);
/* Send all the vehicles to a depot */
- for (uint i = 0; i < n; i++) {
- const Vehicle *v = sort_list[i];
+ for (uint i = 0; i < list.Length(); i++) {
+ const Vehicle *v = list[i];
CommandCost ret = DoCommand(v->tile, v->index, (service ? 1 : 0) | DEPOT_DONT_CANCEL, flags, GetCmdSendToDepot(type));
/* Return 0 if DC_EXEC is not set this is a valid goto depot command)
@@ -1477,12 +1476,10 @@ CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service,
* and we will issue the command. We can now safely quit the loop, knowing
* it will succeed at least once. With DC_EXEC we really need to send them to the depot */
if (CmdSucceeded(ret) && !(flags & DC_EXEC)) {
- free((void*)sort_list);
return CommandCost();
}
}
- free((void*)sort_list);
return (flags & DC_EXEC) ? CommandCost() : CMD_ERROR;
}