Class that handles all tunnel related functions. More...
#include <ai_tunnel.hpp>
Public Types | |
enum | ErrorMessages { ERR_TUNNEL_BASE = AIError::ERR_CAT_TUNNEL << AIError::ERR_CAT_BIT_SIZE, ERR_TUNNEL_CANNOT_BUILD_ON_WATER, ERR_TUNNEL_START_SITE_UNSUITABLE, ERR_TUNNEL_ANOTHER_TUNNEL_IN_THE_WAY, ERR_TUNNEL_END_SITE_UNSUITABLE } |
All tunnel related errors. More... | |
Static Public Member Functions | |
static const char * | GetClassName () |
Get the name of this class to identify it towards squirrel. | |
static bool | IsTunnelTile (TileIndex tile) |
Check whether the tile is an entrance to a tunnel. | |
static TileIndex | GetOtherTunnelEnd (TileIndex tile) |
Get the tile that exits on the other end of a (would be) tunnel starting at tile. | |
static bool | _BuildTunnelRoad1 () |
Internal function to help BuildTunnel in case of road. | |
static bool | _BuildTunnelRoad2 () |
Internal function to help BuildTunnel in case of road. | |
static bool | BuildTunnel (AIVehicle::VehicleType vehicle_type, TileIndex start) |
Builds a tunnel starting at start. | |
static bool | RemoveTunnel (TileIndex tile) |
Remove the tunnel whose entrance is located at tile. |
Class that handles all tunnel related functions.
Definition at line 21 of file ai_tunnel.hpp.
All tunnel related errors.
Definition at line 29 of file ai_tunnel.hpp.
bool AITunnel::BuildTunnel | ( | AIVehicle::VehicleType | vehicle_type, | |
TileIndex | start | |||
) | [static] |
Builds a tunnel starting at start.
The direction of the tunnel depends on the slope of the start tile. Tunnels can be created for either rails or roads; use the appropriate AIVehicle::VehicleType. As an extra for road, this functions builds two half-pieces of road on each end of the tunnel, making it easier for you to connect it to your network.
start | Where to start the tunnel. | |
vehicle_type | The vehicle-type of tunnel to build. |
Definition at line 72 of file ai_tunnel.cpp.
References CMD_BUILD_TUNNEL, AIObject::DoCommand(), EnforcePrecondition, AIRail::GetCurrentRailType(), AIObject::GetRoadType(), AIRail::IsRailTypeAvailable(), IsValidTile(), RoadTypeToRoadTypes(), AIObject::SetCallbackVariable(), TRANSPORT_RAIL, TRANSPORT_ROAD, AIVehicle::VT_RAIL, and AIVehicle::VT_ROAD.
static const char* AITunnel::GetClassName | ( | ) | [inline, static] |
Get the name of this class to identify it towards squirrel.
Definition at line 24 of file ai_tunnel.hpp.
Get the tile that exits on the other end of a (would be) tunnel starting at tile.
If there is no 'simple' inclined slope at the start tile, this function will return AIMap::TILE_INVALID.
tile | The tile that is an entrance to a tunnel or the tile where you may want to build a tunnel. |
Definition at line 24 of file ai_tunnel.cpp.
References GetInclinedSlopeDirection(), GetTileSlope(), INVALID_DIAGDIR, INVALID_TILE, IsTunnelTile(), IsValidTile(), and TileOffsByDiagDir().
Referenced by _BuildTunnelRoad1(), and _BuildTunnelRoad2().
bool AITunnel::IsTunnelTile | ( | TileIndex | tile | ) | [static] |
Check whether the tile is an entrance to a tunnel.
tile | The tile to check. |
Definition at line 18 of file ai_tunnel.cpp.
References IsValidTile().
Referenced by GetOtherTunnelEnd(), and RemoveTunnel().
bool AITunnel::RemoveTunnel | ( | TileIndex | tile | ) | [static] |
Remove the tunnel whose entrance is located at tile.
tile | The tile that is an entrance to a tunnel. |
AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
Definition at line 120 of file ai_tunnel.cpp.
References CMD_LANDSCAPE_CLEAR, AIObject::DoCommand(), EnforcePrecondition, and IsTunnelTile().