summaryrefslogtreecommitdiff
path: root/vehicle_gui.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-08-26 22:28:40 +0000
committerbjarni <bjarni@openttd.org>2006-08-26 22:28:40 +0000
commitd576f799d5331cd22546cc555d210ab21e141fa1 (patch)
tree411f8a92fd3e71e7b66b7681f622b6b263916272 /vehicle_gui.c
parent5a763f32a5e513f9d98b3c08622207f9f0b74fce (diff)
downloadopenttd-d576f799d5331cd22546cc555d210ab21e141fa1.tar.xz
(svn r6161) -Feature: List of vehicles with the same shared orders
the list is available in the orders window and looks like the list buttons from the station windows (small vehicle) The button is disabled if the vehicle do not have any shared orders or it got shared orders, but an empty order list based on a patch by nycom, thought it ended up getting heavily modified Thanks to TrueLight for proofreading and suggestions
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;
+ }
}
}
}