| author | truebrain |
| Mon, 30 Jun 2008 12:15:10 +0000 | |
| branch | noai |
| changeset 11097 | 6967c52c78c5 |
| parent 10977 | 6c1a6657c7db |
| 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 |
|
10691
a60393d87c0b
(svn r13235) [NoAI] -Change [API CHANGE]: AITunnel.GetOtherTunnelEnd() now returns INVALID_TILE if no other end is found
glx
parents:
10091
diff
changeset
|
53 |
* INVALID_TILE if no other end was found (can't build tunnel). |
| 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. |
|
|
10977
6c1a6657c7db
(svn r13531) [NoAI] -Add [API CHANGE]: when building a bridge/tunnel for road/tram, the BuildBridge/BuildTunnel function will now also make two half-road/half-tram pieces on both ends of the bridge/tunnel, so it is easier for you to connect them to your network. This give a more consistant behavior for road.
truebrain
parents:
10691
diff
changeset
|
61 |
* As an extra for road, this functions builds two half-pieces of road on |
|
6c1a6657c7db
(svn r13531) [NoAI] -Add [API CHANGE]: when building a bridge/tunnel for road/tram, the BuildBridge/BuildTunnel function will now also make two half-road/half-tram pieces on both ends of the bridge/tunnel, so it is easier for you to connect them to your network. This give a more consistant behavior for road.
truebrain
parents:
10691
diff
changeset
|
62 |
* each end of the tunnel, making it easier for you to connect it to your |
|
6c1a6657c7db
(svn r13531) [NoAI] -Add [API CHANGE]: when building a bridge/tunnel for road/tram, the BuildBridge/BuildTunnel function will now also make two half-road/half-tram pieces on both ends of the bridge/tunnel, so it is easier for you to connect them to your network. This give a more consistant behavior for road.
truebrain
parents:
10691
diff
changeset
|
63 |
* network. |
| 9794 | 64 |
* @param start Where to start the tunnel. |
65 |
* @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
|
66 |
* @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
|
67 |
* @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
|
68 |
* @exception AIError::ERR_AREA_NOT_CLEAR |
|
922c6e6a8d3e
(svn r12612) [NoAI] -Add: support for GetLastError for AITunnel. Patch by Morloth.
rubidium
parents:
9838
diff
changeset
|
69 |
* @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
|
70 |
* @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
|
71 |
* @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
|
72 |
* @exception AITunnel::ERR_TUNNEL_END_SITE_UNSUITABLE |
| 9794 | 73 |
* @return Whether the tunnel has been/can be build or not. |
74 |
* @note The slope of a tile can be determined by AITile::GetSlope(TileIndex). |
|
|
10977
6c1a6657c7db
(svn r13531) [NoAI] -Add [API CHANGE]: when building a bridge/tunnel for road/tram, the BuildBridge/BuildTunnel function will now also make two half-road/half-tram pieces on both ends of the bridge/tunnel, so it is easier for you to connect them to your network. This give a more consistant behavior for road.
truebrain
parents:
10691
diff
changeset
|
75 |
* @note No matter if the road pieces were build or not, if building the |
|
6c1a6657c7db
(svn r13531) [NoAI] -Add [API CHANGE]: when building a bridge/tunnel for road/tram, the BuildBridge/BuildTunnel function will now also make two half-road/half-tram pieces on both ends of the bridge/tunnel, so it is easier for you to connect them to your network. This give a more consistant behavior for road.
truebrain
parents:
10691
diff
changeset
|
76 |
* tunnel succeeded, this function returns true. |
| 9794 | 77 |
*/ |
78 |
static bool BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start); |
|
79 |
||
80 |
/** |
|
81 |
* 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
|
82 |
* @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
|
83 |
* @pre AIMap::IsValidTile(tile) && IsTunnelTile(tile). |
|
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10088
diff
changeset
|
84 |
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
| 9794 | 85 |
* @return Whether the tunnel has been/can be removed or not. |
86 |
*/ |
|
87 |
static bool RemoveTunnel(TileIndex tile); |
|
88 |
}; |
|
89 |
||
90 |
#endif /* AI_TUNNEL_HPP */ |