# AIMarine Class Reference

Class that handles all marine related functions. More...

`#include <ai_marine.hpp>`

Inheritance diagram for AIMarine:

## Public Types

enum | ErrorMessages { ERR_MARINE_BASE = AIError::ERR_CAT_MARINE << AIError::ERR_CAT_BIT_SIZE, ERR_MARINE_MUST_BE_BUILT_ON_WATER }
| All marine related error messages. More...

## Static Public Member Functions

static const char * | GetClassName ()
static bool | IsWaterDepotTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a water depot.
static bool | IsDockTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a dock.
static bool | IsBuoyTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a buoy.
static bool | IsLockTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a lock.
static bool | IsCanalTile (TileIndex tile)
| Checks whether the given tile is actually a tile with a canal.
static bool | AreWaterTilesConnected (TileIndex tile_from, TileIndex tile_to)
| Checks whether the given tiles are directly connected, i.e.
static bool | BuildWaterDepot (TileIndex tile, TileIndex front)
| Builds a water depot on tile.
static bool | BuildDock (TileIndex tile, StationID station_id)
| Builds a dock where tile is the tile still on land.
static bool | BuildBuoy (TileIndex tile)
| Builds a buoy on tile.
static bool | BuildLock (TileIndex tile)
| Builds a lock on tile.
static bool | BuildCanal (TileIndex tile)
| Builds a canal on tile.
static bool | RemoveWaterDepot (TileIndex tile)
| Removes a water depot.
static bool | RemoveDock (TileIndex tile)
| Removes a dock.
static bool | RemoveBuoy (TileIndex tile)
| Removes a buoy.
static bool | RemoveLock (TileIndex tile)
| Removes a lock.
static bool | RemoveCanal (TileIndex tile)
| Removes a canal.

## Detailed Description

Class that handles all marine related functions.

Definition at line 14 of file ai_marine.hpp.

## Member Enumeration Documentation

enum AIMarine::ErrorMessages

All marine related error messages.

Enumerator:

  ERR_MARINE_BASE | Base for marine related errors.
  ERR_MARINE_MUST_BE_BUILT_ON_WATER | Infrastructure must be built on water.

Definition at line 21 of file ai_marine.hpp.

## Member Function Documentation

bool AIMarine::IsWaterDepotTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a water depot.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a water depot.

Definition at line 11 of file ai_marine.cpp.

References IsTileType(), IsValidTile(), and MP_WATER.

Referenced by RemoveWaterDepot().

bool AIMarine::IsDockTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a dock.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a dock.

Definition at line 18 of file ai_marine.cpp.

References IsTileType(), IsValidTile(), and MP_STATION.

Referenced by RemoveDock().

bool AIMarine::IsBuoyTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a buoy.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a buoy.

Definition at line 25 of file ai_marine.cpp.

References IsTileType(), IsValidTile(), and MP_STATION.

Referenced by RemoveBuoy().

bool AIMarine::IsLockTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a lock.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a lock.

Definition at line 32 of file ai_marine.cpp.

References IsTileType(), IsValidTile(), and MP_WATER.

Referenced by RemoveLock().

bool AIMarine::IsCanalTile | ( | TileIndex | tile | ) | `[static]`

Checks whether the given tile is actually a tile with a canal.

Parameters:

  | tile | The tile to check.

Precondition:
  AIMap::IsValidTile(tile).

Returns:
  True if and only if the tile has a canal.

Definition at line 39 of file ai_marine.cpp.

References IsTileType(), IsValidTile(), and MP_WATER.

Referenced by RemoveCanal().

bool AIMarine::AreWaterTilesConnected | ( | TileIndex | tile_from,
|  | TileIndex | tile_to |
| ) |  |  | `[static]`

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.

Parameters:

  | tile_from | The source tile.
  | tile_to | The destination tile.

Precondition:
  AIMap::IsValidTile(tile_from).

  AIMap::IsValidTile(tile_to).

  'tile_from' and 'tile_to' are directly neighbouring tiles.

Returns:
  True if and only if a ship can go from tile_from to tile_to.

Definition at line 46 of file ai_marine.cpp.

References DIAGDIR_SE, DIAGDIR_SW, DiagdirReachesTracks(), DistanceManhattan(), GetTileTrackStatus(), IsValidTile(), ReverseDiagDir(), Swap(), TileX(), TRACK_BIT_NONE, TrackStatusToTrackBits(), and TRANSPORT_WATER.

bool AIMarine::BuildWaterDepot | ( | TileIndex | tile,
|  | TileIndex | front |
| ) |  |  | `[static]`

Builds a water depot on tile.

Parameters:

  | tile | The tile where the water depot will be build.
  | front | A tile on the same axis with 'tile' as the depot shall be oriented.

Precondition:
  AIMap::IsValidTile(tile).

  AIMap::IsValidTile(front).

Exceptions:

  | AIError::ERR_AREA_NOT_CLEAR |
  | AIError::ERR_SITE_UNSUITABLE |
  | AIMarine::ERR_MARINE_MUST_BE_BUILT_ON_WATER |

Returns:
  Whether the water depot has been/can be build or not.

Note:
  A WaterDepot is 1 tile in width, and 2 tiles in length.

Definition at line 67 of file ai_marine.cpp.

References CMD_BUILD_SHIP_DEPOT, AIObject::DoCommand(), EnforcePrecondition, IsValidTile(), TileX(), and TileY().

bool AIMarine::BuildDock | ( | TileIndex | tile,
|  | StationID | station_id |
| ) |  |  | `[static]`

Builds a dock where tile is the tile still on land.

Parameters:

  | tile | The tile still on land of the dock.
  | station_id | The station to join, AIStation::STATION_NEW or AIStation::STATION_JOIN_ADJACENT.

Precondition:
  AIMap::IsValidTile(tile).

  station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id).

Exceptions:

  | AIError::ERR_AREA_NOT_CLEAR |
  | AIError::ERR_SITE_UNSUITABLE |
  | AIStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION |
  | AIStation::ERR_STATION_TOO_MANY_STATIONS |

Returns:
  Whether the dock has been/can be build or not.

Definition at line 76 of file ai_marine.cpp.

References CMD_BUILD_DOCK, AIObject::DoCommand(), EnforcePrecondition, AIStation::IsValidStation(), IsValidTile(), AIStation::STATION_JOIN_ADJACENT, and AIStation::STATION_NEW.

bool AIMarine::BuildBuoy | ( | TileIndex | tile | ) | `[static]`

Builds a buoy on tile.

Parameters:

  | tile | The tile where the buoy will be build.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_AREA_NOT_CLEAR |
  | AIError::ERR_SITE_UNSUITABLE |
  | AIStation::ERR_STATION_TOO_MANY_STATIONS |

Returns:
  Whether the buoy has been/can be build or not.

Definition at line 86 of file ai_marine.cpp.

References CMD_BUILD_BUOY, AIObject::DoCommand(), EnforcePrecondition, and IsValidTile().

bool AIMarine::BuildLock | ( | TileIndex | tile | ) | `[static]`

Builds a lock on tile.

Parameters:

  | tile | The tile where the lock will be build.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_LAND_SLOPED_WRONG |
  | AIError::ERR_SITE_UNSUITABLE |

Returns:
  Whether the lock has been/can be build or not.

Definition at line 93 of file ai_marine.cpp.

References CMD_BUILD_LOCK, AIObject::DoCommand(), EnforcePrecondition, and IsValidTile().

bool AIMarine::BuildCanal | ( | TileIndex | tile | ) | `[static]`

Builds a canal on tile.

Parameters:

  | tile | The tile where the canal will be build.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_AREA_NOT_CLEAR |
  | AIError::ERR_LAND_SLOPED_WRONG |
  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |
  | AIError::ERR_ALREADY_BUILT |

Returns:
  Whether the canal has been/can be build or not.

Definition at line 100 of file ai_marine.cpp.

References CMD_BUILD_CANAL, AIObject::DoCommand(), EnforcePrecondition, and IsValidTile().

bool AIMarine::RemoveWaterDepot | ( | TileIndex | tile | ) | `[static]`

Removes a water depot.

Parameters:

  | tile | Any tile of the water depot.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |

Returns:
  Whether the water depot has been/can be removed or not.

Definition at line 107 of file ai_marine.cpp.

References CMD_LANDSCAPE_CLEAR, AIObject::DoCommand(), EnforcePrecondition, IsValidTile(), and IsWaterDepotTile().

bool AIMarine::RemoveDock | ( | TileIndex | tile | ) | `[static]`

Removes a dock.

Parameters:

  | tile | Any tile of the dock.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |

Returns:
  Whether the dock has been/can be removed or not.

Definition at line 115 of file ai_marine.cpp.

References CMD_LANDSCAPE_CLEAR, AIObject::DoCommand(), EnforcePrecondition, IsDockTile(), and IsValidTile().

bool AIMarine::RemoveBuoy | ( | TileIndex | tile | ) | `[static]`

Removes a buoy.

Parameters:

  | tile | Any tile of the buoy.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |

Returns:
  Whether the buoy has been/can be removed or not.

Definition at line 123 of file ai_marine.cpp.

References CMD_LANDSCAPE_CLEAR, AIObject::DoCommand(), EnforcePrecondition, IsBuoyTile(), and IsValidTile().

bool AIMarine::RemoveLock | ( | TileIndex | tile | ) | `[static]`

Removes a lock.

Parameters:

  | tile | Any tile of the lock.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |

Returns:
  Whether the lock has been/can be removed or not.

Definition at line 131 of file ai_marine.cpp.

References CMD_LANDSCAPE_CLEAR, AIObject::DoCommand(), EnforcePrecondition, IsLockTile(), and IsValidTile().

bool AIMarine::RemoveCanal | ( | TileIndex | tile | ) | `[static]`

Removes a canal.

Parameters:

  | tile | Any tile of the canal.

Precondition:
  AIMap::IsValidTile(tile).

Exceptions:

  | AIError::ERR_OWNED_BY_ANOTHER_COMPANY |

Returns:
  Whether the canal has been/can be removed or not.

Definition at line 139 of file ai_marine.cpp.

References CMD_LANDSCAPE_CLEAR, AIObject::DoCommand(), EnforcePrecondition, IsCanalTile(), and IsValidTile().

The documentation for this class was generated from the following files:

- src/ai/api/ai_marine.hpp
- src/ai/api/ai_marine.cpp