src/ai/api/ai_station.hpp
author truebrain
Mon, 07 Apr 2008 12:43:46 +0000
branchnoai
changeset 9873 b1ab23560ecb
parent 9866 efc38e1f559a
child 10094 e737405b06dd
permissions -rw-r--r--
(svn r12606) [NoAI] -Fix: minor documentation inconsistancy, to make doxygen even more happy
/* $Id$ */

/** @file ai_station.hpp Everything to query and build stations. */

#ifndef AI_STATION_HPP
#define AI_STATION_HPP

#include "ai_object.hpp"
#include "ai_error.hpp"
#include "../../station_type.h"

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

	/**
	 * All station related error messages.
	 */
	enum ErrorMessages {
		/** Base for station related errors */
		ERR_STATION_BASE = AIError::ERR_CAT_STATION << AIError::ERR_CAT_BIT_SIZE,

		/** The station size exceeds the station spread */
		ERR_STATION_TOO_LARGE,                  // [STR_306C_STATION_TOO_SPREAD_OUT]

		/** The station is build too close to another station */
		ERR_STATION_TOO_CLOSE_TO_OTHER_STATION, // [STR_300D_TOO_CLOSE_TO_ANOTHER_AIRPORT, STR_3009_TOO_CLOSE_TO_ANOTHER_STATION]
	};

	/**
	 * Type of stations known in the game.
	 */
	enum StationType {
		STATION_ANY        = 0x00, //!< All station types
		STATION_TRAIN      = 0x01, //!< Train station
		STATION_TRUCK_STOP = 0x02, //!< Truck station
		STATION_BUS_STOP   = 0x04, //!< Bus station
		STATION_AIRPORT    = 0x08, //!< Airport
		STATION_DOCK       = 0x10, //!< Dock
	};

	/**
	 * Checks whether the given station is valid and owned by you.
	 * @param station_id The station to check.
	 * @return True if and only if the station is valid.
	 */
	static bool IsValidStation(StationID station_id);

	/**
	 * Get the StationID of a tile, if there is a station.
	 * @param tile The tile to find the stationID of
	 * @return StationID of the station.
	 * @post Use IsValidStation() to see if the station is valid.
	 */
	static StationID GetStationID(TileIndex tile);

	/**
	 * Get the name of a station.
	 * @param station_id The station to get the name of.
	 * @pre IsValidStation(station_id).
	 * @return The name of the station.
	 */
	static char *GetName(StationID station_id);

	/**
	 * Get the current location of a station.
	 * @param station_id The station to get the location of.
	 * @pre IsValidStation(station_id).
	 * @return The tile the station is currently on.
	 */
	static TileIndex GetLocation(StationID station_id);

	/**
	 * See how much cargo there is waiting on a station.
	 * @param station_id The station to get the cargo-waiting of.
	 * @param cargo_id The cargo to get the cargo-waiting of.
	 * @pre IsValidStation(station_id).
	 * @pre IsValidCargo(cargo_id).
	 * @return The amount of units waiting at the station.
	 */
	static int32 GetCargoWaiting(StationID station_id, CargoID cargo_id);

	/**
	 * See how high the rating is of a cargo on a station.
	 * @param station_id The station to get the cargo-rating of.
	 * @param cargo_id The cargo to get the cargo-rating of.
	 * @pre IsValidStation(station_id).
	 * @pre IsValidCargo(cargo_id).
	 * @return The rating in percent of the cargo on the station.
	 */
	static int32 GetCargoRating(StationID station_id, CargoID cargo_id);

	/**
	 * Get the coverage radius of this type of station.
	 * @param type The type of station.
	 * @return The radius in tiles.
	 */
	static int32 GetCoverageRadius(AIStation::StationType type);

	/**
	 * Get the manhattan distance from the tile to the AIStation::GetLocation()
	 *  of the station.
	 * @param station_id The station to get the distance to.
	 * @param tile The tile to get the distance to.
	 * @return The distance between station and tile.
	 */
	static int32 GetDistanceManhattanToTile(StationID station_id, TileIndex tile);

	/**
	 * Get the square distance from the tile to the AIStation::GetLocation()
	 *  of the station.
	 * @param station_id The station to get the distance to.
	 * @param tile The tile to get the distance to.
	 * @return The distance between station and tile.
	 */
	static int32 GetDistanceSquareToTile(StationID station_id, TileIndex tile);
};

DECLARE_ENUM_AS_BIT_SET(AIStation::StationType);

#endif /* AI_STATION_HPP */