truebrain@9829: /* $Id$ */ truebrain@9829: truebrain@9829: /** @file ai_tunnel.hpp Everything to query and build tunnels. */ truebrain@9794: truebrain@9794: #ifndef AI_TUNNEL_HPP truebrain@9794: #define AI_TUNNEL_HPP truebrain@9794: truebrain@9794: #include "ai_object.hpp" truebrain@9794: #include "ai_vehicle.hpp" truebrain@9794: truebrain@9794: /** truebrain@9794: * Class that handles all tunnel related functions. truebrain@9794: */ truebrain@9794: class AITunnel : public AIObject { truebrain@9794: public: truebrain@9794: static const char *GetClassName() { return "AITunnel"; } truebrain@9794: truebrain@9794: /** rubidium@10088: * All tunnel related errors. rubidium@10088: */ rubidium@10088: enum ErrorMessages { rubidium@10088: rubidium@10088: /** Base for bridge related errors */ rubidium@10088: ERR_TUNNEL_BASE = AIError::ERR_CAT_TUNNEL << AIError::ERR_CAT_BIT_SIZE, rubidium@10088: rubidium@10088: /** Can't build tunnels on water */ rubidium@10088: ERR_TUNNEL_CANNOT_BUILD_ON_WATER, // [STR_3807_CAN_T_BUILD_ON_WATER] rubidium@10088: rubidium@10088: /** The start tile must slope either North, South, West or East */ rubidium@10088: ERR_TUNNEL_START_SITE_UNSUITABLE, // [STR_500B_SITE_UNSUITABLE_FOR_TUNNEL] rubidium@10088: rubidium@10088: /** An other tunnel is in the way */ rubidium@10088: ERR_TUNNEL_ANOTHER_TUNNEL_IN_THE_WAY, // [STR_5003_ANOTHER_TUNNEL_IN_THE_WAY] rubidium@10088: rubidium@10088: /** Unable to excavate land at the end to create the tunnel's exit */ rubidium@10088: ERR_TUNNEL_END_SITE_UNSUITABLE, // [STR_5005_UNABLE_TO_EXCAVATE_LAND] rubidium@10088: }; rubidium@10088: rubidium@10088: /** truebrain@9807: * Check whether the tile is an entrance to a tunnel. truebrain@9838: * @param tile The tile to check. truebrain@9801: * @pre AIMap::IsValidTile(tile). truebrain@9838: * @return True if and only if the tile is the beginning or end of a tunnel. truebrain@9794: */ truebrain@9794: static bool IsTunnelTile(TileIndex tile); truebrain@9794: truebrain@9794: /** truebrain@9838: * Get the tile that exits on the other end of a (would be) tunnel starting truebrain@9838: * at tile. truebrain@9838: * @param tile The tile that is an entrance to a tunnel or the tile where you may want to build a tunnel. truebrain@9807: * @pre AIMap::IsValidTile(tile). truebrain@9838: * @return The TileIndex that is the other end of the (would be) tunnel, or truebrain@9838: * 'tile' if no other end was found (crossing tunnels). truebrain@9794: */ truebrain@9794: static TileIndex GetOtherTunnelEnd(TileIndex tile); truebrain@9794: truebrain@9794: /** truebrain@9794: * Builds a tunnel starting at start. The direction of the tunnel depends truebrain@9794: * on the slope of the start tile. Tunnels can be created for either truebrain@9794: * rails or roads; use the appropriate AIVehicle::VehicleType. truebrain@9794: * @param start Where to start the tunnel. truebrain@9794: * @param vehicle_type The vehicle-type of tunnel to build. truebrain@9801: * @pre AIMap::IsValidTile(start). truebrain@9838: * @pre 'vehicle_type' is either AIVehicle::VEHICLE_RAIL or AIVEHICLE::VEHICLE_ROAD. rubidium@10088: * @exception AIError::ERR_AREA_NOT_CLEAR rubidium@10088: * @exception AITunnel::ERR_TUNNEL_CANNOT_BUILD_ON_WATER rubidium@10088: * @exception AITunnel::ERR_TUNNEL_START_SITE_UNSUITABLE rubidium@10088: * @exception AITunnel::ERR_TUNNEL_ANOTHER_TUNNEL_IN_THE_WAY rubidium@10088: * @exception AITunnel::ERR_TUNNEL_END_SITE_UNSUITABLE truebrain@9794: * @return Whether the tunnel has been/can be build or not. truebrain@9794: * @note The slope of a tile can be determined by AITile::GetSlope(TileIndex). truebrain@9794: */ truebrain@9794: static bool BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start); truebrain@9794: truebrain@9794: /** truebrain@9794: * Remove the tunnel whose entrance is located at tile. truebrain@9838: * @param tile The tile that is an entrance to a tunnel. truebrain@9801: * @pre AIMap::IsValidTile(tile) && IsTunnelTile(tile). truebrain@9794: * @return Whether the tunnel has been/can be removed or not. truebrain@9794: */ truebrain@9794: static bool RemoveTunnel(TileIndex tile); truebrain@9794: }; truebrain@9794: truebrain@9794: #endif /* AI_TUNNEL_HPP */