summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'vehicle_gui.c')
-rw-r--r--vehicle_gui.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 3002df498..9ac1d4e6f 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -115,7 +115,7 @@ void ResortVehicleLists(void)
}
}
-void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID station)
+void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID station, uint16 order)
{
const Vehicle** sort_list;
uint subtype = (type != VEH_Aircraft) ? Train_Front : 2;
@@ -150,13 +150,27 @@ void BuildVehicleList(vehiclelist_d* vl, int type, PlayerID owner, StationID sta
}
}
} else {
- const Vehicle *v;
- FOR_ALL_VEHICLES(v) {
- if (v->type == type && v->owner == owner && (
- (type == VEH_Train && IsFrontEngine(v)) ||
- (type != VEH_Train && v->subtype <= subtype)
- )) {
- sort_list[n++] = v;
+ if (order != INVALID_ORDER) {
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ /* Find a vehicle with the order in question */
+ if (v != NULL && v->orders != NULL && v->orders->index == order) break;
+ }
+
+ if (v != NULL && v->orders != NULL && v->orders->index == order) {
+ /* Only try to make the list if we found a vehicle using the order in question */
+ for (v = GetFirstVehicleFromSharedList(v); v != NULL; v = v->next_shared) {
+ sort_list[n++] = v;
+ }
+ }
+ } else {
+ const Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if (v->type == type && v->owner == owner && (
+ (type == VEH_Train && IsFrontEngine(v)) ||
+ (type != VEH_Train && v->subtype <= subtype))) {
+ sort_list[n++] = v;
+ }
}
}
}