# HG changeset patch
# Parent 4daf28a89c8b3ffd71638504d6a49e0fda7bb167

diff -r 4daf28a89c8b projects/openttd_vs100.vcxproj
--- a/projects/openttd_vs100.vcxproj	Wed Sep 07 19:17:29 2011 +0200
+++ b/projects/openttd_vs100.vcxproj	Wed Sep 07 19:19:04 2011 +0200
@@ -854,6 +854,7 @@
     <ClInclude Include="..\src\ai\api\ai_airport.hpp" />
     <ClInclude Include="..\src\ai\api\ai_airporttype.hpp" />
     <ClInclude Include="..\src\ai\api\ai_airporttypelist.hpp" />
+    <ClInclude Include="..\src\ai\api\ai_airportviewlist.hpp" />
     <ClInclude Include="..\src\ai\api\ai_base.hpp" />
     <ClInclude Include="..\src\ai\api\ai_basestation.hpp" />
     <ClInclude Include="..\src\ai\api\ai_bridge.hpp" />
@@ -909,6 +910,7 @@
     <ClCompile Include="..\src\ai\api\ai_airport.cpp" />
     <ClCompile Include="..\src\ai\api\ai_airporttype.cpp" />
     <ClCompile Include="..\src\ai\api\ai_airporttypelist.cpp" />
+    <ClCompile Include="..\src\ai\api\ai_airportviewlist.cpp" />
     <ClCompile Include="..\src\ai\api\ai_base.cpp" />
     <ClCompile Include="..\src\ai\api\ai_basestation.cpp" />
     <ClCompile Include="..\src\ai\api\ai_bridge.cpp" />
diff -r 4daf28a89c8b projects/openttd_vs100.vcxproj.filters
--- a/projects/openttd_vs100.vcxproj.filters	Wed Sep 07 19:17:29 2011 +0200
+++ b/projects/openttd_vs100.vcxproj.filters	Wed Sep 07 19:19:04 2011 +0200
@@ -1782,6 +1782,9 @@
     <ClInclude Include="..\src\ai\api\ai_airporttypelist.hpp">
       <Filter>AI API</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\ai\api\ai_airportviewlist.hpp">
+      <Filter>AI API</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\ai\api\ai_base.hpp">
       <Filter>AI API</Filter>
     </ClInclude>
@@ -1947,6 +1950,9 @@
     <ClCompile Include="..\src\ai\api\ai_airporttypelist.cpp">
       <Filter>AI API Implementation</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\ai\api\ai_airportviewlist.cpp">
+      <Filter>AI API Implementation</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\ai\api\ai_base.cpp">
       <Filter>AI API Implementation</Filter>
     </ClCompile>
diff -r 4daf28a89c8b projects/openttd_vs80.vcproj
--- a/projects/openttd_vs80.vcproj	Wed Sep 07 19:17:29 2011 +0200
+++ b/projects/openttd_vs80.vcproj	Wed Sep 07 19:19:04 2011 +0200
@@ -2739,6 +2739,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_airportviewlist.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_base.hpp"
 				>
 			</File>
@@ -2963,6 +2967,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_airportviewlist.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_base.cpp"
 				>
 			</File>
diff -r 4daf28a89c8b projects/openttd_vs90.vcproj
--- a/projects/openttd_vs90.vcproj	Wed Sep 07 19:17:29 2011 +0200
+++ b/projects/openttd_vs90.vcproj	Wed Sep 07 19:19:04 2011 +0200
@@ -2736,6 +2736,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_airportviewlist.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_base.hpp"
 				>
 			</File>
@@ -2960,6 +2964,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_airportviewlist.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_base.cpp"
 				>
 			</File>
diff -r 4daf28a89c8b source.list
--- a/source.list	Wed Sep 07 19:17:29 2011 +0200
+++ b/source.list	Wed Sep 07 19:19:04 2011 +0200
@@ -627,6 +627,7 @@
 ai/api/ai_airport.hpp
 ai/api/ai_airporttype.hpp
 ai/api/ai_airporttypelist.hpp
+ai/api/ai_airportviewlist.hpp
 ai/api/ai_base.hpp
 ai/api/ai_basestation.hpp
 ai/api/ai_bridge.hpp
@@ -684,6 +685,7 @@
 ai/api/ai_airport.cpp
 ai/api/ai_airporttype.cpp
 ai/api/ai_airporttypelist.cpp
+ai/api/ai_airportviewlist.cpp
 ai/api/ai_base.cpp
 ai/api/ai_basestation.cpp
 ai/api/ai_bridge.cpp
diff -r 4daf28a89c8b src/ai/ai_instance.cpp
--- a/src/ai/ai_instance.cpp	Wed Sep 07 19:17:29 2011 +0200
+++ b/src/ai/ai_instance.cpp	Wed Sep 07 19:19:04 2011 +0200
@@ -27,6 +27,7 @@
 #include "api/ai_airport.hpp.sq"
 #include "api/ai_airporttype.hpp.sq"
 #include "api/ai_airporttypelist.hpp.sq"
+#include "api/ai_airportviewlist.hpp.sq"
 #include "api/ai_base.hpp.sq"
 #include "api/ai_basestation.hpp.sq"
 #include "api/ai_bridge.hpp.sq"
@@ -181,6 +182,7 @@
 	SQAIAirport_Register(this->engine);
 	SQAIAirportType_Register(this->engine);
 	SQAIAirportTypeList_Register(this->engine);
+	SQAIAirportViewList_Register(this->engine);
 	SQAIBase_Register(this->engine);
 	SQAIBaseStation_Register(this->engine);
 	SQAIBridge_Register(this->engine);
diff -r 4daf28a89c8b src/ai/api/ai_airporttype.cpp
--- a/src/ai/api/ai_airporttype.cpp	Wed Sep 07 19:17:29 2011 +0200
+++ b/src/ai/api/ai_airporttype.cpp	Wed Sep 07 19:19:04 2011 +0200
@@ -26,6 +26,13 @@
 	return type >= 0 && type < (AirportType)NUM_AIRPORTS && AirportSpec::Get(type)->enabled;
 }
 
+/* static */ bool AIAirportType::IsValidAirportView(AirportView airport_view, AirportType airport_type)
+{
+	if (!IsAirportTypeInformationAvailable(airport_type)) return false;
+
+	return AirportSpec::Get(airport_type)->num_table > airport_view;
+}
+
 /* static */ bool AIAirportType::IsValidPlaneType(PlaneType plane_type)
 {
 	return plane_type == PT_SMALL_PLANE || plane_type == PT_BIG_PLANE || plane_type == PT_HELICOPTER;
diff -r 4daf28a89c8b src/ai/api/ai_airporttype.hpp
--- a/src/ai/api/ai_airporttype.hpp	Wed Sep 07 19:17:29 2011 +0200
+++ b/src/ai/api/ai_airporttype.hpp	Wed Sep 07 19:19:04 2011 +0200
@@ -13,6 +13,7 @@
 #define AI_AIRPORTTYPE_HPP
 
 #include "ai_object.hpp"
+#include "ai_types.hpp"
 
 /**
  * Class that handles all airport type related functions.
@@ -53,6 +54,14 @@
 	static bool IsAirportTypeInformationAvailable(AirportType type);
 
 	/**
+	 * Check if a view is valid for a given airport type.
+	 * @param airport_view The view to check
+	 * @param airport_type The airport type for which to check if the view exist
+	 * @return True if and only if the AirportView is valid for the give AirportType
+	 */
+	static bool IsValidAirportView(AirportView airport_view, AirportType airport_type);
+
+	/**
 	 * Checks wheather the given PlaneType is valid
 	 * @param plane_type The PlaneType to check.
 	 * @return True if and only if the PlaneType is valid
diff -r 4daf28a89c8b src/ai/api/ai_airportviewlist.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_airportviewlist.cpp	Wed Sep 07 19:19:04 2011 +0200
@@ -0,0 +1,28 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file ai_airportviewlist.cpp Implementation of AIAirportViewList. */
+
+#include "../../stdafx.h"
+#include "ai_airportviewlist.hpp"
+#include "ai_airporttype.hpp"
+//#include "../../airport.h"
+#include "../../newgrf_airport.h"
+
+AIAirportViewList::AIAirportViewList(AirportType type)
+{
+	if (!AIAirportType::IsAirportTypeInformationAvailable(type)) return;
+
+	const AirportSpec *as = ::AirportSpec::Get(type);
+
+	for (byte j = 0; j < as->num_table; j++)
+	{
+		this->AddItem(j);
+	}
+}
diff -r 4daf28a89c8b src/ai/api/ai_airportviewlist.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_airportviewlist.hpp	Wed Sep 07 19:19:04 2011 +0200
@@ -0,0 +1,35 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
+ * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** @file ai_airportviewlist.hpp List all airport views. */
+
+#ifndef AI_AIRPORTVIEWLIST_HPP
+#define AI_AIRPORTVIEWLIST_HPP
+
+#include "ai_list.hpp"
+#include "ai_types.hpp"
+
+/**
+ * Creates a list of airport views that are available for the given
+ * airport type. An airport view is basically a rotation of the airport.
+ * @ingroup AIList
+ */
+class AIAirportViewList : public AIList {
+public:
+	/** Get the name of this class to identify it towards squirrel. */
+	static const char *GetClassName() { return "AIAirportViewList"; }
+
+	/**
+	 * @param type The airport type to get a list of views for.
+	 * @pre AIAirportType::IsAirportTypeInformationAvailable
+	 */
+	AIAirportViewList(AirportType type);
+};
+
+#endif /* AI_AIRPORTVIEWLIST_HPP */
diff -r 4daf28a89c8b src/ai/api/ai_types.hpp
--- a/src/ai/api/ai_types.hpp	Wed Sep 07 19:17:29 2011 +0200
+++ b/src/ai/api/ai_types.hpp	Wed Sep 07 19:19:04 2011 +0200
@@ -103,5 +103,6 @@
 typedef byte AirportType;    ///< The ID of an airport type.
 typedef uint AIErrorType;    ///< The types of errors inside the NoAI framework.
 typedef BridgeType BridgeID; ///< The ID of a bridge.
+typedef byte AirportView;    ///< The ID of an airport view
 
 #endif /* AI_TYPES_HPP */
