# HG changeset patch
# Parent 690d6910bc7ec70b880ee97ad6ef97513f86d622

diff -r 690d6910bc7e projects/openttd_vs100.vcxproj
--- a/projects/openttd_vs100.vcxproj	Wed Sep 07 19:13:24 2011 +0200
+++ b/projects/openttd_vs100.vcxproj	Wed Sep 07 19:28:45 2011 +0200
@@ -852,6 +852,7 @@
     <ClInclude Include="..\src\ai\ai_storage.hpp" />
     <ClInclude Include="..\src\ai\api\ai_accounting.hpp" />
     <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_base.hpp" />
     <ClInclude Include="..\src\ai\api\ai_basestation.hpp" />
@@ -906,6 +907,7 @@
     <ClInclude Include="..\src\ai\api\ai_waypointlist.hpp" />
     <ClCompile Include="..\src\ai\api\ai_accounting.cpp" />
     <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_base.cpp" />
     <ClCompile Include="..\src\ai\api\ai_basestation.cpp" />
diff -r 690d6910bc7e projects/openttd_vs100.vcxproj.filters
--- a/projects/openttd_vs100.vcxproj.filters	Wed Sep 07 19:13:24 2011 +0200
+++ b/projects/openttd_vs100.vcxproj.filters	Wed Sep 07 19:28:45 2011 +0200
@@ -1776,6 +1776,9 @@
     <ClInclude Include="..\src\ai\api\ai_airport.hpp">
       <Filter>AI API</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\ai\api\ai_airporttype.hpp">
+      <Filter>AI API</Filter>
+    </ClInclude>
     <ClInclude Include="..\src\ai\api\ai_airporttypelist.hpp">
       <Filter>AI API</Filter>
     </ClInclude>
@@ -1938,6 +1941,9 @@
     <ClCompile Include="..\src\ai\api\ai_airport.cpp">
       <Filter>AI API Implementation</Filter>
     </ClCompile>
+    <ClCompile Include="..\src\ai\api\ai_airporttype.cpp">
+      <Filter>AI API Implementation</Filter>
+    </ClCompile>
     <ClCompile Include="..\src\ai\api\ai_airporttypelist.cpp">
       <Filter>AI API Implementation</Filter>
     </ClCompile>
diff -r 690d6910bc7e projects/openttd_vs80.vcproj
--- a/projects/openttd_vs80.vcproj	Wed Sep 07 19:13:24 2011 +0200
+++ b/projects/openttd_vs80.vcproj	Wed Sep 07 19:28:45 2011 +0200
@@ -2731,6 +2731,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_airporttype.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_airporttypelist.hpp"
 				>
 			</File>
@@ -2951,6 +2955,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_airporttype.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_airporttypelist.cpp"
 				>
 			</File>
diff -r 690d6910bc7e projects/openttd_vs90.vcproj
--- a/projects/openttd_vs90.vcproj	Wed Sep 07 19:13:24 2011 +0200
+++ b/projects/openttd_vs90.vcproj	Wed Sep 07 19:28:45 2011 +0200
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9,00"
+	Version="9.00"
 	Name="openttd"
 	ProjectGUID="{668328A0-B40E-4CDB-BD72-D0064424414A}"
 	RootNamespace="openttd"
@@ -15,8 +15,6 @@
 			Name="x64"
 		/>
 	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
 	<Configurations>
 		<Configuration
 			Name="Release|Win32"
@@ -157,7 +155,7 @@
 				AdditionalOptions="/MP"
 				Optimization="0"
 				AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;ENABLE_AI;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;ENABLE_AI;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="1"
 				UsePrecompiledHeader="0"
@@ -2730,6 +2728,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_airporttype.hpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_airporttypelist.hpp"
 				>
 			</File>
@@ -2950,6 +2952,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\ai\api\ai_airporttype.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\ai\api\ai_airporttypelist.cpp"
 				>
 			</File>
diff -r 690d6910bc7e source.list
--- a/source.list	Wed Sep 07 19:13:24 2011 +0200
+++ b/source.list	Wed Sep 07 19:28:45 2011 +0200
@@ -625,6 +625,7 @@
 # AI API
 ai/api/ai_accounting.hpp
 ai/api/ai_airport.hpp
+ai/api/ai_airporttype.hpp
 ai/api/ai_airporttypelist.hpp
 ai/api/ai_base.hpp
 ai/api/ai_basestation.hpp
@@ -681,6 +682,7 @@
 # AI API Implementation
 ai/api/ai_accounting.cpp
 ai/api/ai_airport.cpp
+ai/api/ai_airporttype.cpp
 ai/api/ai_airporttypelist.cpp
 ai/api/ai_base.cpp
 ai/api/ai_basestation.cpp
diff -r 690d6910bc7e src/ai/ai_instance.cpp
--- a/src/ai/ai_instance.cpp	Wed Sep 07 19:13:24 2011 +0200
+++ b/src/ai/ai_instance.cpp	Wed Sep 07 19:28:45 2011 +0200
@@ -25,6 +25,7 @@
  * Note: this line a marker in squirrel_export.sh. Do not change! */
 #include "api/ai_accounting.hpp.sq"
 #include "api/ai_airport.hpp.sq"
+#include "api/ai_airporttype.hpp.sq"
 #include "api/ai_airporttypelist.hpp.sq"
 #include "api/ai_base.hpp.sq"
 #include "api/ai_basestation.hpp.sq"
@@ -178,6 +179,7 @@
 	SQAIList_Register(this->engine);
 	SQAIAccounting_Register(this->engine);
 	SQAIAirport_Register(this->engine);
+	SQAIAirportType_Register(this->engine);
 	SQAIAirportTypeList_Register(this->engine);
 	SQAIBase_Register(this->engine);
 	SQAIBaseStation_Register(this->engine);
diff -r 690d6910bc7e src/ai/api/ai_airport.cpp
--- a/src/ai/api/ai_airport.cpp	Wed Sep 07 19:13:24 2011 +0200
+++ b/src/ai/api/ai_airport.cpp	Wed Sep 07 19:28:45 2011 +0200
@@ -16,24 +16,6 @@
 #include "../../company_func.h"
 #include "../../town.h"
 
-/* static */ bool AIAirport::IsValidAirportType(AirportType type)
-{
-	return IsAirportInformationAvailable(type) && ::AirportSpec::Get(type)->IsAvailable();
-}
-
-/* static */ bool AIAirport::IsAirportInformationAvailable(AirportType type)
-{
-	return type >= 0 && type < (AirportType)NUM_AIRPORTS && AirportSpec::Get(type)->enabled;
-}
-
-/* static */ Money AIAirport::GetPrice(AirportType type)
-{
-	if (!IsValidAirportType(type)) return -1;
-
-	const AirportSpec *as = ::AirportSpec::Get(type);
-	return _price[PR_BUILD_STATION_AIRPORT] * as->size_x * as->size_y;
-}
-
 /* static */ bool AIAirport::IsHangarTile(TileIndex tile)
 {
 	if (!::IsValidTile(tile)) return false;
@@ -48,31 +30,10 @@
 	return ::IsTileType(tile, MP_STATION) && ::IsAirport(tile);
 }
 
-/* static */ int32 AIAirport::GetAirportWidth(AirportType type)
-{
-	if (!IsAirportInformationAvailable(type)) return -1;
-
-	return ::AirportSpec::Get(type)->size_x;
-}
-
-/* static */ int32 AIAirport::GetAirportHeight(AirportType type)
-{
-	if (!IsAirportInformationAvailable(type)) return -1;
-
-	return ::AirportSpec::Get(type)->size_y;
-}
-
-/* static */ int32 AIAirport::GetAirportCoverageRadius(AirportType type)
-{
-	if (!IsAirportInformationAvailable(type)) return -1;
-
-	return _settings_game.station.modified_catchment ? ::AirportSpec::Get(type)->catchment : (uint)CA_UNMODIFIED;
-}
-
 /* static */ bool AIAirport::BuildAirport(TileIndex tile, AirportType type, StationID station_id)
 {
 	EnforcePrecondition(false, ::IsValidTile(tile));
-	EnforcePrecondition(false, IsValidAirportType(type));
+	EnforcePrecondition(false, AIAirportType::IsBuildableAirportType(type));
 	EnforcePrecondition(false, station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id));
 
 	uint p2 = station_id == AIStation::STATION_JOIN_ADJACENT ? 0 : 1;
@@ -123,31 +84,3 @@
 
 	return (AirportType)::Station::Get(station_id)->airport.type;
 }
-
-
-/* static */ int AIAirport::GetNoiseLevelIncrease(TileIndex tile, AirportType type)
-{
-	extern Town *AirportGetNearestTown(const AirportSpec *as, TileIndex airport_tile);
-	extern uint8 GetAirportNoiseLevelForTown(const AirportSpec *as, TileIndex town_tile, TileIndex tile);
-
-	if (!::IsValidTile(tile)) return -1;
-	if (!IsAirportInformationAvailable(type)) return -1;
-
-	if (_settings_game.economy.station_noise_level) {
-		const AirportSpec *as = ::AirportSpec::Get(type);
-		const Town *t = AirportGetNearestTown(as, tile);
-		return GetAirportNoiseLevelForTown(as, t->xy, tile);
-	}
-
-	return 1;
-}
-
-/* static */ TownID AIAirport::GetNearestTown(TileIndex tile, AirportType type)
-{
-	extern Town *AirportGetNearestTown(const AirportSpec *as, TileIndex airport_tile);
-
-	if (!::IsValidTile(tile)) return INVALID_TOWN;
-	if (!IsAirportInformationAvailable(type)) return INVALID_TOWN;
-
-	return AirportGetNearestTown(AirportSpec::Get(type), tile)->index;
-}
diff -r 690d6910bc7e src/ai/api/ai_airport.hpp
--- a/src/ai/api/ai_airport.hpp	Wed Sep 07 19:13:24 2011 +0200
+++ b/src/ai/api/ai_airport.hpp	Wed Sep 07 19:28:45 2011 +0200
@@ -13,6 +13,7 @@
 #define AI_AIRPORT_HPP
 
 #include "ai_object.hpp"
+#include "ai_airporttype.hpp"
 
 /**
  * Class that handles all airport related functions.
@@ -23,44 +24,6 @@
 	static const char *GetClassName() { return "AIAirport"; }
 
 	/**
-	 * All plane types available.
-	 */
-	enum PlaneType {
-		/* Note: the values _are_ important as they represent an in-game value */
-		PT_HELICOPTER    =   0, ///< A helicopter.
-		PT_SMALL_PLANE   =   1, ///< A small plane.
-		PT_BIG_PLANE     =   3, ///< A big plane.
-
-		PT_INVALID       =  -1, ///< An invalid PlaneType
-	};
-
-	/**
-	 * Checks whether the given AirportType is valid and available.
-	 * @param type The AirportType to check.
-	 * @return True if and only if the AirportType is valid and available.
-	 * @post return value == true -> IsAirportInformationAvailable returns true.
-	 */
-	static bool IsValidAirportType(AirportType type);
-
-	/**
-	 * Can you get information on this airport type? As opposed to
-	 * IsValidAirportType this will return also return true when
-	 * an airport type is no longer buildable.
-	 * @param type The AirportType to check.
-	 * @return True if and only if the AirportType is valid.
-	 * @post return value == false -> IsValidAirportType returns false.
-	 */
-	static bool IsAirportInformationAvailable(AirportType type);
-
-	/**
-	 * Get the cost to build this AirportType.
-	 * @param type The AirportType to check.
-	 * @pre AirportAvailable(type).
-	 * @return The cost of building this AirportType.
-	 */
-	static Money GetPrice(AirportType type);
-
-	/**
 	 * Checks whether the given tile is actually a tile with a hangar.
 	 * @param tile The tile to check.
 	 * @pre AIMap::IsValidTile(tile).
@@ -77,30 +40,6 @@
 	static bool IsAirportTile(TileIndex tile);
 
 	/**
-	 * Get the width of this type of airport.
-	 * @param type The type of airport.
-	 * @pre IsAirportInformationAvailable(type).
-	 * @return The width in tiles.
-	 */
-	static int32 GetAirportWidth(AirportType type);
-
-	/**
-	 * Get the height of this type of airport.
-	 * @param type The type of airport.
-	 * @pre IsAirportInformationAvailable(type).
-	 * @return The height in tiles.
-	 */
-	static int32 GetAirportHeight(AirportType type);
-
-	/**
-	 * Get the coverage radius of this type of airport.
-	 * @param type The type of airport.
-	 * @pre IsAirportInformationAvailable(type).
-	 * @return The radius in tiles.
-	 */
-	static int32 GetAirportCoverageRadius(AirportType type);
-
-	/**
 	 * Get the number of hangars of the airport.
 	 * @param tile Any tile of the airport.
 	 * @pre AIMap::IsValidTile(tile).
@@ -126,7 +65,7 @@
 	 * @param type The type of airport to build.
 	 * @param station_id The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT.
 	 * @pre AIMap::IsValidTile(tile).
-	 * @pre AirportAvailable(type).
+	 * @pre AIAirportType::IsBuildableAirportType(type).
 	 * @pre station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id).
 	 * @exception AIError::ERR_AREA_NOT_CLEAR
 	 * @exception AIError::ERR_FLAT_LAND_REQUIRED
@@ -154,27 +93,6 @@
 	 * @return The AirportType of the airport.
 	 */
 	static AirportType GetAirportType(TileIndex tile);
-
-	/**
-	 * Get the noise that will be added to the nearest town if an airport was
-	 *  built at this tile.
-	 * @param tile The tile to check.
-	 * @param type The AirportType to check.
-	 * @pre IsAirportInformationAvailable(type).
-	 * @return The amount of noise added to the nearest town.
-	 * @note The noise will be added to the town with TownID GetNearestTown(tile, type).
-	 */
-	static int GetNoiseLevelIncrease(TileIndex tile, AirportType type);
-
-	/**
-	 * Get the TownID of the town whose local authority will influence
-	 *  an airport at some tile.
-	 * @param tile The tile to check.
-	 * @param type The AirportType to check.
-	 * @pre IsAirportInformationAvailable(type).
-	 * @return The TownID of the town closest to the tile.
-	 */
-	static TownID GetNearestTown(TileIndex tile, AirportType type);
 };
 
 #endif /* AI_AIRPORT_HPP */
diff -r 690d6910bc7e src/ai/api/ai_airport.hpp.sq
--- a/src/ai/api/ai_airport.hpp.sq	Wed Sep 07 19:13:24 2011 +0200
+++ b/src/ai/api/ai_airport.hpp.sq	Wed Sep 07 19:28:45 2011 +0200
@@ -12,10 +12,6 @@
 #include "ai_airport.hpp"
 
 namespace SQConvert {
-	/* Allow enums to be used as Squirrel parameters */
-	template <> AIAirport::PlaneType GetParam(ForceType<AIAirport::PlaneType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIAirport::PlaneType)tmp; }
-	template <> int Return<AIAirport::PlaneType>(HSQUIRRELVM vm, AIAirport::PlaneType res) { sq_pushinteger(vm, (int32)res); return 1; }
-
 	/* Allow AIAirport to be used as Squirrel parameter */
 	template <> AIAirport *GetParam(ForceType<AIAirport *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIAirport *)instance; }
 	template <> AIAirport &GetParam(ForceType<AIAirport &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIAirport *)instance; }
@@ -30,26 +26,13 @@
 	SQAIAirport.PreRegister(engine);
 	SQAIAirport.AddConstructor<void (AIAirport::*)(), 1>(engine, "x");
 
-	SQAIAirport.DefSQConst(engine, AIAirport::PT_HELICOPTER,  "PT_HELICOPTER");
-	SQAIAirport.DefSQConst(engine, AIAirport::PT_SMALL_PLANE, "PT_SMALL_PLANE");
-	SQAIAirport.DefSQConst(engine, AIAirport::PT_BIG_PLANE,   "PT_BIG_PLANE");
-	SQAIAirport.DefSQConst(engine, AIAirport::PT_INVALID,     "PT_INVALID");
-
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsValidAirportType,            "IsValidAirportType",            2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsAirportInformationAvailable, "IsAirportInformationAvailable", 2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetPrice,                      "GetPrice",                      2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsHangarTile,                  "IsHangarTile",                  2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsAirportTile,                 "IsAirportTile",                 2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportWidth,               "GetAirportWidth",               2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportHeight,              "GetAirportHeight",              2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportCoverageRadius,      "GetAirportCoverageRadius",      2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetNumHangars,                 "GetNumHangars",                 2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetHangarOfAirport,            "GetHangarOfAirport",            2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::BuildAirport,                  "BuildAirport",                  4, ".iii");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::RemoveAirport,                 "RemoveAirport",                 2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportType,                "GetAirportType",                2, ".i");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetNoiseLevelIncrease,         "GetNoiseLevelIncrease",         3, ".ii");
-	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetNearestTown,                "GetNearestTown",                3, ".ii");
+	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsHangarTile,       "IsHangarTile",       2, ".i");
+	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::IsAirportTile,      "IsAirportTile",      2, ".i");
+	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetNumHangars,      "GetNumHangars",      2, ".i");
+	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetHangarOfAirport, "GetHangarOfAirport", 2, ".i");
+	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::BuildAirport,       "BuildAirport",       4, ".iii");
+	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::RemoveAirport,      "RemoveAirport",      2, ".i");
+	SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportType,     "GetAirportType",     2, ".i");
 
 	SQAIAirport.PostRegister(engine);
 }
diff -r 690d6910bc7e src/ai/api/ai_airporttype.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_airporttype.cpp	Wed Sep 07 19:28:45 2011 +0200
@@ -0,0 +1,88 @@
+/* $Id: ai_airporttype.cpp 22710 2011-08-01 20:15:18Z frosch $ */
+
+/*
+ * 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_airporttype.cpp Implementation of AIAirportType. */
+
+#include "../../stdafx.h"
+#include "ai_airporttype.hpp"
+#include "ai_station.hpp"
+#include "../../station_base.h"
+#include "../../company_func.h"
+#include "../../town.h"
+
+/* static */ bool AIAirportType::IsBuildableAirportType(AirportType type)
+{
+	return IsAirportTypeInformationAvailable(type) && ::AirportSpec::Get(type)->IsAvailable();
+}
+
+/* static */ bool AIAirportType::IsAirportTypeInformationAvailable(AirportType type)
+{
+	return type >= 0 && type < (AirportType)NUM_AIRPORTS && AirportSpec::Get(type)->enabled;
+}
+
+/* static */ bool AIAirportType::IsValidPlaneType(PlaneType plane_type)
+{
+	return plane_type == PT_SMALL_PLANE || plane_type == PT_BIG_PLANE || plane_type == PT_HELICOPTER;
+}
+
+/* static */ Money AIAirportType::GetPrice(AirportType type)
+{
+	if (!IsBuildableAirportType(type)) return -1;
+
+	const AirportSpec *as = ::AirportSpec::Get(type);
+	return _price[PR_BUILD_STATION_AIRPORT] * as->size_x * as->size_y;
+}
+
+/* static */ int32 AIAirportType::GetAirportWidth(AirportType type)
+{
+	if (!IsAirportTypeInformationAvailable(type)) return -1;
+
+	return ::AirportSpec::Get(type)->size_x;
+}
+
+/* static */ int32 AIAirportType::GetAirportHeight(AirportType type)
+{
+	if (!IsAirportTypeInformationAvailable(type)) return -1;
+
+	return ::AirportSpec::Get(type)->size_y;
+}
+
+/* static */ int32 AIAirportType::GetAirportCoverageRadius(AirportType type)
+{
+	if (!IsAirportTypeInformationAvailable(type)) return -1;
+
+	return _settings_game.station.modified_catchment ? ::AirportSpec::Get(type)->catchment : (uint)CA_UNMODIFIED;
+}
+
+/* static */ int AIAirportType::GetNoiseLevelIncrease(TileIndex tile, AirportType type)
+{
+	extern Town *AirportGetNearestTown(const AirportSpec *as, TileIndex airport_tile);
+	extern uint8 GetAirportNoiseLevelForTown(const AirportSpec *as, TileIndex town_tile, TileIndex tile);
+
+	if (!::IsValidTile(tile)) return -1;
+	if (!IsAirportTypeInformationAvailable(type)) return -1;
+
+	if (_settings_game.economy.station_noise_level) {
+		const AirportSpec *as = ::AirportSpec::Get(type);
+		const Town *t = AirportGetNearestTown(as, tile);
+		return GetAirportNoiseLevelForTown(as, t->xy, tile);
+	}
+
+	return 1;
+}
+
+/* static */ TownID AIAirportType::GetNearestTown(TileIndex tile, AirportType type)
+{
+	extern Town *AirportGetNearestTown(const AirportSpec *as, TileIndex airport_tile);
+
+	if (!::IsValidTile(tile)) return INVALID_TOWN;
+	if (!AIAirportType::IsAirportTypeInformationAvailable(type)) return INVALID_TOWN;
+
+	return AirportGetNearestTown(AirportSpec::Get(type), tile)->index;
+}
diff -r 690d6910bc7e src/ai/api/ai_airporttype.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_airporttype.hpp	Wed Sep 07 19:28:45 2011 +0200
@@ -0,0 +1,116 @@
+/* $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_airporttype.hpp Everything to query information about airport types. */
+
+#ifndef AI_AIRPORTTYPE_HPP
+#define AI_AIRPORTTYPE_HPP
+
+#include "ai_object.hpp"
+
+/**
+ * Class that handles all airport type related functions.
+ */
+class AIAirportType : public AIObject {
+public:
+	/** Get the name of this class to identify it towards squirrel. */
+	static const char *GetClassName() { return "AIAirportType"; }
+
+	/**
+	 * All plane types available.
+	 */
+	enum PlaneType {
+		/* Note: the values _are_ important as they represent an in-game value */
+		PT_HELICOPTER    =   0, ///< A helicopter.
+		PT_SMALL_PLANE   =   1, ///< A small plane.
+		PT_BIG_PLANE     =   3, ///< A big plane.
+
+		PT_INVALID       =  -1, ///< An invalid PlaneType
+	};
+
+	/**
+	 * Checks whether the given AirportType is valid and available.
+	 * @param type The AirportType to check.
+	 * @return True if and only if the AirportType is valid and available.
+	 * @post return value == true -> IsAirportTypeInformationAvailable returns true.
+	 */
+	static bool IsBuildableAirportType(AirportType type);
+
+	/**
+	 * Can you get information on this airport type? As opposed to
+	 * IsBuildable this will return also return true when
+	 * an airport type is no longer buildable.
+	 * @param type The AirportType to check.
+	 * @return True if and only if the AirportType is valid.
+	 * @post return value == false -> IsBuildableAirportType returns false.
+	 */
+	static bool IsAirportTypeInformationAvailable(AirportType 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
+	 */
+	static bool IsValidPlaneType(PlaneType plane_type);
+
+	/**
+	 * Get the cost to build this AirportType.
+	 * @param type The AirportType to check.
+	 * @pre IsBuildableAirportType(type).
+	 * @return The cost of building this AirportType.
+	 */
+	static Money GetPrice(AirportType type);
+
+	/**
+	 * Get the width of of the given airport type.
+	 * @param type The type of airport.
+	 * @pre IsAirportTypeInformationAvailable(type).
+	 * @return The width in tiles.
+	 */
+	static int32 GetAirportWidth(AirportType type);
+
+	/**
+	 * Get the height of of the given airport type.
+	 * @param type The type of airport.
+	 * @pre IsAirportTypeInformationAvailable(type).
+	 * @return The height in tiles.
+	 */
+	static int32 GetAirportHeight(AirportType type);
+
+	/**
+	 * Get the coverage radius of this type of airport.
+	 * @param type The type of airport.
+	 * @pre IsAirportTypeInformationAvailable(type).
+	 * @return The radius in tiles.
+	 */
+	static int32 GetAirportCoverageRadius(AirportType type);
+
+	/**
+	 * Get the noise that will be added to the nearest town if an airport was
+	 *  built at this tile.
+	 * @param tile The tile to check.
+	 * @param type The AirportType to check.
+	 * @pre IsAirportTypeInformationAvailable(type).
+	 * @return The amount of noise added to the nearest town.
+	 * @note The noise will be added to the town with TownID GetNearestTown(tile, type).
+	 */
+	static int GetNoiseLevelIncrease(TileIndex tile, AirportType type);
+
+	/**
+	 * Get the TownID of the town whose local authority will influence
+	 *  an airport at some tile.
+	 * @param tile The tile to check.
+	 * @param type The AirportType to check.
+	 * @pre IsAirportTypeInformationAvailable(type).
+	 * @return The TownID of the town closest to the tile.
+	 */
+	static TownID GetNearestTown(TileIndex tile, AirportType type);
+};
+
+#endif /* AI_AIRPORTTYPE_HPP */
diff -r 690d6910bc7e src/ai/api/ai_airporttype.hpp.sq
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_airporttype.hpp.sq	Wed Sep 07 19:28:45 2011 +0200
@@ -0,0 +1,49 @@
+/* $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/>.
+ */
+
+/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
+
+#include "ai_airporttype.hpp"
+
+namespace SQConvert {
+	/* Allow enums to be used as Squirrel parameters */
+	template <> AIAirportType::PlaneType GetParam(ForceType<AIAirportType::PlaneType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (AIAirportType::PlaneType)tmp; }
+	template <> int Return<AIAirportType::PlaneType>(HSQUIRRELVM vm, AIAirportType::PlaneType res) { sq_pushinteger(vm, (int32)res); return 1; }
+
+	/* Allow AIAirportType to be used as Squirrel parameter */
+	template <> AIAirportType *GetParam(ForceType<AIAirportType *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIAirportType *)instance; }
+	template <> AIAirportType &GetParam(ForceType<AIAirportType &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIAirportType *)instance; }
+	template <> const AIAirportType *GetParam(ForceType<const AIAirportType *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIAirportType *)instance; }
+	template <> const AIAirportType &GetParam(ForceType<const AIAirportType &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIAirportType *)instance; }
+	template <> int Return<AIAirportType *>(HSQUIRRELVM vm, AIAirportType *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIAirportType", res, NULL, DefSQDestructorCallback<AIAirportType>); return 1; }
+} // namespace SQConvert
+
+void SQAIAirportType_Register(Squirrel *engine)
+{
+	DefSQClass <AIAirportType> SQAIAirportType("AIAirportType");
+	SQAIAirportType.PreRegister(engine);
+	SQAIAirportType.AddConstructor<void (AIAirportType::*)(), 1>(engine, "x");
+
+	SQAIAirportType.DefSQConst(engine, AIAirportType::PT_HELICOPTER,  "PT_HELICOPTER");
+	SQAIAirportType.DefSQConst(engine, AIAirportType::PT_SMALL_PLANE, "PT_SMALL_PLANE");
+	SQAIAirportType.DefSQConst(engine, AIAirportType::PT_BIG_PLANE,   "PT_BIG_PLANE");
+	SQAIAirportType.DefSQConst(engine, AIAirportType::PT_INVALID,     "PT_INVALID");
+
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::IsBuildableAirportType,            "IsBuildableAirportType",            2, ".i");
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::IsAirportTypeInformationAvailable, "IsAirportTypeInformationAvailable", 2, ".i");
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::IsValidPlaneType,                  "IsValidPlaneType",                  2, ".i");
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::GetPrice,                          "GetPrice",                          2, ".i");
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::GetAirportWidth,                   "GetAirportWidth",                   2, ".i");
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::GetAirportHeight,                  "GetAirportHeight",                  2, ".i");
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::GetAirportCoverageRadius,          "GetAirportCoverageRadius",          2, ".i");
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::GetNoiseLevelIncrease,             "GetNoiseLevelIncrease",             3, ".ii");
+	SQAIAirportType.DefSQStaticMethod(engine, &AIAirportType::GetNearestTown,                    "GetNearestTown",                    3, ".ii");
+
+	SQAIAirportType.PostRegister(engine);
+}
diff -r 690d6910bc7e src/ai/api/ai_airporttypelist.cpp
--- a/src/ai/api/ai_airporttypelist.cpp	Wed Sep 07 19:13:24 2011 +0200
+++ b/src/ai/api/ai_airporttypelist.cpp	Wed Sep 07 19:28:45 2011 +0200
@@ -11,12 +11,12 @@
 
 #include "../../stdafx.h"
 #include "ai_airporttypelist.hpp"
-#include "ai_airport.hpp"
+#include "ai_airporttype.hpp"
 #include "../../airport.h"
 
 AIAirportTypeList::AIAirportTypeList()
 {
 	for (byte j = 0; j <= NUM_AIRPORTS; j++) {
-		if (AIAirport::IsAirportInformationAvailable(j)) this->AddItem(j);
+		if (AIAirportType::IsAirportTypeInformationAvailable(j)) this->AddItem(j);
 	}
 }
diff -r 690d6910bc7e src/ai/api/ai_engine.cpp
--- a/src/ai/api/ai_engine.cpp	Wed Sep 07 19:13:24 2011 +0200
+++ b/src/ai/api/ai_engine.cpp	Wed Sep 07 19:28:45 2011 +0200
@@ -242,10 +242,10 @@
 	return CountArticulatedParts(engine_id, true) != 0;
 }
 
-/* static */ AIAirport::PlaneType AIEngine::GetPlaneType(EngineID engine_id)
+/* static */ AIAirportType::PlaneType AIEngine::GetPlaneType(EngineID engine_id)
 {
-	if (!IsValidEngine(engine_id)) return AIAirport::PT_INVALID;
-	if (GetVehicleType(engine_id) != AIVehicle::VT_AIR) return AIAirport::PT_INVALID;
+	if (!IsValidEngine(engine_id)) return AIAirportType::PT_INVALID;
+	if (GetVehicleType(engine_id) != AIVehicle::VT_AIR) return AIAirportType::PT_INVALID;
 
-	return (AIAirport::PlaneType)::AircraftVehInfo(engine_id)->subtype;
+	return (AIAirportType::PlaneType)::AircraftVehInfo(engine_id)->subtype;
 }
diff -r 690d6910bc7e src/ai/api/ai_engine.hpp
--- a/src/ai/api/ai_engine.hpp	Wed Sep 07 19:13:24 2011 +0200
+++ b/src/ai/api/ai_engine.hpp	Wed Sep 07 19:28:45 2011 +0200
@@ -14,7 +14,7 @@
 
 #include "ai_vehicle.hpp"
 #include "ai_rail.hpp"
-#include "ai_airport.hpp"
+#include "ai_airporttype.hpp"
 
 /**
  * Class that handles all engine related functions.
@@ -251,7 +251,7 @@
 	 * @pre GetVehicleType(engine_id) == AIVehicle::VT_AIR.
 	 * @return The PlaneType the engine has.
 	 */
-	static AIAirport::PlaneType GetPlaneType(EngineID engine_id);
+	static AIAirportType::PlaneType GetPlaneType(EngineID engine_id);
 };
 
 #endif /* AI_ENGINE_HPP */
