1 /* $Id$ */ |
1 /* $Id$ */ |
2 |
2 |
3 /** @file ai_airport.cpp Implementation of AIAirport. */ |
3 /** @file ai_airport.cpp Implementation of AIAirport. */ |
4 |
4 |
5 #include "ai_airport.hpp" |
5 #include "ai_airport.hpp" |
|
6 #include "ai_error.hpp" |
6 #include "../../openttd.h" |
7 #include "../../openttd.h" |
7 #include "../../variables.h" |
8 #include "../../variables.h" |
8 #include "../../station_map.h" |
9 #include "../../station_map.h" |
9 #include "../../player_func.h" |
10 #include "../../player_func.h" |
10 #include "../../settings_type.h" |
11 #include "../../settings_type.h" |
47 return _patches.modified_catchment ? ::GetAirport(type)->catchment : (uint)CA_UNMODIFIED; |
48 return _patches.modified_catchment ? ::GetAirport(type)->catchment : (uint)CA_UNMODIFIED; |
48 } |
49 } |
49 |
50 |
50 /* static */ bool AIAirport::BuildAirport(TileIndex tile, AirportType type) |
51 /* static */ bool AIAirport::BuildAirport(TileIndex tile, AirportType type) |
51 { |
52 { |
52 if (!::IsValidTile(tile)) return false; |
53 if (!::IsValidTile(tile) || type > AT_HELISTATION) { |
53 if (type > AT_HELISTATION) return 0; |
54 AIObject::SetLastError(AIError::ERR_PRECONDITION_FAILED); |
|
55 return false; |
|
56 } |
54 |
57 |
55 return AIObject::DoCommand(tile, type, 0, CMD_BUILD_AIRPORT); |
58 return AIObject::DoCommand(tile, type, 0, CMD_BUILD_AIRPORT); |
56 } |
59 } |
57 |
60 |
58 /* static */ bool AIAirport::RemoveAirport(TileIndex tile) |
61 /* static */ bool AIAirport::RemoveAirport(TileIndex tile) |
59 { |
62 { |
60 if (!::IsValidTile(tile)) return false; |
63 if (!::IsValidTile(tile) || !(IsAirportTile(tile) || IsHangarTile(tile))) { |
61 if (!IsAirportTile(tile) && !IsHangarTile(tile)) return false; |
64 AIObject::SetLastError(AIError::ERR_PRECONDITION_FAILED); |
|
65 return false; |
|
66 } |
62 |
67 |
63 return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); |
68 return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); |
64 } |
69 } |
65 |
70 |
66 /* static */ TileIndex AIAirport::GetHangarOfAirport(TileIndex tile) |
71 /* static */ TileIndex AIAirport::GetHangarOfAirport(TileIndex tile) |