changeset 15316:2a60c2c9506b draft

(svn r19957) -Codechange: remove VLW_WAYPOINT_LIST
author smatz <smatz@openttd.org>
date Fri, 11 Jun 2010 00:18:28 +0000
parents ae1f7a2f6ce3
children bd76dc37e6ab
files src/station.cpp src/vehicle_gui.cpp src/vehicle_gui.h src/vehiclelist.cpp src/waypoint.cpp src/waypoint_gui.cpp
diffstat 6 files changed, 19 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -35,6 +35,16 @@
 {
 	free(this->name);
 	free(this->speclist);
+
+	if (CleaningPool()) return;
+
+	Owner owner = this->owner;
+	if (!Company::IsValidID(owner)) owner = _local_company;
+	WindowNumber wno = (this->index << 16) | VLW_STATION_LIST | owner;
+	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
+	DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
+	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
+	DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
 }
 
 Station::Station(TileIndex tile) :
@@ -83,14 +93,6 @@
 
 	DeleteWindowById(WC_STATION_VIEW, index);
 
-	Owner owner = this->owner;
-	if (!Company::IsValidID(owner)) owner = _local_company;
-	WindowNumber wno = (this->index << 16) | VLW_STATION_LIST | owner;
-	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
-	DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
-	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
-	DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
-
 	/* Now delete all orders that go to the station */
 	RemoveOrderFromAllVehicles(OT_GOTO_STATION, this->index);
 
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -43,6 +43,7 @@
 #include "engine_base.h"
 #include "engine_func.h"
 #include "newgrf.h"
+#include "station_base.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -1076,14 +1077,8 @@
 				SetDParam(3, this->vscroll.GetCount());
 				break;
 
-			case VLW_WAYPOINT_LIST:
-				SetDParam(0, STR_WAYPOINT_NAME);
-				SetDParam(1, index);
-				SetDParam(3, this->vscroll.GetCount());
-				break;
-
-			case VLW_STATION_LIST: // Station Name
-				SetDParam(0, STR_STATION_NAME);
+			case VLW_STATION_LIST: // Station/Waypoint Name
+				SetDParam(0, Station::IsExpected(BaseStation::Get(index)) ? STR_STATION_NAME : STR_WAYPOINT_NAME);
 				SetDParam(1, index);
 				SetDParam(3, this->vscroll.GetCount());
 				break;
@@ -1303,12 +1298,6 @@
 	}
 }
 
-void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, const Waypoint *wp)
-{
-	if (wp == NULL) return;
-	ShowVehicleListWindowLocal(company, VLW_WAYPOINT_LIST, vehicle_type, wp->index);
-}
-
 void ShowVehicleListWindow(const Vehicle *v)
 {
 	ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->FirstShared()->index);
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -53,13 +53,12 @@
 	VLW_STATION_LIST  = 2 << 8,
 	VLW_DEPOT_LIST    = 3 << 8,
 	VLW_GROUP_LIST    = 4 << 8,
-	VLW_WAYPOINT_LIST = 5 << 8,
 	VLW_MASK          = 0x700,
 };
 
 static inline bool ValidVLWFlags(uint16 flags)
 {
-	return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST || flags == VLW_GROUP_LIST || flags == VLW_WAYPOINT_LIST);
+	return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST || flags == VLW_GROUP_LIST);
 }
 
 int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number);
@@ -75,7 +74,6 @@
 StringID GetCargoSubtypeText(const Vehicle *v);
 
 void ShowVehicleListWindow(const Vehicle *v);
-void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, const Waypoint *wp);
 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
--- a/src/vehiclelist.cpp
+++ b/src/vehiclelist.cpp
@@ -68,12 +68,11 @@
  * @param owner       Company to generate list for
  * @param index       This parameter has different meanings depending on window_type
  *    <ul>
- *      <li>VLW_STATION_LIST:  index of station to generate a list for</li>
+ *      <li>VLW_STATION_LIST:  index of station/waypoint to generate a list for</li>
  *      <li>VLW_SHARED_ORDERS: index of order to generate a list for<li>
  *      <li>VLW_STANDARD: not used<li>
  *      <li>VLW_DEPOT_LIST: TileIndex of the depot/hangar to make the list for</li>
  *      <li>VLW_GROUP_LIST: index of group to generate a list for</li>
- *      <li>VLW_WAYPOINT_LIST: index of waypoint to generate a list for</li>
  *    </ul>
  * @param window_type The type of window the list is for, using the VLW_ flags in vehicle_gui.h
  * @return false if invalid list is requested
@@ -91,7 +90,8 @@
 					const Order *order;
 
 					FOR_VEHICLE_ORDERS(v, order) {
-						if (order->IsType(OT_GOTO_STATION) && order->GetDestination() == index) {
+						if ((order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT))
+								&& order->GetDestination() == index) {
 							*list->Append() = v;
 							break;
 						}
@@ -133,21 +133,6 @@
 			}
 			break;
 
-		case VLW_WAYPOINT_LIST:
-			FOR_ALL_VEHICLES(v) {
-				if (v->type == type && v->IsPrimaryVehicle()) {
-					const Order *order;
-
-					FOR_VEHICLE_ORDERS(v, order) {
-						if (order->IsType(OT_GOTO_WAYPOINT) && order->GetDestination() == index) {
-							*list->Append() = v;
-							break;
-						}
-					}
-				}
-			}
-			break;
-
 		case VLW_GROUP_LIST:
 			FOR_ALL_VEHICLES(v) {
 				if (v->type == type && v->IsPrimaryVehicle() &&
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -15,9 +15,6 @@
 #include "window_func.h"
 #include "newgrf_station.h"
 #include "waypoint_base.h"
-#include "vehicle_gui.h"
-#include "company_func.h"
-#include "company_base.h"
 
 /**
  * Draw a waypoint
@@ -56,11 +53,5 @@
 	DeleteWindowById(WC_WAYPOINT_VIEW, this->index);
 	RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index);
 
-	Owner owner = this->owner;
-	if (!Company::IsValidID(owner)) owner = _local_company;
-	WindowNumber wno = (this->index << 16) | VLW_WAYPOINT_LIST | owner;
-	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
-	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
-
 	this->sign.MarkDirty();
 }
--- a/src/waypoint_gui.cpp
+++ b/src/waypoint_gui.cpp
@@ -65,7 +65,7 @@
 	{
 		Owner owner = this->owner;
 		if (!Company::IsValidID(owner)) owner = _local_company;
-		DeleteWindowById(GetWindowClassForVehicleType(this->vt), (this->window_number << 16) | (this->vt << 11) | VLW_WAYPOINT_LIST | owner, false);
+		DeleteWindowById(GetWindowClassForVehicleType(this->vt), (this->window_number << 16) | (this->vt << 11) | VLW_STATION_LIST | owner, false);
 	}
 
 	virtual void SetStringParameters(int widget) const
@@ -95,7 +95,7 @@
 				break;
 
 			case WAYPVW_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders
-				ShowVehicleListWindow(this->owner, this->vt, this->wp);
+				ShowVehicleListWindow(this->owner, this->vt, this->wp->index);
 				break;
 		}
 	}