summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_gui.c7
-rw-r--r--order.h1
-rw-r--r--roadveh_gui.c10
-rw-r--r--ship_gui.c7
-rw-r--r--train_gui.c10
-rw-r--r--vehicle_gui.c93
-rw-r--r--vehicle_gui.h8
7 files changed, 80 insertions, 56 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 245bb4eb0..344af4644 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -1028,12 +1028,13 @@ void ShowPlayerAircraftLocal(PlayerID player, StationID station, OrderID order,
Window *w;
if (show_shared) {
- w = AllocateWindowDescFront(&_player_aircraft_desc, (order << 16) | (VEH_Aircraft << 11) | SHARE_FLAG);
+ w = AllocateWindowDescFront(&_player_aircraft_desc, (order << 16) | (VEH_Aircraft << 11) | VLW_SHARED_ORDERS);
} else {
+ uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
- w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | (VEH_Aircraft << 11) | player);
+ w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | (VEH_Aircraft << 11) | VLW_flag | player);
} else {
- w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | (VEH_Aircraft << 11) | player);
+ w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | (VEH_Aircraft << 11) | VLW_flag | player);
}
}
diff --git a/order.h b/order.h
index cc0bffc18..99c606a89 100644
--- a/order.h
+++ b/order.h
@@ -11,7 +11,6 @@
enum {
INVALID_ORDER = 0xFFFF,
- SHARE_FLAG = 1 << 8,
};
/* Order types */
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 84003ec03..ac3688df0 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -967,14 +967,16 @@ static void ShowPlayerRoadVehiclesLocal(PlayerID player, StationID station, Orde
Window *w;
if (show_shared) {
- w = AllocateWindowDescFront(&_player_roadveh_desc, (order << 16) | (VEH_Road << 11) | SHARE_FLAG);
+ w = AllocateWindowDescFront(&_player_roadveh_desc, (order << 16) | (VEH_Road << 11) | VLW_SHARED_ORDERS);
} else {
- if ( player == _local_player) {
- w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | (VEH_Road << 11) | player);
+ uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
+ if (player == _local_player) {
+ w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | (VEH_Road << 11) | VLW_flag | player);
} else {
- w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | (VEH_Road << 11) | player);
+ w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | (VEH_Road << 11) | VLW_flag | player);
}
}
+
if (w != NULL) {
vehiclelist_d *vl = &WP(w, vehiclelist_d);
vl->flags = VL_REBUILD | (_sorting.roadveh.order << (VL_DESC - 1));
diff --git a/ship_gui.c b/ship_gui.c
index a1b64ee87..57bfddf1d 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -970,12 +970,13 @@ static void ShowPlayerShipsLocal(PlayerID player, StationID station, OrderID ord
Window *w;
if (show_shared) {
- w = AllocateWindowDescFront(&_player_ships_desc, (order << 16) | VEH_Ship << 11 | SHARE_FLAG);
+ w = AllocateWindowDescFront(&_player_ships_desc, (order << 16) | (VEH_Ship << 11) | VLW_SHARED_ORDERS);
} else {
+ uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
- w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | VEH_Ship << 11 | player);
+ w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | (VEH_Ship << 11) | VLW_flag | player);
} else {
- w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | VEH_Ship << 11 | player);
+ w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | (VEH_Ship << 11) | VLW_flag | player);
}
}
diff --git a/train_gui.c b/train_gui.c
index 2aef94fc6..f09feb623 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -1425,14 +1425,16 @@ static void ShowPlayerTrainsLocal(PlayerID player, StationID station, OrderID or
Window *w;
if (show_shared) {
- w = AllocateWindowDescFront(&_player_trains_desc, (order << 16) | (VEH_Train << 11) | SHARE_FLAG);
+ w = AllocateWindowDescFront(&_player_trains_desc, (order << 16) | (VEH_Train << 11) | VLW_SHARED_ORDERS);
} else {
+ uint16 VLW_flag = (station == INVALID_STATION) ? VLW_STANDARD : VLW_STATION_LIST;
if (player == _local_player) {
- w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | (VEH_Train << 11) | player);
- } else {
- w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | (VEH_Train << 11) | player);
+ w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | (VEH_Train << 11) | VLW_flag | player);
+ } else {
+ w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | (VEH_Train << 11) | VLW_flag | player);
}
}
+
if (w != NULL) {
vehiclelist_d *vl = &WP(w, vehiclelist_d);
vl->flags = VL_REBUILD | (_sorting.train.order << (VL_DESC - 1));
diff --git a/vehicle_gui.c b/vehicle_gui.c
index d03529303..1f5ee5b05 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -1207,6 +1207,14 @@ 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)
+ * 8-10 window type (use flags in vehicle_gui.h)
+ * 11-15 vehicle type (using VEH_, but can be compressed to fewer bytes if needed)
+ * 16-31 StationID or OrderID depending on window type (bit 8-10)
+ **/
+
void PlayerVehWndProc(Window *w, WindowEvent *e)
{
vehiclelist_d *vl = &WP(w, vehiclelist_d);
@@ -1221,14 +1229,9 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
int i;
const PlayerID owner = GB(w->window_number, 0, 8);
const Player *p = GetPlayer(owner);
- OrderID order = INVALID_ORDER;
- StationID station = INVALID_STATION;
-
- if (w->window_number & SHARE_FLAG) {
- order = GB(w->window_number, 16, 16);
- } else {
- station = GB(w->window_number, 16, 16);
- }
+ const uint16 window_type = w->window_number & VLW_FLAGS;
+ 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;
BuildVehicleList(vl, vehicle_type, owner, station, order);
SortVehicleList(vl);
@@ -1238,37 +1241,45 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
if (vl->sort_type == SORT_BY_UNSORTED) SETBIT(w->disabled_state, 3);
/* draw the widgets */
- if (order != INVALID_ORDER) {
- /* Shared Orders */
- 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 */
- SetDParam(0, p->name_1);
- SetDParam(1, p->name_2);
- SetDParam(2, w->vscroll.count);
- switch (vehicle_type) {
- case VEH_Train: w->widget[1].unkA = STR_881B_TRAINS; break;
- case VEH_Road: w->widget[1].unkA = STR_9001_ROAD_VEHICLES; break;
- case VEH_Ship: w->widget[1].unkA = STR_9805_SHIPS; break;
- case VEH_Aircraft: w->widget[1].unkA = STR_A009_AIRCRAFT; break;
- default: NOT_REACHED(); break;
- }
- } else {
- /* Station Name */
- SetDParam(0, station);
- SetDParam(1, w->vscroll.count);
- switch (vehicle_type) {
- case VEH_Train: w->widget[1].unkA = STR_SCHEDULED_TRAINS; break;
- case VEH_Road: w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES; break;
- case VEH_Ship: w->widget[1].unkA = STR_SCHEDULED_SHIPS; break;
- case VEH_Aircraft: w->widget[1].unkA = STR_SCHEDULED_AIRCRAFT; break;
- default: NOT_REACHED(); break;
- }
+ switch (window_type) {
+ case VLW_SHARED_ORDERS:
+ /* Shared Orders */
+ 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);
+ break;
+
+ case VLW_STANDARD:
+ /* Company Name */
+ SetDParam(0, p->name_1);
+ SetDParam(1, p->name_2);
+ SetDParam(2, w->vscroll.count);
+ switch (vehicle_type) {
+ case VEH_Train: w->widget[1].unkA = STR_881B_TRAINS; break;
+ case VEH_Road: w->widget[1].unkA = STR_9001_ROAD_VEHICLES; break;
+ case VEH_Ship: w->widget[1].unkA = STR_9805_SHIPS; break;
+ case VEH_Aircraft: w->widget[1].unkA = STR_A009_AIRCRAFT; break;
+ default: NOT_REACHED(); break;
+ }
+ break;
+
+ case VLW_STATION_LIST:
+ /* Station Name */
+ SetDParam(0, station);
+ SetDParam(1, w->vscroll.count);
+ switch (vehicle_type) {
+ case VEH_Train: w->widget[1].unkA = STR_SCHEDULED_TRAINS; break;
+ case VEH_Road: w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES; break;
+ case VEH_Ship: w->widget[1].unkA = STR_SCHEDULED_SHIPS; break;
+ case VEH_Aircraft: w->widget[1].unkA = STR_SCHEDULED_AIRCRAFT; break;
+ default: NOT_REACHED(); break;
+ }
+ break;
+
+ default: NOT_REACHED(); break;
}
DrawWindowWidgets(w);
@@ -1439,9 +1450,9 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */
if (--vl->resort_timer == 0) {
- StationID station = (w->window_number & SHARE_FLAG) ? INVALID_STATION : GB(w->window_number, 16, 16);
+ StationID station = ((w->window_number & VLW_FLAGS) == VLW_STATION_LIST) ? GB(w->window_number, 16, 16) : INVALID_STATION;
PlayerID owner = GB(w->window_number, 0, 8);
- DEBUG(misc, 1) ("Periodic resort ships list player %d station %d", owner, station);
+ DEBUG(misc, 1) ("Periodic resort %d list player %d station %d", vehicle_type, owner, station);
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
vl->flags |= VL_RESORT;
SetWindowDirty(w);
diff --git a/vehicle_gui.h b/vehicle_gui.h
index 3284508f4..5df43c11c 100644
--- a/vehicle_gui.h
+++ b/vehicle_gui.h
@@ -44,6 +44,14 @@ enum {
PLY_WND_PRC__SIZE_OF_ROW_BIG = 36,
};
+/* Vehicle List Window type flags */
+enum {
+ VLW_FLAGS = (1 << 8)|(1 << 9)|(1 << 10),
+ VLW_STANDARD = 0,
+ VLW_SHARED_ORDERS = 1 << 8,
+ VLW_STATION_LIST = 2 << 8,
+};
+
void PlayerVehWndProc(Window *w, WindowEvent *e);
void ShowReplaceVehicleWindow(byte vehicletype);