(svn r12555) [NoAI] -Add: support for GetLastError for AICompany.
/* $Id$ */
/** @file ai_bridge.hpp Everything to query and build bridges. */
#ifndef AI_BRIDGE_HPP
#define AI_BRIDGE_HPP
#include "ai_object.hpp"
#include "ai_vehicle.hpp"
#include "../../bridge.h"
/** In OpenTTD Core 'BridgeID' is called 'BridgeType', so map it to make this API more logic. */
typedef BridgeType BridgeID;
/**
* Class that handles all bridge related functions.
*/
class AIBridge : public AIObject {
public:
static const char *GetClassName() { return "AIBridge"; }
/**
* Checks whether the given bridge type is valid.
* @param bridge_id The bridge to check.
* @return True if and only if the bridge type is valid.
*/
static bool IsValidBridge(BridgeID bridge_id);
/**
* Checks whether the given tile is actually a bridge start or end tile.
* @param tile The tile to check.
* @pre AIMap::IsValidTile(tile).
* @return True if and only if the tile is the beginning or end of a bridge.
*/
static bool IsBridgeTile(TileIndex tile);
/**
* Get the name of a bridge.
* @param bridge_id The bridge to get the name of.
* @pre IsValidBridge(bridge_id).
* @return The name the bridge has.
*/
static char *GetName(BridgeID bridge_id);
/**
* Get the maximum speed of a bridge (in km/h).
* @param bridge_id The bridge to get the maximum speed of.
* @pre IsValidBridge(bridge_id).
* @return The maximum speed the bridge has.
*/
static uint32 GetMaxSpeed(BridgeID bridge_id);
/**
* Get the new cost of a bridge.
* @param bridge_id The bridge to get the new cost of.
* @param length The length of the bridge.
* @pre IsValidBridge(bridge_id).
* @return The new cost the bridge has.
*/
static uint32 GetPrice(BridgeID bridge_id, uint length);
/**
* Get the maximum length of a bridge.
* @param bridge_id The bridge to get the maximum length of.
* @pre IsValidBridge(bridge_id).
* @returns The maximum length the bridge has.
*/
static uint32 GetMaxLength(BridgeID bridge_id);
/**
* Get the minimum length of a bridge.
* @param bridge_id The bridge to get the minimum length of.
* @pre IsValidBridge(bridge_id).
* @returns The minimum length the bridge has.
*/
static uint32 GetMinLength(BridgeID bridge_id);
/**
* Get the year in which a bridge becomes available.
* @param bridge_id The bridge to get the year of availability of.
* @pre IsValidBridge(bridge_id).
* @returns The year of availability the bridge has.
* @note Years are like 2010, -10 (10 B.C.), 1950, ..
*/
static int32 GetYearAvailable(BridgeID bridge_id);
/**
* Build a bridge from one tile to the other.
* @param vehicle_type The vehicle-type of bridge to build.
* @param bridge_id The bridge-type to build.
* @param start Where to start the bridge.
* @param end Where to end the bridge.
* @pre AIMap::IsValidTile(start).
* @pre AIMap::IsValidTile(end).
* @pre 'start' and 'end' are in a straight line, i.e.
* AIMap::GetTileX(start) == AIMap::GetTileX(end) or
* AIMap::GetTileY(start) == AIMap::GetTileY(end).
* @pre 'vehicle_type' is either AIVehicle::VEHICLE_RAIL or AIVEHICLE::VEHICLE_ROAD.
* @return Whether the bridge has been/can be build or not.
*/
static bool BuildBridge(AIVehicle::VehicleType vehicle_type, BridgeID bridge_id, TileIndex start, TileIndex end);
/**
* Removes a bridge, by executing it on either the start or end tile.
* @param tile An end or start tile of the bridge.
* @pre AIMap::IsValidTile(tile).
* @return Whether the bridge has been/can be removed or not.
*/
static bool RemoveBridge(TileIndex tile);
};
#endif /* AI_BRIDGE_HPP */