@@ -56,49 +56,49 @@
if (!::IsValidTile(t1)) return false;
if (!::IsValidTile(t2)) return false;
/* Tiles not neighbouring */
if (::DistanceManhattan(t1, t2) != 1) return false;
DiagDirection to_other_tile = ::DiagdirBetweenTiles(t1, t2);
/* Determine the reachable tracks from the shared edge */
TrackBits gtts1 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t1, TRANSPORT_WATER, 0, to_other_tile)) & ::DiagdirReachesTracks(to_other_tile);
if (gtts1 == TRACK_BIT_NONE) return false;
to_other_tile = ReverseDiagDir(to_other_tile);
TrackBits gtts2 = ::TrackStatusToTrackBits(::GetTileTrackStatus(t2, TRANSPORT_WATER, 0, to_other_tile)) & ::DiagdirReachesTracks(to_other_tile);
return gtts2 != TRACK_BIT_NONE;
}
/* static */ bool AIMarine::BuildWaterDepot(TileIndex tile, TileIndex front)
{
EnforcePrecondition(false, ::IsValidTile(tile));
EnforcePrecondition(false, ::IsValidTile(front));
EnforcePrecondition(false, (::TileX(front) == ::TileX(tile)) != (::TileY(front) == ::TileY(tile)));
return AIObject::DoCommand(tile, ::TileY(front) == ::TileY(tile), 0, CMD_BUILD_SHIP_DEPOT);
return AIObject::DoCommand(tile, ::TileX(front) == ::TileX(tile), 0, CMD_BUILD_SHIP_DEPOT);
/* static */ bool AIMarine::BuildDock(TileIndex tile, StationID station_id)
EnforcePrecondition(false, station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id));
uint p1 = station_id == AIStation::STATION_JOIN_ADJACENT ? 0 : 1;
uint p2 = (AIStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16;
return AIObject::DoCommand(tile, p1, p2, CMD_BUILD_DOCK);
/* static */ bool AIMarine::BuildBuoy(TileIndex tile)
return AIObject::DoCommand(tile, 0, 0, CMD_BUILD_BUOY);
/* static */ bool AIMarine::BuildLock(TileIndex tile)
return AIObject::DoCommand(tile, 0, 0, CMD_BUILD_LOCK);
@@ -86,48 +86,49 @@ public:
/**
* Checks whether the given tiles are directly connected, i.e. whether
* a ship vehicle can travel from the center of the first tile to the
* center of the second tile.
* @param tile_from The source tile.
* @param tile_to The destination tile.
* @pre AIMap::IsValidTile(tile_from).
* @pre AIMap::IsValidTile(tile_to).
* @pre 'tile_from' and 'tile_to' are directly neighbouring tiles.
* @return True if and only if a ship can go from tile_from to tile_to.
*/
static bool AreWaterTilesConnected(TileIndex tile_from, TileIndex tile_to);
* Builds a water depot on tile.
* @param tile The tile where the water depot will be build.
* @param front A tile on the same axis with 'tile' as the depot shall be oriented.
* @pre AIMap::IsValidTile(tile).
* @pre AIMap::IsValidTile(front).
* @exception AIError::ERR_AREA_NOT_CLEAR
* @exception AIError::ERR_SITE_UNSUITABLE
* @exception AIMarine::ERR_MARINE_MUST_BE_BUILT_ON_WATER
* @return Whether the water depot has been/can be build or not.
* @note A WaterDepot is 1 tile in width, and 2 tiles in length.
* @note The depot will be built towards the south from 'tile', not necessarily towards 'front'.
static bool BuildWaterDepot(TileIndex tile, TileIndex front);
* Builds a dock where tile is the tile still on land.
* @param tile The tile still on land of the dock.
* @param station_id The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT.
* @pre station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id).
* @exception AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
* @exception AIStation::ERR_STATION_TOO_MANY_STATIONS
* @return Whether the dock has been/can be build or not.
static bool BuildDock(TileIndex tile, StationID station_id);
* Builds a buoy on tile.
* @param tile The tile where the buoy will be build.
Status change: