OpenTTD Source: src/water_cmd.cpp File Reference

OpenTTD Source 15.0-RC2

Functions | Variables
water_cmd.cpp File Reference

Handling of water tiles. More...

`#include "stdafx.h"`
`#include "landscape.h"`
`#include "viewport_func.h"`
`#include "command_func.h"`
`#include "town.h"`
`#include "news_func.h"`
`#include "depot_base.h"`
`#include "depot_func.h"`
`#include "water.h"`
`#include "industry_map.h"`
`#include "newgrf_canal.h"`
`#include "strings_func.h"`
`#include "vehicle_func.h"`
`#include "sound_func.h"`
`#include "company_func.h"`
`#include "clear_map.h"`
`#include "tree_map.h"`
`#include "aircraft.h"`
`#include "effectvehicle_func.h"`
`#include "tunnelbridge_map.h"`
`#include "station_base.h"`
`#include "ai/ai.hpp"`
`#include "game/game.hpp"`
`#include "core/random_func.hpp"`
`#include "core/backup_type.hpp"`
`#include "timer/timer_game_calendar.h"`
`#include "company_base.h"`
`#include "company_gui.h"`
`#include "newgrf_generic.h"`
`#include "industry.h"`
`#include "water_cmd.h"`
`#include "landscape_cmd.h"`
`#include "pathfinder/water_regions.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`
`#include "table/water_land.h"`

Go to the source code of this file.

## Functions
static void | MarkTileDirtyIfCanalOrRiver (TileIndex tile)
| Marks tile dirty if it is a canal or river tile.
static void | MarkCanalsAndRiversAroundDirty (TileIndex tile)
| Marks the tiles around a tile as dirty, if they are canals or rivers.
void | ClearNeighbourNonFloodingStates (TileIndex tile)
| Clear non-flooding state of the tiles around a tile.
CommandCost | CmdBuildShipDepot (DoCommandFlags flags, TileIndex tile, Axis axis)
| Build a ship depot.
bool | IsPossibleDockingTile (Tile t)
void | CheckForDockingTile (TileIndex t)
| Mark the supplied tile as a docking tile if it is suitable for docking.
void | MakeWaterKeepingClass (TileIndex tile, Owner o)
static CommandCost | RemoveShipDepot (TileIndex tile, DoCommandFlags flags)
static uint8_t | GetLockPartMinimalBridgeHeight (LockPart lock_part)
| Get the minimal height required for a bridge above a lock part.
static CommandCost | DoBuildLock (TileIndex tile, DiagDirection dir, DoCommandFlags flags)
| Builds a lock.
static CommandCost | RemoveLock (TileIndex tile, DoCommandFlags flags)
| Remove a lock.
CommandCost | CmdBuildLock (DoCommandFlags flags, TileIndex tile)
| Builds a lock.
void | MakeRiverAndModifyDesertZoneAround (TileIndex tile)
| Make a river tile and remove desert directly around it.
CommandCost | CmdBuildCanal (DoCommandFlags flags, TileIndex tile, TileIndex start_tile, WaterClass wc, bool diagonal)
| Build a piece of canal.
static CommandCost | ClearTile_Water (TileIndex tile, DoCommandFlags flags)
bool | IsWateredTile (TileIndex tile, Direction from)
| return true if a tile is a water tile wrt.
static void | DrawWaterSprite (SpriteID base, uint offset, CanalFeature feature, TileIndex tile)
| Draw a water sprite, potentially with a NewGRF-modified sprite offset.
static void | DrawWaterEdges (bool canal, uint offset, TileIndex tile)
| Draw canal or river edges.
static void | DrawSeaWater (TileIndex)
| Draw a plain sea water tile with no edges.
static void | DrawCanalWater (TileIndex tile)
| draw a canal styled water tile with dikes around
static void | DrawWaterTileStruct (const TileInfo *ti, std::span< const DrawTileSeqStruct > seq, SpriteID base, uint offset, PaletteID palette, CanalFeature feature)
| Draw a build sprite sequence for water tiles.
static void | DrawWaterLock (const TileInfo *ti)
| Draw a lock tile.
static void | DrawWaterDepot (const TileInfo *ti)
| Draw a ship depot tile.
static void | DrawRiverWater (const TileInfo *ti)
void | DrawShoreTile (Slope tileh)
void | DrawWaterClassGround (const TileInfo *ti)
static void | DrawTile_Water (TileInfo *ti)
void | DrawShipDepotSprite (int x, int y, Axis axis, DepotPart part)
static int | GetSlopePixelZ_Water (TileIndex tile, uint x, uint y, bool)
static Foundation | GetFoundation_Water (TileIndex, Slope)
static void | GetTileDesc_Water (TileIndex tile, TileDesc &td)
static void | FloodVehicle (Vehicle *v)
| Handle the flooding of a vehicle.
static void | FloodVehicleProc (Vehicle *v, int z)
| Flood a vehicle if we are allowed to flood it, i.e.
static void | FloodVehiclesOnTile (TileIndex tile, int z)
static void | FloodVehicles (TileIndex tile)
| Finds a vehicle to flood.
FloodingBehaviour | GetFloodingBehaviour (TileIndex tile)
| Returns the behaviour of a tile during flooding.
static void | DoFloodTile (TileIndex target)
| Floods a tile.
static void | DoDryUp (TileIndex tile)
| Drys a tile up.
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()
void | ConvertGroundTilesIntoWaterTiles ()
static TrackStatus | GetTileTrackStatus_Water (TileIndex tile, TransportType mode, uint, DiagDirection)
static bool | ClickTile_Water (TileIndex tile)
static void | ChangeTileOwner_Water (TileIndex tile, Owner old_owner, Owner new_owner)
static VehicleEnterTileStates | VehicleEnter_Water (Vehicle *, TileIndex, int, int)
static CommandCost | TerraformTile_Water (TileIndex tile, DoCommandFlags flags, int, Slope)
static CommandCost | CheckBuildAbove_Water (TileIndex tile, DoCommandFlags flags, Axis, int height)

## Variables
static const Directions | _flood_from_dirs []
| Describes from which directions a specific slope can be flooded (if the tile is floodable at all).
const TileTypeProcs | _tile_type_water_procs

## Detailed Description

Handling of water tiles.

Definition in file water_cmd.cpp.

## Function Documentation

## ◆ ChangeTileOwner_Water()

static void ChangeTileOwner_Water | ( | TileIndex | tile,
|  | Owner | old_owner,
|  | Owner | new_owner
| ) |  |
| static

Definition at line 1395 of file water_cmd.cpp.

## ◆ CheckBuildAbove_Water()

static CommandCost CheckBuildAbove_Water | ( | TileIndex | tile,
|  | DoCommandFlags | flags,
|  | Axis | ,
|  | int | height
| ) |  |
| static

Definition at line 1444 of file water_cmd.cpp.

## ◆ 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().

## ◆ ClearTile_Water()

static CommandCost ClearTile_Water | ( | TileIndex | tile,
|  | DoCommandFlags | flags
| ) |  |
| static

Definition at line 572 of file water_cmd.cpp.

## ◆ ClickTile_Water()

static bool ClickTile_Water | ( | TileIndex | tile | ) |
| static

Definition at line 1386 of file water_cmd.cpp.

## ◆ CmdBuildCanal()

CommandCost CmdBuildCanal | ( | DoCommandFlags | flags,
|  | TileIndex | tile,
|  | TileIndex | start_tile,
|  | WaterClass | wc,
|  | bool | diagonal
| ) |  |

Build a piece of canal.

Parameters

  flags | type of operation
  tile | end tile of stretch-dragging
  start_tile | start tile of stretch-dragging
  wc | waterclass to build. sea and river can only be built in scenario editor
  diagonal | Whether to use the Orthogonal (0) or Diagonal (1) iterator.

Returns
  the cost of this operation or an error

Definition at line 492 of file water_cmd.cpp.

References _current_company, CommandCost::AddCost(), Canal, CheckForDockingTile(), CMD_ERROR, TileIterator::Create(), DirtyCompanyInfrastructureWindows(), Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), GetTileOwner(), GetTileSlope(), GetTropicZone(), INVALID_TILE, IsCanal(), IsInclinedSlope(), IsTileOwner(), IsTileType(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), IsValidWaterClass(), IsWaterTile(), MakeCanal(), MakeRiver(), MakeSea(), MarkCanalsAndRiversAroundDirty(), MarkTileDirtyByTile(), MP_WATER, OWNER_NONE, Random, River, RIVER_OFFSET_DESERT_DISTANCE, Sea, SetTropicZone(), Map::Size(), SLOPE_FLAT, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileHeight(), TROPICZONE_DESERT, and TROPICZONE_NORMAL.

## ◆ CmdBuildLock()

CommandCost CmdBuildLock | ( | DoCommandFlags | flags,
|  | TileIndex | tile
| ) |  |

Builds a lock.

Parameters

  flags | type of operation
  tile | tile where to place the lock

Returns
  the cost of this operation or an error

Definition at line 453 of file water_cmd.cpp.

References _settings_game, GameSettings::construction, DoBuildLock(), ConstructionSettings::freeform_edges, GetInclinedSlopeDirection(), GetTileSlope(), INVALID_DIAGDIR, IsInsideMM(), Map::MaxX(), Map::MaxY(), ReverseDiagDir(), TileAddByDiagDir(), TileX(), and TileY().

## ◆ CmdBuildShipDepot()

CommandCost CmdBuildShipDepot | ( | DoCommandFlags | flags,
|  | TileIndex | tile,
|  | Axis | axis
| ) |  |

Build a ship depot.

Parameters

  flags | type of operation
  tile | tile where ship depot is built
  axis | depot orientation (Axis)

Returns
  the cost of this operation or an error

Definition at line 112 of file water_cmd.cpp.

References _current_company, CommandCost::AddCost(), Auto, Canal, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_depot_pool >::CanAllocateItem(), CheckForDockingTile(), CMD_ERROR, DirtyCompanyInfrastructureWindows(), Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), GetWaterClass(), HasTileWaterClass(), HasTileWaterGround(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IsBridgeAbove(), IsTileFlat(), IsTileOwner(), IsValidAxis(), IsWaterTile(), LOCK_DEPOT_TILE_FACTOR, MakeDefaultName(), MakeShipDepot(), MarkTileDirtyByTile(), North, South, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and TileOffsByAxis().

## ◆ ConvertGroundTilesIntoWaterTiles()

void ConvertGroundTilesIntoWaterTiles | ( |  | ) |

Definition at line 1324 of file water_cmd.cpp.

## ◆ DoBuildLock()

static CommandCost DoBuildLock | ( | TileIndex | tile,
|  | DiagDirection | dir,
|  | DoCommandFlags | flags
| ) |  |
| static

Builds a lock.

Parameters

  tile | Central tile of the lock.
  dir | Uphill direction.
  flags | Operation to perform.

Returns
  The cost in case of success, or an error code if it failed.

Definition at line 326 of file water_cmd.cpp.

References _current_company, CommandCost::AddCost(), Canal, CheckForDockingTile(), CommandCostWithParam(), DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetBridgeHeight(), CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), GetLockPartMinimalBridgeHeight(), GetSouthernBridgeEnd(), GetTileMaxZ(), GetWaterClass(), HasTileWaterGround(), Company::infrastructure, InvalidateWaterRegion(), IsBridgeAbove(), IsTileFlat(), IsWaterTile(), LOCK_DEPOT_TILE_FACTOR, MakeLock(), MarkCanalsAndRiversAroundDirty(), MarkTileDirtyByTile(), Middle, CommandCost::Succeeded(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TILE_HEIGHT_STEP, TileOffsByDiagDir(), and CompanyInfrastructure::water.

Referenced by CmdBuildLock().

## ◆ DoDryUp()

static void DoDryUp | ( | TileIndex | tile | ) |
| static

Drys a tile up.

Definition at line 1222 of file water_cmd.cpp.

References _current_company, CLEAR_GRASS, Execute, FenceHoriz1, FenceHoriz2, FenceVert1, FenceVert2, GetTileType(), GetTrackBits(), HalfTileWater, IsCoast(), IsPlainRail(), MakeClear(), MarkTileDirtyByTile(), MP_RAILWAY, MP_TREES, MP_WATER, OWNER_WATER, Backup< T >::Restore(), SetTreeGroundDensity(), TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, TRACK_BIT_UPPER, and TREE_GROUND_GRASS.

Referenced by TileLoop_Water().

## ◆ DoFloodTile()

static void DoFloodTile | ( | TileIndex | target | ) |
| static

Floods a tile.

Definition at line 1154 of file water_cmd.cpp.

References _current_company, CheckForDockingTile(), Execute, FloodHalftile(), FloodVehicles(), GetTileSlope(), GetTileType(), InvalidateWaterRegion(), IsPlainRail(), IsSlopeWithOneCornerRaised(), IsTileType(), MakeSea(), MakeShore(), MarkCanalsAndRiversAroundDirty(), MarkTileDirtyByTile(), MP_CLEAR, MP_RAILWAY, MP_TREES, MP_WATER, OWNER_WATER, Backup< T >::Restore(), SetTreeGroundDensity(), SLOPE_FLAT, TREE_GROUND_SHORE, and UpdateSignalsInBuffer().

Referenced by TileLoop_Water().

## ◆ DrawCanalWater()

static void DrawCanalWater | ( | TileIndex | tile | ) |
| static

draw a canal styled water tile with dikes around

Definition at line 803 of file water_cmd.cpp.

References _water_feature, CFF_HAS_FLAT_SPRITE, DrawWaterEdges(), DrawWaterSprite(), GetCanalSprite(), and HasBit().

## ◆ DrawRiverWater()

static void DrawRiverWater | ( | const TileInfo * | ti | ) |
| static

Definition at line 885 of file water_cmd.cpp.

## ◆ DrawSeaWater()

static void DrawSeaWater | ( | TileIndex |  | ) |
| static

Draw a plain sea water tile with no edges.

Definition at line 797 of file water_cmd.cpp.

References DrawGroundSprite().

## ◆ 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.

## ◆ DrawTile_Water()

static void DrawTile_Water | ( | TileInfo * | ti | ) |
| static

Definition at line 950 of file water_cmd.cpp.

## ◆ DrawWaterClassGround()

void DrawWaterClassGround | ( | const TileInfo * | ti | ) |

Definition at line 940 of file water_cmd.cpp.

## ◆ DrawWaterDepot()

static void DrawWaterDepot | ( | const TileInfo * | ti | ) |
| static

Draw a ship depot tile.

Definition at line 879 of file water_cmd.cpp.

References DrawWaterTileStruct(), GetCompanyPalette(), GetShipDepotAxis(), GetShipDepotPart(), GetTileOwner(), TileInfo::tile, and to_underlying().

## ◆ DrawWaterEdges()

static void DrawWaterEdges | ( | bool | canal,
|  | uint | offset,
|  | TileIndex | tile
| ) |  |
| static

Draw canal or river edges.

Parameters

  canal | True if canal edges should be drawn, false for river edges.
  offset | Sprite offset.
  tile | Tile to draw.

Definition at line 744 of file water_cmd.cpp.

References DIR_E, DIR_N, DIR_NE, DIR_NW, DIR_S, DIR_SE, DIR_SW, DIR_W, DrawWaterSprite(), GetCanalSprite(), IsWateredTile(), and TileAddXY().

Referenced by DrawCanalWater().

## ◆ DrawWaterLock()

static void DrawWaterLock | ( | const TileInfo * | ti | ) |
| static

Draw a lock tile.

Definition at line 840 of file water_cmd.cpp.

References _water_feature, CFF_HAS_FLAT_SPRITE, DrawGroundSprite(), DrawWaterTileStruct(), GetCanalSprite(), GetLockDirection(), GetLockPart(), DrawTileSprites::ground, HasBit(), PalSpriteID::sprite, TileInfo::tile, to_underlying(), Upper, and Coord3D< T >::z.

## ◆ DrawWaterSprite()

static void DrawWaterSprite | ( | SpriteID | base,
|  | uint | offset,
|  | CanalFeature | feature,
|  | TileIndex | tile
| ) |  |
| static

Draw a water sprite, potentially with a NewGRF-modified sprite offset.

Parameters

  base | Sprite base.
  offset | Sprite offset.
  feature | The type of sprite that is drawn.
  tile | Tile index to draw.

Definition at line 729 of file water_cmd.cpp.

References DrawGroundSprite(), and GetCanalSpriteOffset().

Referenced by DrawCanalWater(), and DrawWaterEdges().

## ◆ DrawWaterTileStruct()

static void DrawWaterTileStruct | ( | const TileInfo * | ti,
|  | std::span< const DrawTileSeqStruct > | seq,
|  | SpriteID | base,
|  | uint | offset,
|  | PaletteID | palette,
|  | CanalFeature | feature
| ) |  |
| static

Draw a build sprite sequence for water tiles.

If buildings are invisible, nothing will be drawn.

Parameters

  ti | Tile info.
  seq | Sprite sequence to draw.
  base | Base sprite.
  offset | Additional sprite offset.
  palette | Palette to use.

Definition at line 827 of file water_cmd.cpp.

References AddSortableSpriteToDraw(), GetCanalSpriteOffset(), IsInvisibilitySet(), IsTransparencySet(), TileInfo::tile, and TO_BUILDINGS.

Referenced by DrawWaterDepot(), and DrawWaterLock().

## ◆ FloodVehicle()

static void FloodVehicle | ( | Vehicle * | v | ) |
| static

Handle the flooding of a vehicle.

This sets the vehicle state to crashed, creates a newsitem and dirties the necessary windows.

Parameters

  v | The vehicle to flood.

Definition at line 1028 of file water_cmd.cpp.

References _settings_client, Accident, Vehicle::Crash(), CreateEffectVehicleRel(), SoundSettings::disaster, EV_EXPLOSION_LARGE, GetEncodedString(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Game::NewEvent(), AI::NewEvent(), Vehicle::owner, SND_12_EXPLOSION, ClientSettings::sound, and Vehicle::tile.

Referenced by FloodVehicleProc().

## ◆ FloodVehicleProc()

static void FloodVehicleProc | ( | Vehicle * | v,
|  | int | z
| ) |  |
| static

Flood a vehicle if we are allowed to flood it, i.e.

when it is on the ground.

Parameters

  v | The vehicle to test for flooding.
  z | The z of level to flood.

Definition at line 1044 of file water_cmd.cpp.

References AIR_SHADOW, Station::airport, Crashed, AirportFTAClass::delta_z, Vehicle::First(), FloodVehicle(), BaseStation::GetByTile(), Airport::GetFTA(), GetTileMaxZ(), IsAirportTile(), Vehicle::subtype, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_TRAIN, Vehicle::vehstatus, and Vehicle::z_pos.

## ◆ FloodVehicles()

static void FloodVehicles | ( | TileIndex | tile | ) |
| static

Finds a vehicle to flood.

It does not find vehicles that are already crashed on bridges, i.e. flooded.

Parameters

  tile | the tile where to find a vehicle to flood

Definition at line 1086 of file water_cmd.cpp.

References Station::airport, GetBridgePixelHeight(), BaseStation::GetByTile(), GetOtherBridgeEnd(), IsAirportTile(), and IsBridgeTile().

Referenced by DoFloodTile().

## ◆ FloodVehiclesOnTile()

static void FloodVehiclesOnTile | ( | TileIndex | tile,
|  | int | z
| ) |  |
| static

Definition at line 1074 of file water_cmd.cpp.

## ◆ 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().

## ◆ GetFoundation_Water()

static Foundation GetFoundation_Water | ( | TileIndex | ,
|  | Slope |
| ) |  |
| static

Definition at line 995 of file water_cmd.cpp.

## ◆ GetLockPartMinimalBridgeHeight()

static uint8_t GetLockPartMinimalBridgeHeight | ( | LockPart | lock_part | ) |
| static

Get the minimal height required for a bridge above a lock part.

Parameters

  lock_part | the lock part.

Returns
  the minimal bridge height.

Definition at line 309 of file water_cmd.cpp.

References to_underlying().

Referenced by DoBuildLock().

## ◆ GetSlopePixelZ_Water()

static int GetSlopePixelZ_Water | ( | TileIndex | tile,
|  | uint | x,
|  | uint | y,
|  | bool |
| ) |  |
| static

Definition at line 988 of file water_cmd.cpp.

## ◆ GetTileDesc_Water()

static void GetTileDesc_Water | ( | TileIndex | tile,
|  | TileDesc & | td
| ) |  |
| static

Definition at line 1000 of file water_cmd.cpp.

## ◆ GetTileTrackStatus_Water()

static TrackStatus GetTileTrackStatus_Water | ( | TileIndex | tile,
|  | TransportType | mode,
|  | uint | ,
|  | DiagDirection |
| ) |  |
| static

Definition at line 1359 of file water_cmd.cpp.

## ◆ IsPossibleDockingTile()

bool IsPossibleDockingTile | ( | Tile | t | ) |

Definition at line 172 of file water_cmd.cpp.

## ◆ 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.

## ◆ MarkTileDirtyIfCanalOrRiver()

static void MarkTileDirtyIfCanalOrRiver | ( | TileIndex | tile | ) |
| inlinestatic

Marks tile dirty if it is a canal or river tile.

Called to avoid glitches when flooding tiles next to canal tile.

Parameters

  tile | tile to check

Definition at line 75 of file water_cmd.cpp.

References IsCanal(), IsRiver(), IsTileType(), IsValidTile(), MarkTileDirtyByTile(), and MP_WATER.

Referenced by MarkCanalsAndRiversAroundDirty().

## ◆ RemoveLock()

static CommandCost RemoveLock | ( | TileIndex | tile,
|  | DoCommandFlags | flags
| ) |  |
| static

Remove a lock.

Parameters

  tile | Central tile of the lock.
  flags | Operation to perform.

Returns
  The cost in case of success, or an error code if it failed.

Definition at line 408 of file water_cmd.cpp.

References CheckTileOwnership(), ClearNeighbourNonFloodingStates(), DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), GetLockDirection(), GetTileOwner(), GetWaterClass(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Company::infrastructure, LOCK_DEPOT_TILE_FACTOR, MakeRiver(), MarkCanalsAndRiversAroundDirty(), OWNER_NONE, Random, River, CommandCost::Succeeded(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileOffsByDiagDir(), and CompanyInfrastructure::water.

## ◆ RemoveShipDepot()

static CommandCost RemoveShipDepot | ( | TileIndex | tile,
|  | DoCommandFlags | flags
| ) |  |
| static

Definition at line 269 of file water_cmd.cpp.

## ◆ TerraformTile_Water()

static CommandCost TerraformTile_Water | ( | TileIndex | tile,
|  | DoCommandFlags | flags,
|  | int | ,
|  | Slope |
| ) |  |
| static

Definition at line 1436 of file water_cmd.cpp.

## ◆ 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.

## ◆ VehicleEnter_Water()

static VehicleEnterTileStates VehicleEnter_Water | ( | Vehicle * | ,
|  | TileIndex | ,
|  | int | ,
|  | int |
| ) |  |
| static

Definition at line 1431 of file water_cmd.cpp.

## Variable Documentation

## ◆ _flood_from_dirs

const Directions _flood_from_dirs[]
| static

Initial value:
= {
{DIR_NW, DIR_SW, DIR_SE, DIR_NE},
{DIR_NE, DIR_SE},
{DIR_NW, DIR_NE},
{DIR_NE},
{DIR_NW, DIR_SW},
{},
{DIR_NW},
{DIR_N, DIR_NW, DIR_NE},
{DIR_SW, DIR_SE},
{DIR_SE},
{},
{DIR_E, DIR_NE, DIR_SE},
{DIR_SW},
{DIR_S, DIR_SW, DIR_SE},
{DIR_W, DIR_SW, DIR_NW},
}
DIR_SW
@ DIR_SW
Southwest.
Definition direction_type.h:31
DIR_NW
@ DIR_NW
Northwest.
Definition direction_type.h:33
DIR_N
@ DIR_N
North.
Definition direction_type.h:26
DIR_SE
@ DIR_SE
Southeast.
Definition direction_type.h:29
DIR_S
@ DIR_S
South.
Definition direction_type.h:30
DIR_NE
@ DIR_NE
Northeast.
Definition direction_type.h:27
DIR_W
@ DIR_W
West.
Definition direction_type.h:32
DIR_E
@ DIR_E
East.
Definition direction_type.h:28

Describes from which directions a specific slope can be flooded (if the tile is floodable at all).

Definition at line 51 of file water_cmd.cpp.

Referenced by TileLoop_Water().

## ◆ _tile_type_water_procs

const TileTypeProcs _tile_type_water_procs
| extern

Initial value:
= {
DrawTile_Water,
GetSlopePixelZ_Water,
ClearTile_Water,
nullptr,
GetTileDesc_Water,
GetTileTrackStatus_Water,
ClickTile_Water,
nullptr,
TileLoop_Water,
ChangeTileOwner_Water,
nullptr,
VehicleEnter_Water,
GetFoundation_Water,
TerraformTile_Water,
CheckBuildAbove_Water,
}
TileLoop_Water
void TileLoop_Water(TileIndex tile)
Let a water tile floods its diagonal adjoining tiles called from tunnelbridge_cmd,...
Definition water_cmd.cpp:1269

Definition at line 57 of file landscape.cpp.