summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_gui.c4
-rw-r--r--roadveh_gui.c4
-rw-r--r--ship_gui.c4
-rw-r--r--train_gui.c4
-rw-r--r--vehicle_gui.c69
5 files changed, 31 insertions, 54 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 344af4644..b74047bc8 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -975,7 +975,7 @@ void DrawSmallOrderListAircraft(const Vehicle *v, int x, int y)
}
-const Widget _player_aircraft_widgets[] = {
+static const Widget _player_aircraft_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS },
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON },
@@ -1028,7 +1028,7 @@ void ShowPlayerAircraftLocal(PlayerID player, StationID station, OrderID order,
Window *w;
if (show_shared) {
- w = AllocateWindowDescFront(&_player_aircraft_desc, (order << 16) | (VEH_Aircraft << 11) | VLW_SHARED_ORDERS);
+ w = AllocateWindowDescFront(&_player_aircraft_desc, (order << 16) | (VEH_Aircraft << 11) | VLW_SHARED_ORDERS | player);
} else {
uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
diff --git a/roadveh_gui.c b/roadveh_gui.c
index ac3688df0..56e96dfd2 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -912,7 +912,7 @@ void ShowRoadDepotWindow(TileIndex tile)
}
}
-const Widget _player_roadveh_widgets[] = {
+static const Widget _player_roadveh_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
@@ -967,7 +967,7 @@ static void ShowPlayerRoadVehiclesLocal(PlayerID player, StationID station, Orde
Window *w;
if (show_shared) {
- w = AllocateWindowDescFront(&_player_roadveh_desc, (order << 16) | (VEH_Road << 11) | VLW_SHARED_ORDERS);
+ w = AllocateWindowDescFront(&_player_roadveh_desc, (order << 16) | (VEH_Road << 11) | VLW_SHARED_ORDERS | player);
} else {
uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
diff --git a/ship_gui.c b/ship_gui.c
index 57bfddf1d..d2e5dde14 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -916,7 +916,7 @@ void DrawSmallOrderListShip(const Vehicle *v, int x, int y)
}
-const Widget _player_ships_widgets[] = {
+static const Widget _player_ships_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
@@ -970,7 +970,7 @@ static void ShowPlayerShipsLocal(PlayerID player, StationID station, OrderID ord
Window *w;
if (show_shared) {
- w = AllocateWindowDescFront(&_player_ships_desc, (order << 16) | (VEH_Ship << 11) | VLW_SHARED_ORDERS);
+ w = AllocateWindowDescFront(&_player_ships_desc, (order << 16) | (VEH_Ship << 11) | VLW_SHARED_ORDERS | player);
} else {
uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
diff --git a/train_gui.c b/train_gui.c
index f09feb623..eaa1e0b21 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -1372,7 +1372,7 @@ static void ShowTrainDetailsWindow(const Vehicle *v)
WP(w,traindetails_d).tab = 0;
}
-const Widget _player_trains_widgets[] = {
+static const Widget _player_trains_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 312, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, 14, 313, 324, 0, 13, 0x0, STR_STICKY_BUTTON},
@@ -1425,7 +1425,7 @@ static void ShowPlayerTrainsLocal(PlayerID player, StationID station, OrderID or
Window *w;
if (show_shared) {
- w = AllocateWindowDescFront(&_player_trains_desc, (order << 16) | (VEH_Train << 11) | VLW_SHARED_ORDERS);
+ w = AllocateWindowDescFront(&_player_trains_desc, (order << 16) | (VEH_Train << 11) | VLW_SHARED_ORDERS | player);
} else {
uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 3462b512b..2b3e3131b 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -1202,11 +1202,6 @@ void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v)
}
}
-extern const Widget _player_ships_widgets[];
-extern const Widget _player_aircraft_widgets[];
-extern const Widget _player_roadveh_widgets[];
-extern const Widget _player_trains_widgets[];
-
/*
* bitmask for w->window_number
* 0-7 PlayerID (owner)
@@ -1247,13 +1242,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
if (vl->list_length == 0) {
/* The list is empty, so the last vehicle is sold or crashed */
/* Delete the window because the order is now not in use anymore */
- switch (vehicle_type) {
- case VEH_Train: DeleteWindowById(WC_TRAINS_LIST, w->window_number); break;
- case VEH_Road: DeleteWindowById(WC_ROADVEH_LIST, w->window_number); break;
- case VEH_Ship: DeleteWindowById(WC_SHIPS_LIST, w->window_number); break;
- case VEH_Aircraft: DeleteWindowById(WC_AIRCRAFT_LIST, w->window_number); break;
- default: NOT_REACHED(); break;
- }
+ DeleteWindow(w);
return;
}
SetDParam(0, w->vscroll.count);
@@ -1403,48 +1392,36 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
}
} break;
- case 9: { /* Build new Vehicle */
- const uint16 window_type = w->window_number & VLW_FLAGS;
-
- if (window_type == VLW_SHARED_ORDERS) {
- const Vehicle *v;
- assert(vl->list_length != 0);
- v = vl->sort_list[0];
- DoCommandP(v->tile, v->index, _ctrl_pressed ? 3 : 2, NULL, CMD_SEND_TO_DEPOT(vehicle_type));
- break;
- }
+ case 9: /* Left button */
+ if (GB(w->window_number, 0, 8) /* OwnerID */ != _local_player) break;
- switch (vehicle_type) {
- case VEH_Train:
- assert(IsWindowOfPrototype(w, _player_trains_widgets));
- ShowBuildTrainWindow(0);
- break;
- case VEH_Road:
- assert(IsWindowOfPrototype(w, _player_roadveh_widgets));
- ShowBuildRoadVehWindow(0);
- break;
- case VEH_Ship:
- assert(IsWindowOfPrototype(w, _player_ships_widgets));
- ShowBuildShipWindow(0);
- break;
- case VEH_Aircraft:
- assert(IsWindowOfPrototype(w, _player_aircraft_widgets));
- ShowBuildAircraftWindow(0);
+ switch (w->window_number & VLW_FLAGS) {
+ case VLW_SHARED_ORDERS: {
+ /* Send to depot */
+ const Vehicle *v;
+ assert(vl->list_length != 0);
+ v = vl->sort_list[0];
+ DoCommandP(v->tile, v->index, _ctrl_pressed ? 3 : 2, NULL, CMD_SEND_TO_DEPOT(vehicle_type));
break;
+ }
+ case VLW_STANDARD:
+ case VLW_STATION_LIST:
+ /* Build new Vehicle */
+ switch (vehicle_type) {
+ case VEH_Train: ShowBuildTrainWindow(0); break;
+ case VEH_Road: ShowBuildRoadVehWindow(0); break;
+ case VEH_Ship: ShowBuildShipWindow(0); break;
+ case VEH_Aircraft: ShowBuildAircraftWindow(0); break;
+ default: NOT_REACHED(); break;
+ }
+ break;
default: NOT_REACHED(); break;
}
break;
- }
-
- case 10: {
- if (vehicle_type == VEH_Train && !IsWindowOfPrototype(w, _player_trains_widgets)) break;
- if (vehicle_type == VEH_Road && !IsWindowOfPrototype(w, _player_roadveh_widgets)) break;
- if (vehicle_type == VEH_Ship && !IsWindowOfPrototype(w, _player_ships_widgets)) break;
- if (vehicle_type == VEH_Aircraft && !IsWindowOfPrototype(w, _player_aircraft_widgets)) break;
+ case 10: /* Right button */
ShowReplaceVehicleWindow(vehicle_type);
break;
- }
}
} break;