src/vehicle_gui.cpp
branchNewGRF_ports
changeset 10274 b3c58f3df92b
parent 10242 52b4a9006029
child 10724 68a692eacf22
--- a/src/vehicle_gui.cpp	Fri Apr 18 21:20:03 2008 +0000
+++ b/src/vehicle_gui.cpp	Sun Apr 20 15:27:28 2008 +0000
@@ -35,7 +35,6 @@
 #include "settings_type.h"
 #include "widgets/dropdown_func.h"
 #include "order_func.h"
-#include "depot_base.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -103,7 +102,11 @@
 	INVALID_STRING_ID
 };
 
-void RebuildVehicleLists()
+/**
+ * Set sort list flag for all vehicle list windows
+ * @param sl_flag Sort list flag to set
+ */
+static void SetVehicleListsFlag(SortListFlags sl_flag)
 {
 	Window* const *wz;
 
@@ -115,7 +118,7 @@
 			case WC_ROADVEH_LIST:
 			case WC_SHIPS_LIST:
 			case WC_AIRCRAFT_LIST:
-				WP(w, vehiclelist_d).l.flags |= VL_REBUILD;
+				WP(w, vehiclelist_d).l.flags |= sl_flag;
 				SetWindowDirty(w);
 				break;
 
@@ -124,25 +127,20 @@
 	}
 }
 
+/**
+ * Rebuild all vehicle list windows
+ */
+void RebuildVehicleLists()
+{
+	SetVehicleListsFlag(VL_REBUILD);
+}
+
+/**
+ * Resort all vehicle list windows
+ */
 void ResortVehicleLists()
 {
-	Window* const *wz;
-
-	FOR_ALL_WINDOWS(wz) {
-		Window *w = *wz;
-
-		switch (w->window_class) {
-			case WC_TRAINS_LIST:
-			case WC_ROADVEH_LIST:
-			case WC_SHIPS_LIST:
-			case WC_AIRCRAFT_LIST:
-				WP(w, vehiclelist_d).l.flags |= VL_RESORT;
-				SetWindowDirty(w);
-				break;
-
-			default: break;
-		}
-	}
+	SetVehicleListsFlag(VL_RESORT);
 }
 
 void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type)
@@ -1753,7 +1751,7 @@
 
 	if (w != NULL) {
 		w->caption_color = v->owner;
-		AssignWindowViewport(w, VV_VIEWPORT_X, VV_VIEWPORT_Y, VV_INITIAL_VIEWPORT_WIDTH,
+		InitializeWindowViewport(w, VV_VIEWPORT_X, VV_VIEWPORT_Y, VV_INITIAL_VIEWPORT_WIDTH,
 												 (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT,
 												 w->window_number | (1 << 31), _vehicle_view_zoom_levels[v->type]);
 	}