summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-01-05 16:51:10 +0000
committertron <tron@openttd.org>2006-01-05 16:51:10 +0000
commit9b87635c1f446541dc32bf9275fdbdcddbaf2af9 (patch)
treeb76c3575e24b071c5ff251860338785bbdefa1fe /vehicle_gui.c
parent318fe153eb20f3987c0f4d1792cc25df3ee1ff45 (diff)
downloadopenttd-9b87635c1f446541dc32bf9275fdbdcddbaf2af9.tar.xz
(svn r3366) Make an unnecessarily global variable local
Diffstat (limited to 'vehicle_gui.c')
-rw-r--r--vehicle_gui.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c
index fdaa7fa4f..43fd33976 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -106,15 +106,15 @@ void ResortVehicleLists(void)
void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID station)
{
+ SortStruct* sort_list;
uint subtype = (type != VEH_Aircraft) ? Train_Front : 2;
uint n = 0;
uint i;
if (!(vl->flags & VL_REBUILD)) return;
- /* Create array for sorting */
- _vehicle_sort = realloc(_vehicle_sort, GetVehiclePoolSize() * sizeof(_vehicle_sort[0]));
- if (_vehicle_sort == NULL)
+ sort_list = malloc(GetVehiclePoolSize() * sizeof(sort_list[0]));
+ if (sort_list == NULL)
error("Could not allocate memory for the vehicle-sorting-list");
DEBUG(misc, 1) ("Building vehicle list for player %d station %d...",
@@ -130,8 +130,8 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
FOR_VEHICLE_ORDERS(v, order) {
if (order->type == OT_GOTO_STATION && order->station == station) {
- _vehicle_sort[n].index = v->index;
- _vehicle_sort[n].owner = v->owner;
+ sort_list[n].index = v->index;
+ sort_list[n].owner = v->owner;
++n;
break;
}
@@ -144,8 +144,8 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
if (v->type == type && v->owner == owner && (
(type == VEH_Train && IsFrontEngine(v)) ||
(type != VEH_Train && v->subtype <= subtype))) {
- _vehicle_sort[n].index = v->index;
- _vehicle_sort[n].owner = v->owner;
+ sort_list[n].index = v->index;
+ sort_list[n].owner = v->owner;
++n;
}
}
@@ -157,7 +157,8 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
error("Could not allocate memory for the vehicle-sorting-list");
vl->list_length = n;
- for (i = 0; i < n; ++i) vl->sort_list[i] = _vehicle_sort[i];
+ for (i = 0; i < n; ++i) vl->sort_list[i] = sort_list[i];
+ free(sort_list);
vl->flags &= ~VL_REBUILD;
vl->flags |= VL_RESORT;