author | rubidium |
Mon, 07 Apr 2008 18:32:42 +0000 | |
branch | noai |
changeset 10088 | 922c6e6a8d3e |
parent 9838 | 0839682a601b |
child 10091 | e4feb2f9fedf |
permissions | -rw-r--r-- |
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 | 4 |
|
5 |
#ifndef AI_TUNNEL_HPP |
|
6 |
#define AI_TUNNEL_HPP |
|
7 |
||
8 |
#include "ai_object.hpp" |
|
9 |
#include "ai_vehicle.hpp" |
|
10 |
||
11 |
/** |
|
12 |
* Class that handles all tunnel related functions. |
|
13 |
*/ |
|
14 |
class AITunnel : public AIObject { |
|
15 |
public: |
|
16 |
static const char *GetClassName() { return "AITunnel"; } |
|
17 |
||
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 | 44 |
*/ |
45 |
static bool IsTunnelTile(TileIndex tile); |
|
46 |
||
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 | 54 |
*/ |
55 |
static TileIndex GetOtherTunnelEnd(TileIndex tile); |
|
56 |
||
57 |
/** |
|
58 |
* Builds a tunnel starting at start. The direction of the tunnel depends |
|
59 |
* on the slope of the start tile. Tunnels can be created for either |
|
60 |
* rails or roads; use the appropriate AIVehicle::VehicleType. |
|
61 |
* @param start Where to start the tunnel. |
|
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 | 70 |
* @return Whether the tunnel has been/can be build or not. |
71 |
* @note The slope of a tile can be determined by AITile::GetSlope(TileIndex). |
|
72 |
*/ |
|
73 |
static bool BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start); |
|
74 |
||
75 |
/** |
|
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 | 79 |
* @return Whether the tunnel has been/can be removed or not. |
80 |
*/ |
|
81 |
static bool RemoveTunnel(TileIndex tile); |
|
82 |
}; |
|
83 |
||
84 |
#endif /* AI_TUNNEL_HPP */ |