summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-10-30 20:51:36 +0000
committeralberth <alberth@openttd.org>2009-10-30 20:51:36 +0000
commitd135329860541a90d1829b19dd90132fc4d2306e (patch)
tree0f1ad76c190327264bd263b9b4cc89817a0b828d /src/vehicle_gui.cpp
parent8cb8f816628579f7f94827435b34f708087406ca (diff)
downloadopenttd-d135329860541a90d1829b19dd90132fc4d2306e.tar.xz
(svn r17906) -Fix [FS#3286]: Fill the vehicle list before initializing the widgets of the vehicle list window.
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 51afdeb92..94f4773dc 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -859,6 +859,23 @@ public:
this->vehicle_type = (VehicleType)GB(window_number, 11, 5);
+ /* Set up sorting. Make the window-specific _sorting variable
+ * point to the correct global _sorting struct so we are freed
+ * from having conditionals during window operation */
+ switch (this->vehicle_type) {
+ case VEH_TRAIN: this->sorting = &_sorting.train; break;
+ case VEH_ROAD: this->sorting = &_sorting.roadveh; break;
+ case VEH_SHIP: this->sorting = &_sorting.ship; break;
+ case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break;
+ default: NOT_REACHED();
+ }
+
+ this->vehicles.SetListing(*this->sorting);
+ this->vehicles.ForceRebuild();
+ this->vehicles.NeedResort();
+ this->BuildVehicleList(company, GB(window_number, 16, 16), window_type);
+ this->SortVehicleList();
+
this->CreateNestedTree(desc);
/* Set up the window widgets */
@@ -877,21 +894,6 @@ public:
this->vscroll.SetCapacity(this->GetWidget<NWidgetBase>(VLW_WIDGET_LIST)->current_y / this->resize.step_height);
this->GetWidget<NWidgetCore>(VLW_WIDGET_LIST)->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
- /* Set up sorting. Make the window-specific _sorting variable
- * point to the correct global _sorting struct so we are freed
- * from having conditionals during window operation */
- switch (this->vehicle_type) {
- case VEH_TRAIN: this->sorting = &_sorting.train; break;
- case VEH_ROAD: this->sorting = &_sorting.roadveh; break;
- case VEH_SHIP: this->sorting = &_sorting.ship; break;
- case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break;
- default: NOT_REACHED();
- }
-
- this->vehicles.SetListing(*this->sorting);
- this->vehicles.ForceRebuild();
- this->vehicles.NeedResort();
-
if (this->vehicle_type == VEH_TRAIN) ResizeWindow(this, 65, 0);
}