--- a/src/vehicle_gui.cpp Wed Jun 13 11:17:30 2007 +0000
+++ b/src/vehicle_gui.cpp Wed Jun 13 11:45:14 2007 +0000
@@ -31,6 +31,7 @@
#include "depot.h"
#include "helpers.hpp"
#include "cargotype.h"
+#include "group.h"
struct Sorting {
Listing aircraft;
@@ -41,15 +42,6 @@
static Sorting _sorting;
-struct vehiclelist_d {
- const Vehicle** sort_list; // List of vehicles (sorted)
- Listing *_sorting; // pointer to the appropiate subcategory of _sorting
- uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for
- byte vehicle_type; // The vehicle type that is sorted
- list_d l; // General list struct
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
-
static bool _internal_sort_order; // descending/ascending
typedef int CDECL VehicleSortListingTypeFunction(const void*, const void*);
@@ -78,7 +70,7 @@
&VehicleValueSorter,
};
-static const StringID _vehicle_sort_listing[] = {
+const StringID _vehicle_sort_listing[] = {
STR_SORT_BY_NUMBER,
STR_SORT_BY_DROPDOWN_NAME,
STR_SORT_BY_AGE,
@@ -134,7 +126,7 @@
}
}
-static void BuildVehicleList(vehiclelist_d* vl, PlayerID owner, uint16 index, uint16 window_type)
+void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type)
{
if (!(vl->l.flags & VL_REBUILD)) return;
@@ -146,7 +138,7 @@
vl->l.flags |= VL_RESORT;
}
-static void SortVehicleList(vehiclelist_d *vl)
+void SortVehicleList(vehiclelist_d *vl)
{
if (!(vl->l.flags & VL_RESORT)) return;
@@ -377,6 +369,7 @@
int command = 0;
switch (v->type) {
+ default: NOT_REACHED();
case VEH_TRAIN: command = CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE); break;
case VEH_ROAD: command = CMD_REFIT_ROAD_VEH | CMD_MSG(STR_REFIT_ROAD_VEHICLE_CAN_T); break;
case VEH_SHIP: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break;
@@ -748,16 +741,6 @@
}
}
-/*
- * Start of functions regarding vehicle list windows
- */
-
-enum {
- PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
- PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
- PLY_WND_PRC__SIZE_OF_ROW_BIG = 36,
-};
-
enum VehicleListWindowWidgets {
VLW_WIDGET_CLOSEBOX = 0,
VLW_WIDGET_CAPTION,
@@ -808,7 +791,7 @@
uint16 window_type = w->window_number & VLW_MASK;
PlayerID player = (PlayerID)GB(w->window_number, 0, 8);
- vl->vehicle_type = GB(w->window_number, 11, 5);
+ vl->vehicle_type = (VehicleType)GB(w->window_number, 11, 5);
vl->length_of_sort_list = 0;
vl->sort_list = NULL;
w->caption_color = player;
@@ -925,7 +908,7 @@
vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
}
-static void DrawSmallOrderList(const Vehicle *v, int x, int y)
+void DrawSmallOrderList(const Vehicle *v, int x, int y)
{
const Order *order;
int sel, i = 0;
@@ -1235,7 +1218,7 @@
PlayerVehWndProc
};
-static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, byte vehicle_type, uint16 unique_number)
+static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number)
{
Window *w;
WindowNumber num;
@@ -1272,9 +1255,13 @@
}
}
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type)
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type)
{
- ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0);
+ if (player == _local_player && _patches.advanced_vehicle_list) {
+ ShowPlayerGroup(player, vehicle_type);
+ } else {
+ ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0);
+ }
}
void ShowVehicleListWindow(const Vehicle *v)
@@ -1283,12 +1270,12 @@
ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->orders->index);
}
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station)
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station)
{
ShowVehicleListWindowLocal(player, VLW_STATION_LIST, vehicle_type, station);
}
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile)
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile)
{
uint16 depot_airport_index;