OpenTTD Source 20241224-master-gf74b0cf984
ship.h File Reference

Base for ships. More...

#include "vehicle_base.h"
#include "water_map.h"

Go to the source code of this file.

Data Structures

struct  ShipPathElement
 Element of the ShipPathCache. More...
 
struct  Ship
 All ships have this type. More...
 

Typedefs

using ShipPathCache = std::vector< ShipPathElement >
 

Functions

void GetShipSpriteSize (EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
 Get the size of the sprite of a ship sprite heading west (used for lists).
 
WaterClass GetEffectiveWaterClass (TileIndex tile)
 Determine the effective WaterClass for a ship travelling on a tile.
 
bool IsShipDestinationTile (TileIndex tile, StationID station)
 Test if a tile is a docking tile for the given station.
 

Detailed Description

Base for ships.

Definition in file ship.h.

Typedef Documentation

◆ ShipPathCache

using ShipPathCache = std::vector<ShipPathElement>

Definition at line 27 of file ship.h.

Function Documentation

◆ GetEffectiveWaterClass()

WaterClass GetEffectiveWaterClass ( TileIndex  tile)

Determine the effective WaterClass for a ship travelling on a tile.

Parameters
tileTile of interest
Returns
the waterclass to be used by the ship.

Definition at line 54 of file ship_cmd.cpp.

References GetTunnelBridgeTransportType(), GetWaterClass(), HasTileWaterClass(), IsTileType(), MP_RAILWAY, MP_TUNNELBRIDGE, RAIL_GROUND_WATER, TRANSPORT_WATER, WATER_CLASS_CANAL, and WATER_CLASS_SEA.

Referenced by CYapfCostShipT< Types >::PfCalcCost(), and Ship::UpdateCache().

◆ GetShipSpriteSize()

void GetShipSpriteSize ( EngineID  engine,
uint &  width,
uint &  height,
int &  xoffs,
int &  yoffs,
EngineImageType  image_type 
)

Get the size of the sprite of a ship sprite heading west (used for lists).

Parameters
engineThe engine to get the sprite from.
[out]widthThe width of the sprite.
[out]heightThe height of the sprite.
[out]xoffsNumber of pixels to shift the sprite to the right.
[out]yoffsNumber of pixels to shift the sprite downwards.
image_typeContext the sprite is used in.

Definition at line 120 of file ship_cmd.cpp.

References VehicleSpriteSeq::GetBounds(), Rect::Height(), UnScaleGUI(), and Rect::Width().

Referenced by EnginePreviewWindow::UpdateWidgetSize().

◆ IsShipDestinationTile()

bool IsShipDestinationTile ( TileIndex  tile,
StationID  station 
)

Test if a tile is a docking tile for the given station.

Parameters
tileDocking tile to test.
stationDestination station.
Returns
true iff docking tile is next to station.

Definition at line 647 of file ship_cmd.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, Industry::GetByTile(), GetStationIndex(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsDockingTile(), IsDockTile(), IsDockWaterPart(), IsOilRig(), IsTileType(), IsValidTile(), MP_INDUSTRY, MP_STATION, Industry::neutral_station, and TileOffsByDiagDir().

Referenced by RemoveDock().