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