Class that handles all tunnel related functions. More...
#include <script_tunnel.hpp>
Public Types | |
enum | ErrorMessages { ERR_TUNNEL_BASE = ScriptError::ERR_CAT_TUNNEL << ScriptError::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 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 (ScriptVehicle::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.
ai
Definition at line 21 of file script_tunnel.hpp.
All tunnel related errors.
Definition at line 26 of file script_tunnel.hpp.
bool ScriptTunnel::_BuildTunnelRoad1 | ( | ) | [static] |
Internal function to help BuildTunnel in case of road.
-all
Definition at line 105 of file script_tunnel.cpp.
References _DoCommandReturnBuildTunnel2(), CMD_BUILD_ROAD, DiagdirBetweenTiles(), DiagDirToRoadBits(), ScriptObject::DoCommand(), ScriptObject::GetCallbackVariable(), GetOtherTunnelEnd(), ScriptObject::GetRoadType(), ReverseDiagDir(), and TileOffsByDiagDir().
Referenced by _DoCommandReturnBuildTunnel1().
bool ScriptTunnel::_BuildTunnelRoad2 | ( | ) | [static] |
Internal function to help BuildTunnel in case of road.
-all
Definition at line 117 of file script_tunnel.cpp.
References CMD_BUILD_ROAD, DiagdirBetweenTiles(), DiagDirToRoadBits(), ScriptObject::DoCommand(), ScriptObject::GetCallbackVariable(), GetOtherTunnelEnd(), ScriptObject::GetRoadType(), ReverseDiagDir(), and TileOffsByDiagDir().
Referenced by _DoCommandReturnBuildTunnel2().
bool ScriptTunnel::BuildTunnel | ( | ScriptVehicle::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 ScriptVehicle::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 81 of file script_tunnel.cpp.
References _DoCommandReturnBuildTunnel1(), CMD_BUILD_TUNNEL, ScriptObject::DoCommand(), EnforcePrecondition, ScriptRail::GetCurrentRailType(), ScriptObject::GetRoadType(), ScriptRail::IsRailTypeAvailable(), IsValidTile(), RoadTypeToRoadTypes(), ScriptObject::SetCallbackVariable(), TRANSPORT_RAIL, TRANSPORT_ROAD, ScriptVehicle::VT_RAIL, and ScriptVehicle::VT_ROAD.
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 ScriptMap::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 25 of file script_tunnel.cpp.
References GetInclinedSlopeDirection(), GetTileSlope(), INVALID_DIAGDIR, INVALID_TILE, IsTunnelTile(), IsValidTile(), and TileOffsByDiagDir().
Referenced by _BuildTunnelRoad1(), and _BuildTunnelRoad2().
bool ScriptTunnel::IsTunnelTile | ( | TileIndex | tile | ) | [static] |
Check whether the tile is an entrance to a tunnel.
tile | The tile to check. |
Definition at line 19 of file script_tunnel.cpp.
References IsValidTile().
Referenced by GetOtherTunnelEnd(), and RemoveTunnel().
bool ScriptTunnel::RemoveTunnel | ( | TileIndex | tile | ) | [static] |
Remove the tunnel whose entrance is located at tile.
tile | The tile that is an entrance to a tunnel. |
ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY |
Definition at line 129 of file script_tunnel.cpp.
References CMD_LANDSCAPE_CLEAR, ScriptObject::DoCommand(), EnforcePrecondition, and IsTunnelTile().