src/ai/api/ai_tunnel.hpp
author rubidium
Mon, 07 Apr 2008 18:32:42 +0000
branchnoai
changeset 10088 922c6e6a8d3e
parent 9838 0839682a601b
child 10091 e4feb2f9fedf
permissions -rw-r--r--
(svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
9829
80fbe02a4184 (svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents: 9807
diff changeset
     1
/* $Id$ */
80fbe02a4184 (svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents: 9807
diff changeset
     2
80fbe02a4184 (svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents: 9807
diff changeset
     3
/** @file ai_tunnel.hpp Everything to query and build tunnels. */
9794
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
     4
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
     5
#ifndef AI_TUNNEL_HPP
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
     6
#define AI_TUNNEL_HPP
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
     7
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
     8
#include "ai_object.hpp"
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
     9
#include "ai_vehicle.hpp"
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    10
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    11
/**
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    12
 * Class that handles all tunnel related functions.
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    13
 */
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    14
class AITunnel : public AIObject {
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    15
public:
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    16
	static const char *GetClassName() { return "AITunnel"; }
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    17
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    18
	/**
10088
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    19
	 * All tunnel related errors.
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    20
	 */
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    21
	enum ErrorMessages {
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    22
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    23
		/** Base for bridge related errors */
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    24
		ERR_TUNNEL_BASE = AIError::ERR_CAT_TUNNEL << AIError::ERR_CAT_BIT_SIZE,
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    25
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    26
		/** Can't build tunnels on water */
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    27
		ERR_TUNNEL_CANNOT_BUILD_ON_WATER,            // [STR_3807_CAN_T_BUILD_ON_WATER]
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    28
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    29
		/** The start tile must slope either North, South, West or East */
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    30
		ERR_TUNNEL_START_SITE_UNSUITABLE,            // [STR_500B_SITE_UNSUITABLE_FOR_TUNNEL]
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    31
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    32
		/** An other tunnel is in the way */
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    33
		ERR_TUNNEL_ANOTHER_TUNNEL_IN_THE_WAY,        // [STR_5003_ANOTHER_TUNNEL_IN_THE_WAY]
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    34
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    35
		/** Unable to excavate land at the end to create the tunnel's exit */
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    36
		ERR_TUNNEL_END_SITE_UNSUITABLE,              // [STR_5005_UNABLE_TO_EXCAVATE_LAND]
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    37
	};
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    38
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    39
	/**
9807
5b3be41b3ce6 (svn r12315) [NoAI] -Fix: AITunnel::GetOtherTunnelEnd() now also works to estimate where a non-existing tunnel would end (Morloth / glx)
truebrain
parents: 9801
diff changeset
    40
	 * Check whether the tile is an entrance to a tunnel.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    41
	 * @param tile The tile to check.
9801
03a3eebd7fb7 (svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents: 9794
diff changeset
    42
	 * @pre AIMap::IsValidTile(tile).
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    43
	 * @return True if and only if the tile is the beginning or end of a tunnel.
9794
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    44
	 */
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    45
	static bool IsTunnelTile(TileIndex tile);
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    46
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    47
	/**
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    48
	 * Get the tile that exits on the other end of a (would be) tunnel starting
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    49
	 *  at tile.
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    50
	 * @param tile The tile that is an entrance to a tunnel or the tile where you may want to build a tunnel.
9807
5b3be41b3ce6 (svn r12315) [NoAI] -Fix: AITunnel::GetOtherTunnelEnd() now also works to estimate where a non-existing tunnel would end (Morloth / glx)
truebrain
parents: 9801
diff changeset
    51
	 * @pre AIMap::IsValidTile(tile).
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    52
	 * @return The TileIndex that is the other end of the (would be) tunnel, or
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    53
	 *  'tile' if no other end was found (crossing tunnels).
9794
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    54
	 */
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    55
	static TileIndex GetOtherTunnelEnd(TileIndex tile);
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    56
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    57
	/**
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    58
	 * Builds a tunnel starting at start. The direction of the tunnel depends
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    59
	 *  on the slope of the start tile. Tunnels can be created for either
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    60
	 *  rails or roads; use the appropriate AIVehicle::VehicleType.
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    61
	 * @param start Where to start the tunnel.
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    62
	 * @param vehicle_type The vehicle-type of tunnel to build.
9801
03a3eebd7fb7 (svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents: 9794
diff changeset
    63
	 * @pre AIMap::IsValidTile(start).
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    64
	 * @pre 'vehicle_type' is either AIVehicle::VEHICLE_RAIL or AIVEHICLE::VEHICLE_ROAD.
10088
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    65
	 * @exception AIError::ERR_AREA_NOT_CLEAR
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    66
	 * @exception AITunnel::ERR_TUNNEL_CANNOT_BUILD_ON_WATER
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    67
	 * @exception AITunnel::ERR_TUNNEL_START_SITE_UNSUITABLE
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    68
	 * @exception AITunnel::ERR_TUNNEL_ANOTHER_TUNNEL_IN_THE_WAY
922c6e6a8d3e (svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents: 9838
diff changeset
    69
	 * @exception AITunnel::ERR_TUNNEL_END_SITE_UNSUITABLE
9794
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    70
	 * @return Whether the tunnel has been/can be build or not.
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    71
	 * @note The slope of a tile can be determined by AITile::GetSlope(TileIndex).
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    72
	 */
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    73
	static bool BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start);
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    74
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    75
	/**
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    76
	 * Remove the tunnel whose entrance is located at tile.
9838
0839682a601b (svn r12504) [NoAI] -Documentation: the last few files which now are consistent in their comments (anyway, so I hope :))
truebrain
parents: 9829
diff changeset
    77
	 * @param tile The tile that is an entrance to a tunnel.
9801
03a3eebd7fb7 (svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents: 9794
diff changeset
    78
	 * @pre AIMap::IsValidTile(tile) && IsTunnelTile(tile).
9794
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    79
	 * @return Whether the tunnel has been/can be removed or not.
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    80
	 */
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    81
	static bool RemoveTunnel(TileIndex tile);
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    82
};
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    83
5d866d7cb991 (svn r12298) [NoAI] -Add: added AITunnel (Morloth)
truebrain
parents:
diff changeset
    84
#endif /* AI_TUNNEL_HPP */