summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_gui.c45
-rw-r--r--gui.h8
-rw-r--r--lang/english.txt3
-rw-r--r--order.h4
-rw-r--r--order_gui.c50
-rw-r--r--roadveh_gui.c44
-rw-r--r--ship_gui.c50
-rw-r--r--train_gui.c44
-rw-r--r--vehicle_gui.c30
-rw-r--r--vehicle_gui.h2
10 files changed, 213 insertions, 67 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 4c4425e34..4134a2e89 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -1005,7 +1005,10 @@ static const Widget _other_player_aircraft_widgets[] = {
static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
{
- StationID station = GB(w->window_number, 16, 16);
+ uint16 order = GB(w->window_number, 16, 16);
+ /* Sorting a shared order list relies on station being set to INVALID_STATION */
+ /* If station is not INVALID_STATION, then order is never used and we don't care what it contains */
+ StationID station = HASBIT(w->window_number, 8) ? INVALID_STATION : order;
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
@@ -1016,9 +1019,8 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
int max;
int i;
- BuildVehicleList(vl, VEH_Aircraft, owner, station);
+ BuildVehicleList(vl, VEH_Aircraft, owner, station, order);
SortVehicleList(vl);
-
SetVScrollCount(w, vl->list_length);
// disable 'Sort By' tooltip on Unsorted sorting criteria
@@ -1027,7 +1029,15 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
/* draw the widgets */
{
const Player *p = GetPlayer(owner);
- if (station == INVALID_STATION) {
+ if (order != INVALID_ORDER) {
+ /* Shared Orders -- (###) Aircraft */
+ SetDParam(0, w->vscroll.count);
+ w->widget[1].unkA = STR_VEH_WITH_SHARED_ORDERS_LIST;
+ w->widget[9].unkA = STR_EMPTY;
+ w->widget[10].unkA = STR_EMPTY;
+ SETBIT(w->disabled_state, 9);
+ SETBIT(w->disabled_state, 10);
+ } else if (station == INVALID_STATION) {
/* Company Name -- (###) Aircraft */
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
@@ -1180,20 +1190,35 @@ static const WindowDesc _other_player_aircraft_desc = {
PlayerAircraftWndProc
};
-void ShowPlayerAircraft(PlayerID player, StationID station)
+void ShowPlayerAircraftLocal(PlayerID player, StationID station, uint16 order, bool show_shared)
{
Window *w;
- if (player == _local_player) {
- w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | player);
- } else {
- w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | player);
+ if (show_shared) {
+ w = AllocateWindowDescFront(&_player_aircraft_desc, (order << 16) | (1 << 8));
+ } else {
+ if (player == _local_player) {
+ w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | player);
+ } else {
+ w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | player);
+ }
}
if (w != NULL) {
- w->caption_color = w->window_number;
+ w->caption_color = player;
w->vscroll.cap = 4;
w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG;
}
}
+
+void ShowPlayerAircraft(PlayerID player, StationID station)
+{
+ ShowPlayerAircraftLocal(player, station, INVALID_ORDER, false);
+}
+
+void ShowVehWithSharedOrdersAircraft(Vehicle *v)
+{
+ if (v->orders == NULL) return; // no shared list to show
+ShowPlayerAircraftLocal(v->owner, INVALID_STATION, v->orders->index, true);
+}
diff --git a/gui.h b/gui.h
index 37c7aa229..39979d779 100644
--- a/gui.h
+++ b/gui.h
@@ -43,23 +43,25 @@ void PlaceProc_BuyLand(TileIndex tile);
void ShowPlayerTrains(PlayerID player, StationID station);
void ShowTrainViewWindow(const Vehicle *v);
void ShowOrdersWindow(const Vehicle *v);
-
-void ShowRoadVehViewWindow(const Vehicle *v);
+void ShowVehWithSharedOrdersTrains(Vehicle *v);
/* road_gui.c */
void ShowBuildRoadToolbar(void);
void ShowBuildRoadScenToolbar(void);
void ShowPlayerRoadVehicles(PlayerID player, StationID station);
+void ShowVehWithSharedOrdersRoadVehicles(Vehicle *v);
+void ShowRoadVehViewWindow(const Vehicle *v);
/* dock_gui.c */
void ShowBuildDocksToolbar(void);
void ShowPlayerShips(PlayerID player, StationID station);
-
+void ShowVehWithSharedOrdersShips(Vehicle *v);
void ShowShipViewWindow(const Vehicle *v);
/* aircraft_gui.c */
void ShowBuildAirToolbar(void);
void ShowPlayerAircraft(PlayerID player, StationID station);
+void ShowVehWithSharedOrdersAircraft(Vehicle *v);
/* terraform_gui.c */
void ShowTerraformToolbar(void);
diff --git a/lang/english.txt b/lang/english.txt
index c4ede5b9e..442a65334 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -2852,6 +2852,9 @@ STR_SCHEDULED_ROAD_VEHICLES_TIP :{BLACK}Show all
STR_SCHEDULED_AIRCRAFT_TIP :{BLACK}Show all aircraft which have this station on their schedule
STR_SCHEDULED_SHIPS_TIP :{BLACK}Show all ships which have this station on their schedule
+STR_VEH_WITH_SHARED_ORDERS_LIST :{WHITE}Shared orders of {COMMA} Vehicle{P "" s}
+STR_VEH_WITH_SHARED_ORDERS_LIST_TIP :{BLACK}Show all vehicles which have the same schedule
+
STR_REPLACE_VEHICLES :{BLACK}Replace Vehicles
STR_REPLACE_VEHICLES_WHITE :{WHITE}Replace {STRING}
STR_REPLACE_VEHICLES_START :{BLACK}Start Replacing Vehicles
diff --git a/order.h b/order.h
index 05107b25e..f60a6b2ac 100644
--- a/order.h
+++ b/order.h
@@ -9,6 +9,10 @@
#include "macros.h"
#include "pool.h"
+enum {
+ INVALID_ORDER = 0xFFFF,
+};
+
/* Order types */
typedef enum OrderTypes {
OT_NOTHING = 0,
diff --git a/order_gui.c b/order_gui.c
index 10aba4f2b..b2f8eaee6 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -70,11 +70,22 @@ static void DrawOrdersWindow(Window *w)
1 << 10 //transfer
);
- if (v->type != VEH_Train)
- SETBIT(w->disabled_state, 6); //disable non-stop for non-trains
+ if (v->type != VEH_Train) {
+ SETBIT(w->disabled_state, 6); // Disable non-stop for non-trains
+ switch (v->type) {
+ case VEH_Road: w->widget[11].unkA = STR_LORRY; break;
+ case VEH_Ship: w->widget[11].unkA = STR_SHIP; break;
+ case VEH_Aircraft: w->widget[11].unkA = STR_PLANE; break;
+ default: NOT_REACHED(); break;
+ }
+ }
shared_orders = IsOrderListShared(v);
+ if (!shared_orders || v->orders == NULL) {
+ SETBIT(w->disabled_state, 11); // Disable list of vehicles with the same shared orders if there are no list
+ }
+
if ((uint)v->num_orders + (shared_orders?1:0) <= (uint)WP(w,order_d).sel)
SETBIT(w->disabled_state, 5); /* delete */
@@ -451,6 +462,15 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
case 10: /* transfer button */
OrderClick_Transfer(w, v);
break;
+ case 11: /* Vehicle with same shared Orders button */
+ switch (v->type) {
+ case VEH_Train: ShowVehWithSharedOrdersTrains(v); break;
+ case VEH_Road: ShowVehWithSharedOrdersRoadVehicles(v); break;
+ case VEH_Ship: ShowVehWithSharedOrdersShips(v); break;
+ case VEH_Aircraft: ShowVehWithSharedOrdersAircraft(v); break;
+ default: NOT_REACHED(); break;
+ }
+ break;
}
} break;
@@ -516,9 +536,9 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
static const Widget _orders_train_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 384, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_PANEL, RESIZE_RB, 14, 0, 372, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
-{ WWT_SCROLLBAR, RESIZE_LRB, 14, 373, 384, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 398, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_PANEL, RESIZE_RB, 14, 0, 386, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
+{ WWT_SCROLLBAR, RESIZE_LRB, 14, 387, 398, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 52, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 53, 105, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 106, 158, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER},
@@ -526,13 +546,14 @@ static const Widget _orders_train_widgets[] = {
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 212, 264, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 265, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 320, 372, 76, 87, STR_886F_TRANSFER, STR_886D_MAKE_THE_HIGHLIGHTED_ORDER},
-{ WWT_PANEL, RESIZE_RTB, 14, 373, 372, 76, 87, 0x0, STR_NULL},
-{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 373, 384, 76, 87, 0x0, STR_RESIZE_BUTTON},
+{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 373, 386, 76, 87, STR_TRAIN, STR_VEH_WITH_SHARED_ORDERS_LIST_TIP},
+{ WWT_PANEL, RESIZE_RTB, 14, 387, 386, 76, 87, 0x0, STR_NULL},
+{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 387, 398, 76, 87, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const WindowDesc _orders_train_desc = {
- -1,-1, 385, 88,
+ -1,-1, 399, 88,
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
_orders_train_widgets,
@@ -541,9 +562,9 @@ static const WindowDesc _orders_train_desc = {
static const Widget _orders_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 395, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_PANEL, RESIZE_RB, 14, 0, 383, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
-{ WWT_SCROLLBAR, RESIZE_LRB, 14, 384, 395, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 409, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_PANEL, RESIZE_RB, 14, 0, 397, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
+{ WWT_SCROLLBAR, RESIZE_LRB, 14, 398, 409, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 64, 128, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED},
{ WWT_EMPTY, RESIZE_TB, 14, 0, 0, 76, 87, 0x0, 0x0},
@@ -551,13 +572,14 @@ static const Widget _orders_widgets[] = {
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 193, 256, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 257, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 320, 383, 76, 87, STR_886F_TRANSFER, STR_886D_MAKE_THE_HIGHLIGHTED_ORDER},
-{ WWT_PANEL, RESIZE_RTB, 14, 384, 383, 76, 87, 0x0, STR_NULL},
-{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 384, 395, 76, 87, 0x0, STR_RESIZE_BUTTON},
+{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 384, 397, 76, 87, STR_EMPTY, STR_VEH_WITH_SHARED_ORDERS_LIST_TIP},
+{ WWT_PANEL, RESIZE_RTB, 14, 397, 396, 76, 87, 0x0, STR_NULL},
+{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 398, 409, 76, 87, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const WindowDesc _orders_desc = {
- -1,-1, 396, 88,
+ -1,-1, 410, 88,
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
_orders_widgets,
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 6fe3c1333..a60d5d125 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -943,7 +943,10 @@ static const Widget _other_player_roadveh_widgets[] = {
static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
{
- StationID station = GB(w->window_number, 16, 16);
+ uint16 order = GB(w->window_number, 16, 16);
+ /* Sorting a shared order list relies on station being set to INVALID_STATION */
+ /* If station is not INVALID_STATION, then order is never used and we don't care what it contains */
+ StationID station = HASBIT(w->window_number, 8) ? INVALID_STATION : order;
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
@@ -954,18 +957,24 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
int max;
int i;
- BuildVehicleList(vl, VEH_Road, owner, station);
+ BuildVehicleList(vl, VEH_Road, owner, station, order);
SortVehicleList(vl);
-
SetVScrollCount(w, vl->list_length);
// disable 'Sort By' tooltip on Unsorted sorting criteria
if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3);
/* draw the widgets */
- if (station == INVALID_STATION) {
+ if (order != INVALID_ORDER) {
+ /* Shared Orders -- (##) Road vehicles */
+ SetDParam(0, w->vscroll.count);
+ w->widget[1].unkA = STR_VEH_WITH_SHARED_ORDERS_LIST;
+ w->widget[9].unkA = STR_EMPTY;
+ w->widget[10].unkA = STR_EMPTY;
+ SETBIT(w->disabled_state, 9);
+ SETBIT(w->disabled_state, 10);
+ } else if (station == INVALID_STATION) {
const Player *p = GetPlayer(owner);
-
/* Company Name -- (###) Road vehicles */
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
@@ -1115,14 +1124,18 @@ static const WindowDesc _other_player_roadveh_desc = {
};
-void ShowPlayerRoadVehicles(PlayerID player, StationID station)
+static void ShowPlayerRoadVehiclesLocal(PlayerID player, StationID station, uint16 order, bool show_shared)
{
Window *w;
- if ( player == _local_player) {
- w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | player);
- } else {
- w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | player);
+ if (show_shared) {
+ w = AllocateWindowDescFront(&_player_roadveh_desc, (order << 16) | (1 << 8));
+ } else {
+ if ( player == _local_player) {
+ w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | player);
+ } else {
+ w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | player);
+ }
}
if (w != NULL) {
w->caption_color = player;
@@ -1132,3 +1145,14 @@ void ShowPlayerRoadVehicles(PlayerID player, StationID station)
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */
}
}
+
+void ShowPlayerRoadVehicles(PlayerID player, StationID station)
+{
+ ShowPlayerRoadVehiclesLocal(player, station, 0, false);
+}
+
+void ShowVehWithSharedOrdersRoadVehicles(Vehicle *v)
+{
+ if (v->orders == NULL) return; // no shared list to show
+ ShowPlayerRoadVehiclesLocal(v->owner, INVALID_STATION, v->orders->index, true);
+}
diff --git a/ship_gui.c b/ship_gui.c
index faac96a0b..842a57c0f 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -952,7 +952,10 @@ static const Widget _other_player_ships_widgets[] = {
static void PlayerShipsWndProc(Window *w, WindowEvent *e)
{
- StationID station = GB(w->window_number, 16, 16);
+ uint16 order = GB(w->window_number, 16, 16);
+ /* Sorting a shared order list relies on station being set to INVALID_STATION */
+ /* If station is not INVALID_STATION, then order is never used and we don't care what it contains */
+ StationID station = HASBIT(w->window_number, 8) ? INVALID_STATION : order;
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
@@ -963,9 +966,8 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
int max;
int i;
- BuildVehicleList(vl, VEH_Ship, owner, station);
+ BuildVehicleList(vl, VEH_Ship, owner, station, order);
SortVehicleList(vl);
-
SetVScrollCount(w, vl->list_length);
// disable 'Sort By' tooltip on Unsorted sorting criteria
@@ -975,14 +977,22 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
/* draw the widgets */
{
const Player *p = GetPlayer(owner);
- if (station == INVALID_STATION) {
- /* Company Name -- (###) Trains */
+ if (order != INVALID_ORDER) {
+ /* Shared Orders -- (###) Ships */
+ SetDParam(0, w->vscroll.count);
+ w->widget[1].unkA = STR_VEH_WITH_SHARED_ORDERS_LIST;
+ w->widget[9].unkA = STR_EMPTY;
+ w->widget[10].unkA = STR_EMPTY;
+ SETBIT(w->disabled_state, 9);
+ SETBIT(w->disabled_state, 10);
+ } else if (station == INVALID_STATION) {
+ /* Company Name -- (###) Ships */
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
SetDParam(2, w->vscroll.count);
w->widget[1].unkA = STR_9805_SHIPS;
} else {
- /* Station Name -- (###) Trains */
+ /* Station Name -- (###) Ships */
SetDParam(0, station);
SetDParam(1, w->vscroll.count);
w->widget[1].unkA = STR_SCHEDULED_SHIPS;
@@ -1128,19 +1138,35 @@ static const WindowDesc _other_player_ships_desc = {
};
-void ShowPlayerShips(PlayerID player, StationID station)
+static void ShowPlayerShipsLocal(PlayerID player, StationID station, uint16 order, bool show_shared)
{
Window *w;
- if (player == _local_player) {
- w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | player);
- } else {
- w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player);
+ if (show_shared) {
+ w = AllocateWindowDescFront(&_player_ships_desc, (order << 16) | (1 << 8));
+ } else {
+ if (player == _local_player) {
+ w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | player);
+ } else {
+ w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player);
+ }
}
+
if (w != NULL) {
- w->caption_color = w->window_number;
+ w->caption_color = player;
w->vscroll.cap = 4;
w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG;
}
}
+
+void ShowPlayerShips(PlayerID player, StationID station)
+{
+ ShowPlayerShipsLocal(player, station, 0, false);
+}
+
+void ShowVehWithSharedOrdersShips(Vehicle *v)
+{
+ if (v->orders == NULL) return; // no shared list to show
+ ShowPlayerShipsLocal(v->owner, INVALID_STATION, v->orders->index, true);
+}
diff --git a/train_gui.c b/train_gui.c
index 92e8cbba5..04e92e56f 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -1402,7 +1402,10 @@ static const Widget _other_player_trains_widgets[] = {
static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
{
- StationID station = GB(w->window_number, 16, 16);
+ uint16 order = GB(w->window_number, 16, 16);
+ /* Sorting a shared order list relies on station being set to INVALID_STATION */
+ /* If station is not INVALID_STATION, then order is never used and we don't care what it contains */
+ StationID station = HASBIT(w->window_number, 8) ? INVALID_STATION : order;
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
@@ -1413,9 +1416,8 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
int max;
int i;
- BuildVehicleList(vl, VEH_Train, owner, station);
+ BuildVehicleList(vl, VEH_Train, owner, station, order);
SortVehicleList(vl);
-
SetVScrollCount(w, vl->list_length);
// disable 'Sort By' tooltip on Unsorted sorting criteria
@@ -1423,8 +1425,16 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
/* draw the widgets */
{
- const Player *p = GetPlayer(owner);
- if (station == INVALID_STATION) {
+ if (order != INVALID_ORDER) {
+ /* Shared Orders -- (###) Trains */
+ SetDParam(0, w->vscroll.count);
+ w->widget[1].unkA = STR_VEH_WITH_SHARED_ORDERS_LIST;
+ w->widget[9].unkA = STR_EMPTY;
+ w->widget[10].unkA = STR_EMPTY;
+ SETBIT(w->disabled_state, 9);
+ SETBIT(w->disabled_state, 10);
+ } else if (station == INVALID_STATION) {
+ const Player *p = GetPlayer(owner);
/* Company Name -- (###) Trains */
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
@@ -1577,14 +1587,18 @@ static const WindowDesc _other_player_trains_desc = {
PlayerTrainsWndProc
};
-void ShowPlayerTrains(PlayerID player, StationID station)
+static void ShowPlayerTrainsLocal(PlayerID player, StationID station, uint16 order, bool show_shared)
{
Window *w;
- if (player == _local_player) {
- w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | player);
+ if (show_shared) {
+ w = AllocateWindowDescFront(&_player_trains_desc, (order << 16) | (1 << 8));
} else {
- w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player);
+ if (player == _local_player) {
+ w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | player);
+ } else {
+ w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player);
+ }
}
if (w != NULL) {
w->caption_color = player;
@@ -1596,3 +1610,15 @@ void ShowPlayerTrains(PlayerID player, StationID station)
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */
}
}
+
+void ShowPlayerTrains(PlayerID player, StationID station)
+{
+ ShowPlayerTrainsLocal(player, station, INVALID_ORDER, false);
+}
+
+void ShowVehWithSharedOrdersTrains(Vehicle *v)
+{
+ if (v->orders == NULL) return; // no shared list to show
+
+ ShowPlayerTrainsLocal(v->owner, INVALID_STATION, v->orders->index, true);
+}
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;
+ }
}
}
}
diff --git a/vehicle_gui.h b/vehicle_gui.h
index e6f0241e6..3f60527db 100644
--- a/vehicle_gui.h
+++ b/vehicle_gui.h
@@ -16,7 +16,7 @@ void InitializeVehiclesGuiList(void);
void RebuildVehicleLists(void);
void ResortVehicleLists(void);
-void BuildVehicleList(struct vehiclelist_d* vl, int type, PlayerID, StationID);
+void BuildVehicleList(struct vehiclelist_d* vl, int type, PlayerID, StationID, uint16 order);
void SortVehicleList(struct vehiclelist_d *vl);
#define PERIODIC_RESORT_DAYS 10