Update: Translations from eints
[openttd-github.git] / src / script / api / script_marine.hpp
blob7337c8df12838a44297f68593761aa8a6973cffd
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file script_marine.hpp Everything to query and build marine. */
10 #ifndef SCRIPT_MARINE_HPP
11 #define SCRIPT_MARINE_HPP
13 #include "script_error.hpp"
15 /**
16 * Class that handles all marine related functions.
17 * @api ai game
19 class ScriptMarine : public ScriptObject {
20 public:
21 /**
22 * All marine related error messages.
24 * @see ScriptErrorType
26 enum ErrorMessages {
27 /** Base for marine related errors */
28 ERR_MARINE_BASE = ScriptError::ERR_CAT_MARINE << ScriptError::ERR_CAT_BIT_SIZE,
30 /** Infrastructure must be built on water */
31 ERR_MARINE_MUST_BE_BUILT_ON_WATER, // [STR_ERROR_MUST_BE_BUILT_ON_WATER]
34 /**
35 * Types of water-related objects in the game.
37 enum BuildType {
38 BT_DOCK, ///< Build a dock
39 BT_DEPOT, ///< Build a ship depot
40 BT_BUOY, ///< Build a buoy
41 BT_LOCK, ///< Build a lock
42 BT_CANAL, ///< Build a canal
45 /**
46 * Checks whether the given tile is actually a tile with a water depot.
47 * @param tile The tile to check.
48 * @pre ScriptMap::IsValidTile(tile).
49 * @return True if and only if the tile has a water depot.
51 static bool IsWaterDepotTile(TileIndex tile);
53 /**
54 * Checks whether the given tile is actually a tile with a dock.
55 * @param tile The tile to check.
56 * @pre ScriptMap::IsValidTile(tile).
57 * @return True if and only if the tile has a dock.
59 static bool IsDockTile(TileIndex tile);
61 /**
62 * Checks whether the given tile is actually a tile with a buoy.
63 * @param tile The tile to check.
64 * @pre ScriptMap::IsValidTile(tile).
65 * @return True if and only if the tile has a buoy.
67 static bool IsBuoyTile(TileIndex tile);
69 /**
70 * Checks whether the given tile is actually a tile with a lock.
71 * @param tile The tile to check.
72 * @pre ScriptMap::IsValidTile(tile).
73 * @return True if and only if the tile has a lock.
75 static bool IsLockTile(TileIndex tile);
77 /**
78 * Checks whether the given tile is actually a tile with a canal.
79 * @param tile The tile to check.
80 * @pre ScriptMap::IsValidTile(tile).
81 * @return True if and only if the tile has a canal.
83 static bool IsCanalTile(TileIndex tile);
85 /**
86 * Checks whether the given tiles are directly connected, i.e. whether
87 * a ship vehicle can travel from the center of the first tile to the
88 * center of the second tile.
89 * @param tile_from The source tile.
90 * @param tile_to The destination tile.
91 * @pre ScriptMap::IsValidTile(tile_from).
92 * @pre ScriptMap::IsValidTile(tile_to).
93 * @pre 'tile_from' and 'tile_to' are directly neighbouring tiles.
94 * @return True if and only if a ship can go from tile_from to tile_to.
96 static bool AreWaterTilesConnected(TileIndex tile_from, TileIndex tile_to);
98 /**
99 * Builds a water depot on tile.
100 * @param tile The tile where the water depot will be build.
101 * @param front A tile on the same axis with 'tile' as the depot shall be oriented.
102 * @pre ScriptMap::IsValidTile(tile).
103 * @pre ScriptMap::IsValidTile(front).
104 * @game @pre ScriptCompanyMode::IsValid().
105 * @exception ScriptError::ERR_AREA_NOT_CLEAR
106 * @exception ScriptError::ERR_SITE_UNSUITABLE
107 * @exception ScriptMarine::ERR_MARINE_MUST_BE_BUILT_ON_WATER
108 * @return Whether the water depot has been/can be build or not.
109 * @note A WaterDepot is 1 tile in width, and 2 tiles in length.
110 * @note The depot will be built towards the south from 'tile', not necessarily towards 'front'.
112 static bool BuildWaterDepot(TileIndex tile, TileIndex front);
115 * Builds a dock where tile is the tile still on land.
116 * @param tile The tile still on land of the dock.
117 * @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
118 * @pre ScriptMap::IsValidTile(tile).
119 * @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id).
120 * @game @pre ScriptCompanyMode::IsValid().
121 * @exception ScriptError::ERR_AREA_NOT_CLEAR
122 * @exception ScriptError::ERR_SITE_UNSUITABLE
123 * @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
124 * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS
125 * @return Whether the dock has been/can be build or not.
127 static bool BuildDock(TileIndex tile, StationID station_id);
130 * Builds a buoy on tile.
131 * @param tile The tile where the buoy will be build.
132 * @pre ScriptMap::IsValidTile(tile).
133 * @game @pre ScriptCompanyMode::IsValid().
134 * @exception ScriptError::ERR_AREA_NOT_CLEAR
135 * @exception ScriptError::ERR_SITE_UNSUITABLE
136 * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS
137 * @return Whether the buoy has been/can be build or not.
139 static bool BuildBuoy(TileIndex tile);
142 * Builds a lock on tile.
143 * @param tile The tile where the lock will be build.
144 * @pre ScriptMap::IsValidTile(tile).
145 * @game @pre ScriptCompanyMode::IsValid().
146 * @exception ScriptError::ERR_LAND_SLOPED_WRONG
147 * @exception ScriptError::ERR_SITE_UNSUITABLE
148 * @return Whether the lock has been/can be build or not.
150 static bool BuildLock(TileIndex tile);
153 * Builds a canal on tile.
154 * @param tile The tile where the canal will be build.
155 * @pre ScriptMap::IsValidTile(tile).
156 * @game @pre ScriptCompanyMode::IsValid().
157 * @exception ScriptError::ERR_AREA_NOT_CLEAR
158 * @exception ScriptError::ERR_LAND_SLOPED_WRONG
159 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
160 * @exception ScriptError::ERR_ALREADY_BUILT
161 * @return Whether the canal has been/can be build or not.
163 static bool BuildCanal(TileIndex tile);
166 * Removes a water depot.
167 * @param tile Any tile of the water depot.
168 * @pre ScriptMap::IsValidTile(tile).
169 * @game @pre ScriptCompanyMode::IsValid().
170 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
171 * @return Whether the water depot has been/can be removed or not.
173 static bool RemoveWaterDepot(TileIndex tile);
176 * Removes a dock.
177 * @param tile Any tile of the dock.
178 * @pre ScriptMap::IsValidTile(tile).
179 * @game @pre ScriptCompanyMode::IsValid().
180 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
181 * @return Whether the dock has been/can be removed or not.
183 static bool RemoveDock(TileIndex tile);
186 * Removes a buoy.
187 * @param tile Any tile of the buoy.
188 * @pre ScriptMap::IsValidTile(tile).
189 * @game @pre ScriptCompanyMode::IsValid().
190 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
191 * @return Whether the buoy has been/can be removed or not.
193 static bool RemoveBuoy(TileIndex tile);
196 * Removes a lock.
197 * @param tile Any tile of the lock.
198 * @pre ScriptMap::IsValidTile(tile).
199 * @game @pre ScriptCompanyMode::IsValid().
200 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
201 * @return Whether the lock has been/can be removed or not.
203 static bool RemoveLock(TileIndex tile);
206 * Removes a canal.
207 * @param tile Any tile of the canal.
208 * @pre ScriptMap::IsValidTile(tile).
209 * @game @pre ScriptCompanyMode::IsValid().
210 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
211 * @return Whether the canal has been/can be removed or not.
213 static bool RemoveCanal(TileIndex tile);
216 * Get the baseprice of building a water-related object.
217 * @param build_type the type of object to build
218 * @return The baseprice of building the given object.
220 static Money GetBuildCost(BuildType build_type);
223 #endif /* SCRIPT_MARINE_HPP */