mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
(svn r6242) -Codechange: made BuildVehicleList static as it is not used in any other files anymore
added window_type to arguments and used it to replace an if cascade with a switch case
This commit is contained in:
parent
8f102334ff
commit
2a07ed9d46
@ -119,7 +119,7 @@ void ResortVehicleLists(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID station, OrderID order)
|
static void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID station, OrderID order, uint16 window_type)
|
||||||
{
|
{
|
||||||
const Vehicle** sort_list;
|
const Vehicle** sort_list;
|
||||||
uint subtype = (type != VEH_Aircraft) ? Train_Front : 2;
|
uint subtype = (type != VEH_Aircraft) ? Train_Front : 2;
|
||||||
@ -136,13 +136,13 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
|
|||||||
DEBUG(misc, 1) ("Building vehicle list for player %d station %d...",
|
DEBUG(misc, 1) ("Building vehicle list for player %d station %d...",
|
||||||
owner, station);
|
owner, station);
|
||||||
|
|
||||||
if (station != INVALID_STATION) {
|
switch (window_type) {
|
||||||
|
case VLW_STATION_LIST: {
|
||||||
const Vehicle *v;
|
const Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type == type && (
|
if (v->type == type && (
|
||||||
(type == VEH_Train && IsFrontEngine(v)) ||
|
(type == VEH_Train && IsFrontEngine(v)) ||
|
||||||
(type != VEH_Train && v->subtype <= subtype)
|
(type != VEH_Train && v->subtype <= subtype))) {
|
||||||
)) {
|
|
||||||
const Order *order;
|
const Order *order;
|
||||||
|
|
||||||
FOR_VEHICLE_ORDERS(v, order) {
|
FOR_VEHICLE_ORDERS(v, order) {
|
||||||
@ -153,8 +153,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} break;
|
||||||
if (order != INVALID_ORDER) {
|
|
||||||
|
case VLW_SHARED_ORDERS: {
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
/* Find a vehicle with the order in question */
|
/* Find a vehicle with the order in question */
|
||||||
@ -167,7 +168,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
|
|||||||
sort_list[n++] = v;
|
sort_list[n++] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} break;
|
||||||
|
|
||||||
|
case VLW_STANDARD: {
|
||||||
const Vehicle *v;
|
const Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type == type && v->owner == owner && (
|
if (v->type == type && v->owner == owner && (
|
||||||
@ -176,7 +179,9 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
|
|||||||
sort_list[n++] = v;
|
sort_list[n++] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
|
|
||||||
|
default: NOT_REACHED(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
free((void*)vl->sort_list);
|
free((void*)vl->sort_list);
|
||||||
@ -1227,7 +1232,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
|
|||||||
const StationID station = (window_type == VLW_STATION_LIST) ? GB(w->window_number, 16, 16) : INVALID_STATION;
|
const StationID station = (window_type == VLW_STATION_LIST) ? GB(w->window_number, 16, 16) : INVALID_STATION;
|
||||||
const OrderID order = (window_type == VLW_SHARED_ORDERS) ? GB(w->window_number, 16, 16) : INVALID_ORDER;
|
const OrderID order = (window_type == VLW_SHARED_ORDERS) ? GB(w->window_number, 16, 16) : INVALID_ORDER;
|
||||||
|
|
||||||
BuildVehicleList(vl, vehicle_type, owner, station, order);
|
BuildVehicleList(vl, vehicle_type, owner, station, order, window_type);
|
||||||
SortVehicleList(vl);
|
SortVehicleList(vl);
|
||||||
SetVScrollCount(w, vl->list_length);
|
SetVScrollCount(w, vl->list_length);
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ void InitializeVehiclesGuiList(void);
|
|||||||
void RebuildVehicleLists(void);
|
void RebuildVehicleLists(void);
|
||||||
void ResortVehicleLists(void);
|
void ResortVehicleLists(void);
|
||||||
|
|
||||||
void BuildVehicleList(struct vehiclelist_d* vl, int type, PlayerID, StationID, uint16 order);
|
|
||||||
void SortVehicleList(struct vehiclelist_d *vl);
|
void SortVehicleList(struct vehiclelist_d *vl);
|
||||||
|
|
||||||
#define PERIODIC_RESORT_DAYS 10
|
#define PERIODIC_RESORT_DAYS 10
|
||||||
|
Loading…
Reference in New Issue
Block a user