1 /* $Id: script_marine.hpp 23633 2011-12-19 21:05:36Z truebrain $ */
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file script_marine.hpp Everything to query and build marine. */
12 #ifndef SCRIPT_MARINE_HPP
13 #define SCRIPT_MARINE_HPP
15 #include "script_error.hpp"
18 * Class that handles all marine related functions.
21 class ScriptMarine
: public ScriptObject
{
24 * All marine related error messages.
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]
35 * Types of water-related objects in the game.
38 BT_DOCK
, ///< Build a dock
39 BT_DEPOT
, ///< Build a ship depot
40 BT_BUOY
, ///< Build a buoy
44 * Checks whether the given tile is actually a tile with a water depot.
45 * @param tile The tile to check.
46 * @pre ScriptMap::IsValidTile(tile).
47 * @return True if and only if the tile has a water depot.
49 static bool IsWaterDepotTile(TileIndex tile
);
52 * Checks whether the given tile is actually a tile with a dock.
53 * @param tile The tile to check.
54 * @pre ScriptMap::IsValidTile(tile).
55 * @return True if and only if the tile has a dock.
57 static bool IsDockTile(TileIndex tile
);
60 * Checks whether the given tile is actually a tile with a buoy.
61 * @param tile The tile to check.
62 * @pre ScriptMap::IsValidTile(tile).
63 * @return True if and only if the tile has a buoy.
65 static bool IsBuoyTile(TileIndex tile
);
68 * Checks whether the given tile is actually a tile with a lock.
69 * @param tile The tile to check.
70 * @pre ScriptMap::IsValidTile(tile).
71 * @return True if and only if the tile has a lock.
73 static bool IsLockTile(TileIndex tile
);
76 * Checks whether the given tile is actually a tile with a canal.
77 * @param tile The tile to check.
78 * @pre ScriptMap::IsValidTile(tile).
79 * @return True if and only if the tile has a canal.
81 static bool IsCanalTile(TileIndex tile
);
84 * Checks whether the given tiles are directly connected, i.e. whether
85 * a ship vehicle can travel from the center of the first tile to the
86 * center of the second tile.
87 * @param tile_from The source tile.
88 * @param tile_to The destination tile.
89 * @pre ScriptMap::IsValidTile(tile_from).
90 * @pre ScriptMap::IsValidTile(tile_to).
91 * @pre 'tile_from' and 'tile_to' are directly neighbouring tiles.
92 * @return True if and only if a ship can go from tile_from to tile_to.
94 static bool AreWaterTilesConnected(TileIndex tile_from
, TileIndex tile_to
);
97 * Builds a water depot on tile.
98 * @param tile The tile where the water depot will be build.
99 * @param front A tile on the same axis with 'tile' as the depot shall be oriented.
100 * @pre ScriptMap::IsValidTile(tile).
101 * @pre ScriptMap::IsValidTile(front).
102 * @game @pre Valid ScriptCompanyMode active in scope.
103 * @exception ScriptError::ERR_AREA_NOT_CLEAR
104 * @exception ScriptError::ERR_SITE_UNSUITABLE
105 * @exception ScriptMarine::ERR_MARINE_MUST_BE_BUILT_ON_WATER
106 * @return Whether the water depot has been/can be build or not.
107 * @note A WaterDepot is 1 tile in width, and 2 tiles in length.
108 * @note The depot will be built towards the south from 'tile', not necessarily towards 'front'.
110 static bool BuildWaterDepot(TileIndex tile
, TileIndex front
);
113 * Builds a dock where tile is the tile still on land.
114 * @param tile The tile still on land of the dock.
115 * @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
116 * @pre ScriptMap::IsValidTile(tile).
117 * @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id).
118 * @game @pre Valid ScriptCompanyMode active in scope.
119 * @exception ScriptError::ERR_AREA_NOT_CLEAR
120 * @exception ScriptError::ERR_SITE_UNSUITABLE
121 * @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
122 * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS
123 * @return Whether the dock has been/can be build or not.
125 static bool BuildDock(TileIndex tile
, StationID station_id
);
128 * Builds a buoy on tile.
129 * @param tile The tile where the buoy will be build.
130 * @pre ScriptMap::IsValidTile(tile).
131 * @game @pre Valid ScriptCompanyMode active in scope.
132 * @exception ScriptError::ERR_AREA_NOT_CLEAR
133 * @exception ScriptError::ERR_SITE_UNSUITABLE
134 * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS
135 * @return Whether the buoy has been/can be build or not.
137 static bool BuildBuoy(TileIndex tile
);
140 * Builds a lock on tile.
141 * @param tile The tile where the lock will be build.
142 * @pre ScriptMap::IsValidTile(tile).
143 * @game @pre Valid ScriptCompanyMode active in scope.
144 * @exception ScriptError::ERR_LAND_SLOPED_WRONG
145 * @exception ScriptError::ERR_SITE_UNSUITABLE
146 * @return Whether the lock has been/can be build or not.
148 static bool BuildLock(TileIndex tile
);
151 * Builds a canal on tile.
152 * @param tile The tile where the canal will be build.
153 * @pre ScriptMap::IsValidTile(tile).
154 * @game @pre Valid ScriptCompanyMode active in scope.
155 * @exception ScriptError::ERR_AREA_NOT_CLEAR
156 * @exception ScriptError::ERR_LAND_SLOPED_WRONG
157 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
158 * @exception ScriptError::ERR_ALREADY_BUILT
159 * @return Whether the canal has been/can be build or not.
161 static bool BuildCanal(TileIndex tile
);
164 * Removes a water depot.
165 * @param tile Any tile of the water depot.
166 * @pre ScriptMap::IsValidTile(tile).
167 * @game @pre Valid ScriptCompanyMode active in scope.
168 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
169 * @return Whether the water depot has been/can be removed or not.
171 static bool RemoveWaterDepot(TileIndex tile
);
175 * @param tile Any tile of the dock.
176 * @pre ScriptMap::IsValidTile(tile).
177 * @game @pre Valid ScriptCompanyMode active in scope.
178 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
179 * @return Whether the dock has been/can be removed or not.
181 static bool RemoveDock(TileIndex tile
);
185 * @param tile Any tile of the buoy.
186 * @pre ScriptMap::IsValidTile(tile).
187 * @game @pre Valid ScriptCompanyMode active in scope.
188 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
189 * @return Whether the buoy has been/can be removed or not.
191 static bool RemoveBuoy(TileIndex tile
);
195 * @param tile Any tile of the lock.
196 * @pre ScriptMap::IsValidTile(tile).
197 * @game @pre Valid ScriptCompanyMode active in scope.
198 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
199 * @return Whether the lock has been/can be removed or not.
201 static bool RemoveLock(TileIndex tile
);
205 * @param tile Any tile of the canal.
206 * @pre ScriptMap::IsValidTile(tile).
207 * @game @pre Valid ScriptCompanyMode active in scope.
208 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
209 * @return Whether the canal has been/can be removed or not.
211 static bool RemoveCanal(TileIndex tile
);
214 * Get the baseprice of building a water-related object.
215 * @param build_type the type of object to build
216 * @return The baseprice of building the given object.
218 static Money
GetBuildCost(BuildType build_type
);
221 #endif /* SCRIPT_MARINE_HPP */