diff options
author | SamuXarick <43006711+SamuXarick@users.noreply.github.com> | 2021-09-14 21:06:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 22:06:55 +0200 |
commit | 37de87812994be72399a9588473ece1c514397c0 (patch) | |
tree | b450411376890b3ac8310dcca2f5b9bad3ca830f /src/script/api | |
parent | c6035158ca9df31d12ba28acf2037ff7d5aeb248 (diff) | |
download | openttd-37de87812994be72399a9588473ece1c514397c0.tar.xz |
Feature: [AI/GS] Missing water related functions and objects (#8390)
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/ai_changelog.hpp | 5 | ||||
-rw-r--r-- | src/script/api/game_changelog.hpp | 5 | ||||
-rw-r--r-- | src/script/api/script_marine.cpp | 2 | ||||
-rw-r--r-- | src/script/api/script_marine.hpp | 2 | ||||
-rw-r--r-- | src/script/api/script_tile.cpp | 15 | ||||
-rw-r--r-- | src/script/api/script_tile.hpp | 18 |
6 files changed, 47 insertions, 0 deletions
diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index e5699a7d4..f977168e4 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -21,6 +21,11 @@ * \li AINewGRF * \li AINewGRFList * \li AIGroup::GetNumVehicles + * \li AIMarine::BT_LOCK + * \li AIMarine::BT_CANAL + * \li AITile::IsSeaTile + * \li AITile::IsRiverTile + * \li AITile::BT_CLEAR_WATER * * \b 1.11.0 * diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index d3efea919..8eab8956e 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -20,6 +20,11 @@ * API additions: * \li GSNewGRF * \li GSNewGRFList + * \li GSMarine::BT_LOCK + * \li GSMarine::BT_CANAL + * \li GSTile::IsSeaTile + * \li GSTile::IsRiverTile + * \li GSTile::BT_CLEAR_WATER * * \b 1.11.0 * diff --git a/src/script/api/script_marine.cpp b/src/script/api/script_marine.cpp index c63add8fa..16f0228db 100644 --- a/src/script/api/script_marine.cpp +++ b/src/script/api/script_marine.cpp @@ -167,6 +167,8 @@ case BT_DOCK: return ::GetPrice(PR_BUILD_STATION_DOCK, 1, nullptr); case BT_DEPOT: return ::GetPrice(PR_BUILD_DEPOT_SHIP, 1, nullptr); case BT_BUOY: return ::GetPrice(PR_BUILD_WAYPOINT_BUOY, 1, nullptr); + case BT_LOCK: return ::GetPrice(PR_BUILD_LOCK, 1, nullptr); + case BT_CANAL: return ::GetPrice(PR_BUILD_CANAL, 1, nullptr); default: return -1; } } diff --git a/src/script/api/script_marine.hpp b/src/script/api/script_marine.hpp index 324ed8f3e..b3ba02210 100644 --- a/src/script/api/script_marine.hpp +++ b/src/script/api/script_marine.hpp @@ -36,6 +36,8 @@ public: BT_DOCK, ///< Build a dock BT_DEPOT, ///< Build a ship depot BT_BUOY, ///< Build a buoy + BT_LOCK, ///< Build a lock + BT_CANAL, ///< Build a canal }; /** diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp index 360b32c02..90411a7f7 100644 --- a/src/script/api/script_tile.cpp +++ b/src/script/api/script_tile.cpp @@ -58,6 +58,20 @@ return true; } +/* static */ bool ScriptTile::IsSeaTile(TileIndex tile) +{ + if (!::IsValidTile(tile)) return false; + + return ::IsTileType(tile, MP_WATER) && ::IsSea(tile); +} + +/* static */ bool ScriptTile::IsRiverTile(TileIndex tile) +{ + if (!::IsValidTile(tile)) return false; + + return ::IsTileType(tile, MP_WATER) && ::IsRiver(tile); +} + /* static */ bool ScriptTile::IsWaterTile(TileIndex tile) { if (!::IsValidTile(tile)) return false; @@ -320,6 +334,7 @@ case BT_CLEAR_ROCKY: return ::GetPrice(PR_CLEAR_ROCKS, 1, nullptr); case BT_CLEAR_FIELDS: return ::GetPrice(PR_CLEAR_FIELDS, 1, nullptr); case BT_CLEAR_HOUSE: return ::GetPrice(PR_CLEAR_HOUSE, 1, nullptr); + case BT_CLEAR_WATER: return ::GetPrice(PR_CLEAR_WATER, 1, nullptr); default: return -1; } } diff --git a/src/script/api/script_tile.hpp b/src/script/api/script_tile.hpp index 423044b21..4ee12c691 100644 --- a/src/script/api/script_tile.hpp +++ b/src/script/api/script_tile.hpp @@ -119,6 +119,7 @@ public: BT_CLEAR_ROCKY, ///< Clear a tile with rocks BT_CLEAR_FIELDS, ///< Clear a tile with farm fields BT_CLEAR_HOUSE, ///< Clear a tile with a house + BT_CLEAR_WATER, ///< Clear a tile with either river or sea }; /** @@ -159,10 +160,27 @@ public: static bool IsBuildableRectangle(TileIndex tile, uint width, uint height); /** + * Checks whether the given tile is actually a sea tile. + * @param tile The tile to check on. + * @pre ScriptMap::IsValidTile(tile). + * @return True if and only if the tile is a sea tile. + */ + static bool IsSeaTile(TileIndex tile); + + /** + * Checks whether the given tile is actually a river tile. + * @param tile The tile to check on. + * @pre ScriptMap::IsValidTile(tile). + * @return True if and only if the tile is a river tile. + */ + static bool IsRiverTile(TileIndex tile); + + /** * Checks whether the given tile is actually a water tile. * @param tile The tile to check on. * @pre ScriptMap::IsValidTile(tile). * @return True if and only if the tile is a water tile. + * @note Returns false when a buoy is on the tile. */ static bool IsWaterTile(TileIndex tile); |