OpenTTD Source: src/water.h File Reference

OpenTTD Source 15.0-RC2

Enumerations | Functions | Variables
water.h File Reference

Functions related to water (management) More...

`#include "water_map.h"`
`#include "economy_func.h"`

Go to the source code of this file.

## Enumerations
enum | FloodingBehaviour : uint8_t { FLOOD_NONE , FLOOD_ACTIVE , FLOOD_PASSIVE , FLOOD_DRYUP }
| Describes the behaviour of a tile during flooding. More...

## Functions
FloodingBehaviour | GetFloodingBehaviour (TileIndex tile)
| Returns the behaviour of a tile during flooding.
void | ClearNeighbourNonFloodingStates (TileIndex tile)
| Clear non-flooding state of the tiles around a tile.
void | TileLoop_Water (TileIndex tile)
| Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd, and by TileLoop_Industry() and TileLoop_Track()
bool | FloodHalftile (TileIndex t)
| Called from water_cmd if a non-flat rail-tile gets flooded and should be converted to shore.
void | ConvertGroundTilesIntoWaterTiles ()
void | DrawShipDepotSprite (int x, int y, Axis axis, DepotPart part)
void | DrawWaterClassGround (const struct TileInfo *ti)
void | DrawShoreTile (Slope tileh)
void | MakeWaterKeepingClass (TileIndex tile, Owner o)
void | CheckForDockingTile (TileIndex t)
| Mark the supplied tile as a docking tile if it is suitable for docking.
void | MakeRiverAndModifyDesertZoneAround (TileIndex tile)
| Make a river tile and remove desert directly around it.
void | RiverMakeWider (TileIndex tile, TileIndex origin_tile)
| Widen a river by expanding into adjacent tiles via circular tile search.
bool | RiverFlowsDown (TileIndex begin, TileIndex end)
| Check whether a river at begin could (logically) flow down to end.
bool | IsWateredTile (TileIndex tile, Direction from)
| return true if a tile is a water tile wrt.
Money | CanalMaintenanceCost (uint32_t num)
| Calculates the maintenance cost of a number of canal tiles.

## Variables
static const uint | RIVER_OFFSET_DESERT_DISTANCE = 5
| Circular tile search diameter to create non-desert around a river tile.

## Detailed Description

Functions related to water (management)

Definition in file water.h.

## Enumeration Type Documentation

## ◆ FloodingBehaviour

enum FloodingBehaviour : uint8_t

Describes the behaviour of a tile during flooding.

Enumerator
FLOOD_NONE | The tile does not flood neighboured tiles.
FLOOD_ACTIVE | The tile floods neighboured tiles.
FLOOD_PASSIVE | The tile does not actively flood neighboured tiles, but it prevents them from drying up.
FLOOD_DRYUP | The tile drys up if it is not constantly flooded from neighboured tiles.

Definition at line 19 of file water.h.

## Function Documentation

## ◆ CanalMaintenanceCost()

Money CanalMaintenanceCost | ( | uint32_t | num | ) |
| inline

Calculates the maintenance cost of a number of canal tiles.

Parameters

  num | Number of canal tiles.

Returns
  Total cost.

Definition at line 53 of file water.h.

References IntSqrt().

Referenced by CompaniesGenStatistics().

## ◆ CheckForDockingTile()

void CheckForDockingTile | ( | TileIndex | t | ) |

Mark the supplied tile as a docking tile if it is suitable for docking.

Tiles surrounding the tile are tested to be docks with correct orientation.

Parameters

  t | Tile to test.

Definition at line 194 of file water_cmd.cpp.

References OrthogonalTileArea::Add(), DIAGDIR_BEGIN, DIAGDIR_END, Station::docking_station, BaseStation::GetByTile(), Industry::GetByTile(), IsDockTile(), IsDockWaterPart(), IsOilRig(), IsTileType(), IsValidTile(), MP_INDUSTRY, MP_STATION, Industry::neutral_station, SetDockingTile(), and TileOffsByDiagDir().

Referenced by ClearDockingTilesCheckingNeighbours(), CmdBuildBridge(), CmdBuildBuoy(), CmdBuildCanal(), CmdBuildShipDepot(), CmdBuildSingleRail(), DoBuildLock(), and DoFloodTile().

## ◆ ClearNeighbourNonFloodingStates()

void ClearNeighbourNonFloodingStates | ( | TileIndex | tile | ) |

Clear non-flooding state of the tiles around a tile.

Parameters

  tile | The centre of the tile where other tiles' non-flooding state is cleared.

Definition at line 97 of file water_cmd.cpp.

References DIR_BEGIN, DIR_END, IsTileType(), IsValidTile(), MP_WATER, SetNonFloodingWaterTile(), and TileOffsByDir().

Referenced by BuildObject(), CmdBuildBuoy(), CmdLandscapeClear(), PlantTreesOnTile(), and RemoveLock().

## ◆ ConvertGroundTilesIntoWaterTiles()

void ConvertGroundTilesIntoWaterTiles | ( |  | ) |

Definition at line 1324 of file water_cmd.cpp.

## ◆ DrawShipDepotSprite()

void DrawShipDepotSprite | ( | int | x,
|  | int | y,
|  | Axis | axis,
|  | DepotPart | part
| ) |  |

Definition at line 979 of file water_cmd.cpp.

## ◆ DrawShoreTile()

void DrawShoreTile | ( | Slope | tileh | ) |

Definition at line 923 of file water_cmd.cpp.

## ◆ FloodHalftile()

bool FloodHalftile | ( | TileIndex | t | ) |

Called from water_cmd if a non-flat rail-tile gets flooded and should be converted to shore.

The function floods the lower halftile, if the tile has a halftile foundation.

Parameters

  t | The tile to flood.

Returns
  true if something was flooded.

Definition at line 759 of file rail_cmd.cpp.

References _current_company, ApplyFoundationToSlope(), CornerToTrackBits(), Execute, FindFirstTrack(), GetHighestSlopeCorner(), GetRailFoundation(), GetTileSlope(), GetTrackBits(), HalfTileWater, IsNonContinuousFoundation(), IsPlainRailTile(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), MakeShore(), MarkTileDirtyByTile(), OppositeCorner(), OWNER_WATER, Backup< T >::Restore(), and TRACK_BIT_NONE.

Referenced by DoFloodTile().

## ◆ GetFloodingBehaviour()

FloodingBehaviour GetFloodingBehaviour | ( | TileIndex | tile | ) |

Returns the behaviour of a tile during flooding.

Returns
  Behaviour of the tile

Definition at line 1115 of file water_cmd.cpp.

References FLOOD_ACTIVE, FLOOD_DRYUP, FLOOD_NONE, GetTileSlope(), GetTileType(), GetTreeGround(), GetWaterClass(), HalfTileWater, IsCoast(), IsSlopeWithOneCornerRaised(), MP_INDUSTRY, MP_OBJECT, MP_RAILWAY, MP_STATION, MP_TREES, MP_VOID, MP_WATER, Sea, and TREE_GROUND_SHORE.

Referenced by CheckRailSlope(), and TileLoop_Water().

## ◆ IsWateredTile()

bool IsWateredTile | ( | TileIndex | tile,
|  | Direction | from
| ) |  |

return true if a tile is a water tile wrt.

a certain direction.

Parameters

  tile | The tile of interest.
  from | The direction of interest.

Returns
  true iff the tile is water in the view of 'from'.

Definition at line 658 of file water_cmd.cpp.

References Clear, Coast, Depot, DiagDirToAxis(), DIR_E, DIR_N, DIR_NE, DIR_NW, DIR_S, DIR_SE, DIR_SW, DIR_W, DirToDiagDir(), GetIndustryIndex(), GetLockDirection(), GetTileSlope(), GetTileType(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetWaterTileType(), HalfTileWater, IsBuoy(), IsDock(), IsOilRig(), IsPlainRail(), IsTileFlat(), IsTileOnWater(), IsTileType(), Lock, MP_INDUSTRY, MP_OBJECT, MP_RAILWAY, MP_STATION, MP_TUNNELBRIDGE, MP_VOID, MP_WATER, ReverseDiagDir(), SLOPE_E, SLOPE_N, SLOPE_S, SLOPE_W, TileOffsByDir(), and TRANSPORT_WATER.

Referenced by DrawWaterEdges(), and CanalScopeResolver::GetVariable().

## ◆ MakeRiverAndModifyDesertZoneAround()

void MakeRiverAndModifyDesertZoneAround | ( | TileIndex | tile | ) |

Make a river tile and remove desert directly around it.

Parameters

  tile | The tile to change into river and create non-desert around

Definition at line 472 of file water_cmd.cpp.

References GetTropicZone(), MakeRiver(), MarkTileDirtyByTile(), Random, RIVER_OFFSET_DESERT_DISTANCE, SetTropicZone(), TROPICZONE_DESERT, and TROPICZONE_NORMAL.

Referenced by MakeLake(), MakeWetlands(), and RiverMakeWider().

## ◆ MakeWaterKeepingClass()

void MakeWaterKeepingClass | ( | TileIndex | tile,
|  | Owner | o
| ) |  |

Definition at line 218 of file water_cmd.cpp.

## ◆ RiverFlowsDown()

bool RiverFlowsDown | ( | TileIndex | begin,
|  | TileIndex | end
| ) |  |

Check whether a river at begin could (logically) flow down to end.

Parameters

  begin | The origin of the flow.
  end | The destination of the flow.

Returns
  True iff the water can be flowing down.

Definition at line 1308 of file landscape.cpp.

References DistanceManhattan(), GetTileSlopeZ(), IsInclinedSlope(), and SLOPE_FLAT.

Referenced by FlowRiver().

## ◆ RiverMakeWider()

void RiverMakeWider | ( | TileIndex | tile,
|  | TileIndex | origin_tile
| ) |  |

Widen a river by expanding into adjacent tiles via circular tile search.

Parameters

  tile | The tile to try expanding the river into.
  origin_tile | The tile to try surrounding the river around.

Definition at line 1165 of file landscape.cpp.

References Auto, ChangeDiagDir(), ComplementSlope(), DIAGDIR_BEGIN, DIAGDIR_END, DIAGDIRDIFF_90LEFT, DIAGDIRDIFF_90RIGHT, DIAGDIRDIFF_BEGIN, DIAGDIRDIFF_END, DIAGDIRDIFF_REVERSE, DIAGDIRDIFF_SAME, Execute, GetInclinedSlopeDirection(), GetTileMaxZ(), GetTileSlope(), GetTileZ(), IsInclinedSlope(), IsRiver(), IsSlopeWithOneCornerRaised(), IsSlopeWithThreeCornersRaised(), IsSteepSlope(), IsTileFlat(), IsValidTile(), IsWaterTile(), MakeRiverAndModifyDesertZoneAround(), ReverseDiagDir(), SLOPE_FLAT, and TileAddByDiagDir().

## ◆ TileLoop_Water()

void TileLoop_Water | ( | TileIndex | tile | ) |

Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd, and by TileLoop_Industry() and TileLoop_Track()

Parameters

  tile | the water/shore tile that floods

Definition at line 1269 of file water_cmd.cpp.

References _flood_from_dirs, AddTileIndexDiffCWrap(), AmbientSoundEffect(), DIR_BEGIN, DIR_END, DoDryUp(), DoFloodTile(), FLOOD_ACTIVE, FLOOD_DRYUP, FLOOD_PASSIVE, GetFloodingBehaviour(), GetFoundationSlope(), GetTreeGround(), INVALID_TILE, IsBuoy(), IsDock(), IsNonFloodingWaterTile(), IsTileType(), IsValidTile(), MP_STATION, MP_TREES, MP_WATER, ReverseDir(), SetNonFloodingWaterTile(), SLOPE_HALFTILE_MASK, SLOPE_STEEP, TileIndexDiffCByDir(), and TREE_GROUND_SHORE.

## Variable Documentation

## ◆ RIVER_OFFSET_DESERT_DISTANCE

const uint RIVER_OFFSET_DESERT_DISTANCE = 5
| static

Circular tile search diameter to create non-desert around a river tile.

Definition at line 44 of file water.h.

Referenced by CmdBuildCanal(), and MakeRiverAndModifyDesertZoneAround().