OpenTTD GameScript API 20241220-master-g59680867c3
Public Types | Static Public Member Functions
GSMarine Class Reference

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

#include <script_marine.hpp>

Inheritance diagram for GSMarine:

Public Types

enum  ErrorMessages {
  ERR_MARINE_BASE ,
  ERR_MARINE_MUST_BE_BUILT_ON_WATER
}
 All marine related error messages. More...
 
enum  BuildType {
  BT_DOCK ,
  BT_DEPOT ,
  BT_BUOY ,
  BT_LOCK ,
  BT_CANAL
}
 Types of water-related objects in the game. More...
 

Static Public Member Functions

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.
 
static Money GetBuildCost (BuildType build_type)
 Get the baseprice of building a water-related object.
 

Detailed Description

Class that handles all marine related functions.

Member Enumeration Documentation

◆ BuildType

Types of water-related objects in the game.

Enumerator
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.

◆ ErrorMessages

All marine related error messages.

See also
ScriptErrorType
Enumerator
ERR_MARINE_BASE 

Base for marine related errors.

ERR_MARINE_MUST_BE_BUILT_ON_WATER 

Infrastructure must be built on water.

Member Function Documentation

◆ AreWaterTilesConnected()

static bool GSMarine::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_fromThe source tile.
tile_toThe destination tile.
Precondition
GSMap::IsValidTile(tile_from).
GSMap::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.

◆ BuildBuoy()

static bool GSMarine::BuildBuoy ( TileIndex  tile)
static

Builds a buoy on tile.

Parameters
tileThe tile where the buoy will be build.
Precondition
GSMap::IsValidTile(tile).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_AREA_NOT_CLEAR
GSError::ERR_SITE_UNSUITABLE
GSStation::ERR_STATION_TOO_MANY_STATIONS
Returns
Whether the buoy has been/can be build or not.

◆ BuildCanal()

static bool GSMarine::BuildCanal ( TileIndex  tile)
static

Builds a canal on tile.

Parameters
tileThe tile where the canal will be build.
Precondition
GSMap::IsValidTile(tile).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_AREA_NOT_CLEAR
GSError::ERR_LAND_SLOPED_WRONG
GSError::ERR_OWNED_BY_ANOTHER_COMPANY
GSError::ERR_ALREADY_BUILT
Returns
Whether the canal has been/can be build or not.

◆ BuildDock()

static bool GSMarine::BuildDock ( TileIndex  tile,
StationID  station_id 
)
static

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

Parameters
tileThe tile still on land of the dock.
station_idThe station to join, GSStation::STATION_NEW or GSStation::STATION_JOIN_ADJACENT.
Precondition
GSMap::IsValidTile(tile).
station_id == GSStation::STATION_NEW || station_id == GSStation::STATION_JOIN_ADJACENT || GSStation::IsValidStation(station_id).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_AREA_NOT_CLEAR
GSError::ERR_SITE_UNSUITABLE
GSStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
GSStation::ERR_STATION_TOO_MANY_STATIONS
Returns
Whether the dock has been/can be build or not.

◆ BuildLock()

static bool GSMarine::BuildLock ( TileIndex  tile)
static

Builds a lock on tile.

Parameters
tileThe tile where the lock will be build.
Precondition
GSMap::IsValidTile(tile).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_LAND_SLOPED_WRONG
GSError::ERR_SITE_UNSUITABLE
Returns
Whether the lock has been/can be build or not.

◆ BuildWaterDepot()

static bool GSMarine::BuildWaterDepot ( TileIndex  tile,
TileIndex  front 
)
static

Builds a water depot on tile.

Parameters
tileThe tile where the water depot will be build.
frontA tile on the same axis with 'tile' as the depot shall be oriented.
Precondition
GSMap::IsValidTile(tile).
GSMap::IsValidTile(front).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_AREA_NOT_CLEAR
GSError::ERR_SITE_UNSUITABLE
GSMarine::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.
The depot will be built towards the south from 'tile', not necessarily towards 'front'.

◆ GetBuildCost()

static Money GSMarine::GetBuildCost ( BuildType  build_type)
static

Get the baseprice of building a water-related object.

Parameters
build_typethe type of object to build
Returns
The baseprice of building the given object.

◆ IsBuoyTile()

static bool GSMarine::IsBuoyTile ( TileIndex  tile)
static

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

Parameters
tileThe tile to check.
Precondition
GSMap::IsValidTile(tile).
Returns
True if and only if the tile has a buoy.

◆ IsCanalTile()

static bool GSMarine::IsCanalTile ( TileIndex  tile)
static

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

Parameters
tileThe tile to check.
Precondition
GSMap::IsValidTile(tile).
Returns
True if and only if the tile has a canal.

◆ IsDockTile()

static bool GSMarine::IsDockTile ( TileIndex  tile)
static

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

Parameters
tileThe tile to check.
Precondition
GSMap::IsValidTile(tile).
Returns
True if and only if the tile has a dock.

◆ IsLockTile()

static bool GSMarine::IsLockTile ( TileIndex  tile)
static

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

Parameters
tileThe tile to check.
Precondition
GSMap::IsValidTile(tile).
Returns
True if and only if the tile has a lock.

◆ IsWaterDepotTile()

static bool GSMarine::IsWaterDepotTile ( TileIndex  tile)
static

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

Parameters
tileThe tile to check.
Precondition
GSMap::IsValidTile(tile).
Returns
True if and only if the tile has a water depot.

◆ RemoveBuoy()

static bool GSMarine::RemoveBuoy ( TileIndex  tile)
static

Removes a buoy.

Parameters
tileAny tile of the buoy.
Precondition
GSMap::IsValidTile(tile).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_OWNED_BY_ANOTHER_COMPANY
Returns
Whether the buoy has been/can be removed or not.

◆ RemoveCanal()

static bool GSMarine::RemoveCanal ( TileIndex  tile)
static

Removes a canal.

Parameters
tileAny tile of the canal.
Precondition
GSMap::IsValidTile(tile).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_OWNED_BY_ANOTHER_COMPANY
Returns
Whether the canal has been/can be removed or not.

◆ RemoveDock()

static bool GSMarine::RemoveDock ( TileIndex  tile)
static

Removes a dock.

Parameters
tileAny tile of the dock.
Precondition
GSMap::IsValidTile(tile).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_OWNED_BY_ANOTHER_COMPANY
Returns
Whether the dock has been/can be removed or not.

◆ RemoveLock()

static bool GSMarine::RemoveLock ( TileIndex  tile)
static

Removes a lock.

Parameters
tileAny tile of the lock.
Precondition
GSMap::IsValidTile(tile).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_OWNED_BY_ANOTHER_COMPANY
Returns
Whether the lock has been/can be removed or not.

◆ RemoveWaterDepot()

static bool GSMarine::RemoveWaterDepot ( TileIndex  tile)
static

Removes a water depot.

Parameters
tileAny tile of the water depot.
Precondition
GSMap::IsValidTile(tile).
GSCompanyMode::IsValid().
Exceptions
GSError::ERR_OWNED_BY_ANOTHER_COMPANY
Returns
Whether the water depot has been/can be removed or not.