src/ai/api/ai_airport.hpp
author truebrain
Mon, 07 Apr 2008 14:00:52 +0000
branchnoai
changeset 9874 4ecef0dadf01
parent 9866 efc38e1f559a
child 10091 e4feb2f9fedf
permissions -rw-r--r--
(svn r12607) [NoAI] -Add: SetLastError support for AIVehicle (Morloth)
/* $Id$ */

/** @file ai_airport.hpp Everything to query and build airports. */

#ifndef AI_AIRPORT_HPP
#define AI_AIRPORT_HPP

#include "ai_object.hpp"

/**
 * Class that handles all airport related functions.
 */
class AIAirport : public AIObject {
public:
	static const char *GetClassName() { return "AIAirport"; }

	/**
	 * The types of airports available in the game.
	 */
	enum AirportType {
		/* Note: the values _are_ important as they represent an in-game value */
		AT_SMALL         =   0, //!< The small airport.
		AT_LARGE         =   1, //!< The large airport.
		AT_METROPOLITAN  =   3, //!< The metropolitan airport.
		AT_INTERNATIONAL =   4, //!< The international airport.
		AT_COMMUTER      =   5, //!< The commuter airport.
		AT_INTERCON      =   7, //!< The intercontinental airport.

		/* Next are the airports which only have helicopter platforms */
		AT_HELIPORT      =   2, //!< The heliport.
		AT_HELISTATION   =   8, //!< The helistation.
		AT_HELIDEPOT     =   6, //!< The helidepot.
	};

	/**
	 * Checks whether the given tile is actually a tile with a hangar.
	 * @param tile The tile to check.
	 * @pre AIMap::IsValidTile(tile).
	 * @return True if and only if the tile has a hangar.
	 */
	static bool IsHangarTile(TileIndex tile);

	/**
	 * Checks whether the given tile is actually a tile with a airport.
	 * @param tile The tile to check.
	 * @pre AIMap::IsValidTile(tile).
	 * @return True if and only if the tile has a airport.
	 */
	static bool IsAirportTile(TileIndex tile);

	/**
	 * Check if a certain airport type is already available.
	 * @param type The type of airport to check.
	 */
	static bool AirportAvailable(AirportType type);

	/**
	 * Get the width of this type of airport.
	 * @param type The type of airport.
	 * @return The width in tiles.
	 */
	static int32 GetAirportWidth(AirportType type);

	/**
	 * Get the height of this type of airport.
	 * @param type The type of airport.
	 * @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.
	 * @return The radius in tiles.
	 */
	static int32 GetAirportCoverageRadius(AirportType type);

	/**
	 * Get the first hanger tile of the airport.
	 * @param tile Any tile of the airport.
	 * @pre AIMap::IsValidTile(tile).
	 * @return The first hanger tile of the airport.
	 * @note Possible there are more hangars, but you won't be able to find them
	 *  without walking over all the tiles of the airport and using
	 *  IsHangarTile() on them.
	 */
	static TileIndex GetHangarOfAirport(TileIndex tile);

	/**
	 * Builds a airport with tile at the topleft corner.
	 * @param tile The topleft corner of the airport.
	 * @param type The type of airport to build.
	 * @pre AIMap::IsValidTile(tile).
	 * @pre AirportAvailable(type).
	 * @exception AIError::ERR_AREA_NOT_CLEAR
	 * @exception AIError::ERR_FLAT_LAND_REQUIRED
	 * @exception AIError::ERR_LOCAL_AUTHORITY_REFUSES
	 * @exception AIStation::ERR_STATION_TOO_LARGE
	 * @exception AIStation::ERR_STATION_TOO_CLOSE_TO_OTHER_STATION
	 * @return Whether the airport has been/can be build or not.
	 */
	static bool BuildAirport(TileIndex tile, AirportType type);

	/**
	 * Removes a airport.
	 * @param tile Any tile of the airport.
	 * @pre AIMap::IsValidTile(tile).
	 * @exception AIError::ERR_AREA_IS_OWNED_BY_ANOTHER_COMPANY
	 * @return Whether the airport has been/can be removed or not.
	 */
	static bool RemoveAirport(TileIndex tile);
};

#endif /* AI_AIRPORT_HPP */