|
OpenTTD Source 20251117-master-g7398d2e290
|
Map accessors for water tiles. More...
Go to the source code of this file.
Enumerations | |
| enum | WaterTileType : uint8_t { WATER_TILE_CLEAR , WATER_TILE_COAST , WATER_TILE_LOCK , WATER_TILE_DEPOT } |
| Available water tile types. More... | |
| enum | WaterClass : uint8_t { WATER_CLASS_SEA , WATER_CLASS_CANAL , WATER_CLASS_RIVER , WATER_CLASS_INVALID } |
| classes of water (for WATER_TILE_CLEAR water tile type). More... | |
| enum | DepotPart : uint8_t { DEPOT_PART_NORTH = 0 , DEPOT_PART_SOUTH = 1 , DEPOT_PART_END } |
| Sections of the water depot. More... | |
| enum | LockPart : uint8_t { LOCK_PART_MIDDLE = 0 , LOCK_PART_LOWER = 1 , LOCK_PART_UPPER = 2 , LOCK_PART_END } |
| Sections of the water lock. More... | |
Functions | |
| bool | IsValidWaterClass (WaterClass wc) |
| Checks if a water class is valid. | |
| DECLARE_INCREMENT_DECREMENT_OPERATORS (LockPart) | |
| bool | IsPossibleDockingTile (Tile t) |
| WaterTileType | GetWaterTileType (Tile t) |
| Get the water tile type of a tile. | |
| void | SetWaterTileType (Tile t, WaterTileType type) |
| Set the water tile type of a tile. | |
| bool | HasTileWaterClass (Tile t) |
| Checks whether the tile has an waterclass associated. | |
| WaterClass | GetWaterClass (Tile t) |
| Get the water class at a tile. | |
| void | SetWaterClass (Tile t, WaterClass wc) |
| Set the water class at a tile. | |
| bool | IsTileOnWater (Tile t) |
| Tests if the tile was built on water. | |
| bool | IsWater (Tile t) |
| Is it a plain water tile? | |
| bool | IsSea (Tile t) |
| Is it a sea water tile? | |
| bool | IsCanal (Tile t) |
| Is it a canal tile? | |
| bool | IsRiver (Tile t) |
| Is it a river water tile? | |
| bool | IsWaterTile (Tile t) |
| Is it a water tile with plain water? | |
| bool | IsCoast (Tile t) |
| Is it a coast tile? | |
| bool | IsCoastTile (Tile t) |
| Is it a coast tile. | |
| bool | IsShipDepot (Tile t) |
| Is it a water tile with a ship depot on it? | |
| bool | IsShipDepotTile (Tile t) |
| Is it a ship depot tile? | |
| Axis | GetShipDepotAxis (Tile t) |
| Get the axis of the ship depot. | |
| DepotPart | GetShipDepotPart (Tile t) |
| Get the part of a ship depot. | |
| DiagDirection | GetShipDepotDirection (Tile t) |
| Get the direction of the ship depot. | |
| TileIndex | GetOtherShipDepotTile (Tile t) |
| Get the other tile of the ship depot. | |
| TileIndex | GetShipDepotNorthTile (Tile t) |
| Get the most northern tile of a ship depot. | |
| bool | IsLock (Tile t) |
| Is there a lock on a given water tile? | |
| DiagDirection | GetLockDirection (Tile t) |
| Get the direction of the water lock. | |
| LockPart | GetLockPart (Tile t) |
| Get the part of a lock. | |
| uint8_t | GetWaterTileRandomBits (Tile t) |
| Get the random bits of the water tile. | |
| bool | HasTileWaterGround (Tile t) |
| Checks whether the tile has water at the ground. | |
| void | SetDockingTile (Tile t, bool b) |
| Set the docking tile state of a tile. | |
| bool | IsDockingTile (Tile t) |
| Checks whether the tile is marked as a dockling tile. | |
| void | MakeShore (Tile t) |
| Helper function to make a coast tile. | |
| void | MakeWater (Tile t, Owner o, WaterClass wc, uint8_t random_bits) |
| Helper function for making a watery tile. | |
| void | MakeSea (Tile t) |
| Make a sea tile. | |
| void | MakeRiver (Tile t, uint8_t random_bits) |
| Make a river tile. | |
| void | MakeCanal (Tile t, Owner o, uint8_t random_bits) |
| Make a canal tile. | |
| void | MakeShipDepot (Tile t, Owner o, DepotID did, DepotPart part, Axis a, WaterClass original_water_class) |
| Make a ship depot section. | |
| void | MakeLockTile (Tile t, Owner o, LockPart part, DiagDirection dir, WaterClass original_water_class) |
| Make a lock section. | |
| void | MakeLock (Tile t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper, WaterClass wc_middle) |
| Make a water lock. | |
| void | SetNonFloodingWaterTile (Tile t, bool b) |
| Set the non-flooding water tile state of a tile. | |
| bool | IsNonFloodingWaterTile (Tile t) |
| Checks whether the tile is marked as a non-flooding water tile. | |
Variables | |
| static constexpr uint8_t | WBL_TYPE_BEGIN = 4 |
| Bit field layout of m5 for water tiles. | |
| static constexpr uint8_t | WBL_TYPE_COUNT = 4 |
| Length of the 'type' bitfield. | |
| static constexpr uint8_t | WBL_LOCK_ORIENT_BEGIN = 0 |
| Start of lock orientation bitfield. | |
| static constexpr uint8_t | WBL_LOCK_ORIENT_COUNT = 2 |
| Length of lock orientation bitfield. | |
| static constexpr uint8_t | WBL_LOCK_PART_BEGIN = 2 |
| Start of lock part bitfield. | |
| static constexpr uint8_t | WBL_LOCK_PART_COUNT = 2 |
| Length of lock part bitfield. | |
| static constexpr uint8_t | WBL_DEPOT_PART = 0 |
| Depot part flag. | |
| static constexpr uint8_t | WBL_DEPOT_AXIS = 1 |
| Depot axis flag. | |
Map accessors for water tiles.
Definition in file water_map.h.
| enum DepotPart : uint8_t |
Sections of the water depot.
| Enumerator | |
|---|---|
| DEPOT_PART_NORTH | Northern part of a depot. |
| DEPOT_PART_SOUTH | Southern part of a depot. |
Definition at line 58 of file water_map.h.
| enum LockPart : uint8_t |
Sections of the water lock.
| Enumerator | |
|---|---|
| LOCK_PART_MIDDLE | Middle part of a lock. |
| LOCK_PART_LOWER | Lower part of a lock. |
| LOCK_PART_UPPER | Upper part of a lock. |
Definition at line 65 of file water_map.h.
| enum WaterClass : uint8_t |
classes of water (for WATER_TILE_CLEAR water tile type).
| Enumerator | |
|---|---|
| WATER_CLASS_SEA | Sea. |
| WATER_CLASS_CANAL | Canal. |
| WATER_CLASS_RIVER | River. |
| WATER_CLASS_INVALID | Used for industry tiles on land (also for oilrig if newgrf says so). |
Definition at line 39 of file water_map.h.
| enum WaterTileType : uint8_t |
Available water tile types.
| Enumerator | |
|---|---|
| WATER_TILE_CLEAR | Plain water. |
| WATER_TILE_COAST | Coast. |
| WATER_TILE_LOCK | Water lock. |
| WATER_TILE_DEPOT | Water Depot. |
Definition at line 31 of file water_map.h.
|
inline |
Get the direction of the water lock.
| t | Water tile to query. |
Definition at line 316 of file water_map.h.
References GB(), IsLock(), Tile::m5(), WBL_LOCK_ORIENT_BEGIN, and WBL_LOCK_ORIENT_COUNT.
Referenced by DrawWaterLock(), IsWateredTile(), and RemoveLock().
Get the part of a lock.
| t | Water tile to query. |
Definition at line 328 of file water_map.h.
References GB(), IsLock(), Tile::m5(), WBL_LOCK_PART_BEGIN, and WBL_LOCK_PART_COUNT.
Referenced by AfterLoadGame(), DrawWaterLock(), CanalScopeResolver::GetVariable(), CYapfCostShipT< Types >::PfCalcCost(), and ShipTestUpDownOnLock().
Get the other tile of the ship depot.
| t | Tile to query, containing one section of a ship depot. |
Definition at line 280 of file water_map.h.
References DEPOT_PART_NORTH, GetShipDepotAxis(), GetShipDepotPart(), and TileOffsByAxis().
Referenced by AfterLoadGame(), and GetShipDepotNorthTile().
Get the axis of the ship depot.
| t | Water tile to query. |
Definition at line 245 of file water_map.h.
References GB(), IsShipDepotTile(), Tile::m5(), and WBL_DEPOT_AXIS.
Referenced by CheckShipStayInDepot(), DrawWaterDepot(), GetOtherShipDepotTile(), and GetShipDepotDirection().
|
inline |
Get the direction of the ship depot.
| t | Water tile to query. |
Definition at line 269 of file water_map.h.
References GetShipDepotAxis(), GetShipDepotPart(), and XYNSToDiagDir().
Referenced by CmdBuildShip(), and Ship::GetVehicleTrackdir().
Get the most northern tile of a ship depot.
| t | One of the tiles of the ship depot. |
Definition at line 291 of file water_map.h.
References GetOtherShipDepotTile(), and IsShipDepot().
Referenced by CmdBuildShip().
Get the part of a ship depot.
| t | Water tile to query. |
Definition at line 257 of file water_map.h.
References GB(), IsShipDepotTile(), Tile::m5(), and WBL_DEPOT_PART.
Referenced by DrawWaterDepot(), GetOtherShipDepotTile(), and GetShipDepotDirection().
|
inline |
Get the water class at a tile.
| t | Water tile to query. |
Definition at line 114 of file water_map.h.
References GB(), HasTileWaterClass(), and Tile::m1().
Referenced by AfterLoadGame(), AmbientSoundEffectCallback(), BuildObject(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildShipDepot(), CmdLandscapeClear(), DoBuildLock(), DoCreateNewIndustry(), DrawTile_TunnelBridge(), GetEffectiveWaterClass(), GetFloodingBehaviour(), GetNearbyTileInformation(), IsCanal(), IsCoastTile(), IsRiver(), IsSea(), IsTileOnWater(), NeighbourIsNormal(), RemoveLock(), and SetWaterClassDependingOnSurroundings().
|
inline |
Get the random bits of the water tile.
| t | Water tile to query. |
Definition at line 340 of file water_map.h.
References IsTileType(), Tile::m4(), and MP_WATER.
Referenced by CanalScopeResolver::GetRandomBits(), and CanalScopeResolver::GetVariable().
|
inline |
Get the water tile type of a tile.
| t | Water tile to query. |
Definition at line 80 of file water_map.h.
References GB(), IsTileType(), Tile::m5(), MP_WATER, WBL_TYPE_BEGIN, and WBL_TYPE_COUNT.
Referenced by AfterLoadGame(), IsCoast(), IsLock(), IsShipDepot(), IsWater(), and IsWateredTile().
|
inline |
Checks whether the tile has an waterclass associated.
You can then subsequently call GetWaterClass().
| t | Tile to query. |
Definition at line 103 of file water_map.h.
References IsTileType(), MP_INDUSTRY, MP_OBJECT, MP_STATION, MP_TREES, and MP_WATER.
Referenced by AmbientSoundEffectCallback(), CheckIfIndustryTilesAreFree(), CmdBuildDock(), CmdBuildShipDepot(), CmdLandscapeClear(), DrawTile_TunnelBridge(), GetEffectiveWaterClass(), GetNearbyTileInformation(), GetWaterClass(), HasTileWaterGround(), NeighbourIsNormal(), and SetWaterClass().
|
inline |
Checks whether the tile has water at the ground.
That is, it is either some plain water tile, or a object/industry/station/... with water under it.
Definition at line 352 of file water_map.h.
References HasTileWaterClass(), IsCoastTile(), and IsTileOnWater().
Referenced by BuildObject(), CanFollowRoad(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildObject(), CmdBuildShipDepot(), CmdBuildTunnel(), DoBuildLock(), GetClosestWaterDistance(), and GrowTownInTile().
|
inline |
Is it a canal tile?
| t | Water tile to query. |
true if it is a canal tile. Definition at line 171 of file water_map.h.
References GetWaterClass(), IsWater(), and WATER_CLASS_CANAL.
Referenced by CmdBuildCanal(), CmdLandscapeClear(), and MarkTileDirtyIfCanalOrRiver().
|
inline |
Is it a coast tile?
| t | Water tile to query. |
true if it is a sea water tile. Definition at line 203 of file water_map.h.
References GetWaterTileType(), and WATER_TILE_COAST.
Referenced by CanPlantTreesOnTile(), CmdPlantTree(), DoDryUp(), GetFloodingBehaviour(), IsCoastTile(), and SetWaterClassDependingOnSurroundings().
|
inline |
Is it a coast tile.
| t | Tile to query. |
true if it is a coast. Definition at line 213 of file water_map.h.
References GetWaterClass(), IsCoast(), IsTileType(), MP_TREES, MP_WATER, and WATER_CLASS_INVALID.
Referenced by CmdLandscapeClear(), and HasTileWaterGround().
|
inline |
Checks whether the tile is marked as a dockling tile.
Definition at line 373 of file water_map.h.
References HasBit(), IsTileType(), Tile::m1(), MP_RAILWAY, MP_STATION, MP_TUNNELBRIDGE, and MP_WATER.
Referenced by BuildObject(), CheckCaches(), CmdRemoveSingleRail(), IsShipDestinationTile(), CYapfCostShipT< Types >::PfCalcCost(), and RemoveDock().
|
inline |
Is there a lock on a given water tile?
| t | Water tile to query. |
true if it is a water lock tile. Definition at line 305 of file water_map.h.
References GetWaterTileType(), and WATER_TILE_LOCK.
Referenced by AfterLoadGame(), GetLockDirection(), GetLockPart(), CanalScopeResolver::GetVariable(), CYapfCostShipT< Types >::PfCalcCost(), SetWaterClassDependingOnSurroundings(), and ShipTestUpDownOnLock().
|
inline |
Checks whether the tile is marked as a non-flooding water tile.
Definition at line 539 of file water_map.h.
References HasBit(), IsTileType(), Tile::m3(), and MP_WATER.
Referenced by TileLoop_Water().
| bool IsPossibleDockingTile | ( | Tile | t | ) |
Definition at line 172 of file water_cmd.cpp.
|
inline |
Is it a river water tile?
| t | Water tile to query. |
true if it is a river water tile. Definition at line 182 of file water_map.h.
References GetWaterClass(), IsWater(), and WATER_CLASS_RIVER.
Referenced by MarkTileDirtyIfCanalOrRiver(), and RiverMakeWider().
|
inline |
Is it a sea water tile?
| t | Water tile to query. |
true if it is a sea water tile. Definition at line 160 of file water_map.h.
References GetWaterClass(), IsWater(), and WATER_CLASS_SEA.
Referenced by GrowTownWithBridge().
|
inline |
Is it a water tile with a ship depot on it?
| t | Water tile to query. |
true if it is a ship depot tile. Definition at line 224 of file water_map.h.
References GetWaterTileType(), and WATER_TILE_DEPOT.
Referenced by AfterLoadGame(), GetShipDepotNorthTile(), and IsShipDepotTile().
|
inline |
Is it a ship depot tile?
| t | Tile to query. |
true if it is a ship depot tile. Definition at line 234 of file water_map.h.
References IsShipDepot(), IsTileType(), and MP_WATER.
Referenced by AfterLoadGame(), CheckShipStayInDepot(), CmdInsertOrder(), GetDepotIndex(), GetShipDepotAxis(), GetShipDepotPart(), IsDepotTile(), and IsDepotTypeTile().
|
inline |
Tests if the tile was built on water.
| t | the tile to check |
Definition at line 138 of file water_map.h.
References GetWaterClass(), and WATER_CLASS_INVALID.
Referenced by CheckIfIndustryTilesAreFree(), CmdLandscapeClear(), DrawTileLayout(), SmallMapWindow::GetTileColours(), HasTileWaterGround(), and IsWateredTile().
|
inline |
Checks if a water class is valid.
| wc | The value to check |
Definition at line 52 of file water_map.h.
References WATER_CLASS_INVALID.
Referenced by CmdBuildCanal().
|
inline |
Is it a plain water tile?
| t | Water tile to query. |
true if any type of clear water like ocean, river, or canal. Definition at line 149 of file water_map.h.
References GetWaterTileType(), and WATER_TILE_CLEAR.
Referenced by AfterLoadGame(), CleanUpRoadBits(), CMSAWater(), IsCanal(), IsRiver(), IsSea(), and IsWaterTile().
|
inline |
Is it a water tile with plain water?
| t | Tile to query. |
true if it is a plain water tile. Definition at line 192 of file water_map.h.
References IsTileType(), IsWater(), and MP_WATER.
Referenced by BuildObject(), CheckIfIndustryTilesAreFree(), CmdBuildBuoy(), CmdBuildCanal(), CmdBuildDock(), CmdBuildObject(), CmdBuildShipDepot(), CmdLandscapeClear(), DoBuildLock(), DoCreateNewIndustry(), FindSpring(), FlowRiver(), GrowTownWithBridge(), MakeLake(), MakeLock(), and RiverMakeWider().
Make a canal tile.
| t | The tile to change into canal |
| o | The owner of the canal |
| random_bits | Random bits to be set for this tile |
Definition at line 447 of file water_map.h.
References MakeWater(), OWNER_WATER, and WATER_CLASS_CANAL.
Referenced by AfterLoadGame(), and CmdBuildCanal().
|
inline |
Make a water lock.
| t | Tile to place the water lock section. |
| o | Owner of the lock. |
| d | Direction of the water lock. |
| wc_lower | Original water class of the lower part. |
| wc_upper | Original water class of the upper part. |
| wc_middle | Original water class of the middle part. |
Definition at line 512 of file water_map.h.
References GetTileOwner(), IsWaterTile(), LOCK_PART_LOWER, LOCK_PART_MIDDLE, LOCK_PART_UPPER, MakeLockTile(), and TileOffsByDiagDir().
Referenced by DoBuildLock().
|
inline |
Make a lock section.
| t | Tile to place the water lock section. |
| o | Owner of the lock. |
| part | Part to place. |
| dir | Lock orientation |
| original_water_class | Original water class. |
Definition at line 487 of file water_map.h.
References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), MP_WATER, SB(), SetDockingTile(), SetTileOwner(), SetTileType(), SetWaterClass(), SetWaterTileType(), WATER_TILE_LOCK, WBL_LOCK_ORIENT_BEGIN, and WBL_LOCK_PART_BEGIN.
Referenced by MakeLock().
|
inline |
Make a river tile.
| t | The tile to change into river |
| random_bits | Random bits to be set for this tile |
Definition at line 436 of file water_map.h.
References MakeWater(), OWNER_WATER, and WATER_CLASS_RIVER.
Referenced by CmdBuildCanal(), MakeRiverAndModifyDesertZoneAround(), and RemoveLock().
|
inline |
Make a sea tile.
| t | The tile to change into sea |
Definition at line 426 of file water_map.h.
References MakeWater(), OWNER_WATER, and WATER_CLASS_SEA.
Referenced by AfterLoadGame(), CmdBuildCanal(), and DoFloodTile().
|
inline |
Make a ship depot section.
| t | Tile to place the ship depot section. |
| o | Owner of the depot. |
| did | Depot ID. |
| part | Depot part (either DEPOT_PART_NORTH or DEPOT_PART_SOUTH). |
| a | Axis of the depot. |
| original_water_class | Original water class. |
Definition at line 462 of file water_map.h.
References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), MP_WATER, SB(), SetDockingTile(), SetTileOwner(), SetTileType(), SetWaterClass(), SetWaterTileType(), WATER_TILE_DEPOT, WBL_DEPOT_AXIS, and WBL_DEPOT_PART.
Referenced by CmdBuildShipDepot().
|
inline |
Helper function to make a coast tile.
| t | The tile to change into water |
Definition at line 383 of file water_map.h.
References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), MP_WATER, OWNER_WATER, SB(), SetDockingTile(), SetTileOwner(), SetTileType(), SetWaterClass(), SetWaterTileType(), WATER_CLASS_SEA, and WATER_TILE_COAST.
Referenced by AfterLoadGame(), CmdRemoveSingleRail(), DoFloodTile(), and FloodHalftile().
|
inline |
Helper function for making a watery tile.
| t | The tile to change into water |
| o | The owner of the water |
| wc | The class of water the tile has to be |
| random_bits | Eventual random bits to be set for this tile |
Definition at line 406 of file water_map.h.
References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), MP_WATER, SB(), SetDockingTile(), SetTileOwner(), SetTileType(), SetWaterClass(), SetWaterTileType(), and WATER_TILE_CLEAR.
Referenced by MakeCanal(), MakeRiver(), and MakeSea().
|
inline |
Set the docking tile state of a tile.
This is used by pathfinders to reach their destination. As well as water tiles, half-rail tiles, buoys and aqueduct ends can also be docking tiles.
| t | the tile |
| b | the docking tile state |
Definition at line 363 of file water_map.h.
References AssignBit(), IsTileType(), Tile::m1(), MP_RAILWAY, MP_STATION, MP_TUNNELBRIDGE, and MP_WATER.
Referenced by AfterLoadGame(), CheckForDockingTile(), ClearDockingTilesCheckingNeighbours(), CmdRemoveSingleRail(), MakeBridgeRamp(), MakeLockTile(), MakeRailDepot(), MakeShipDepot(), MakeShore(), MakeStation(), and MakeWater().
|
inline |
Set the non-flooding water tile state of a tile.
| t | the tile |
| b | the non-flooding water tile state |
Definition at line 530 of file water_map.h.
References AssignBit(), IsTileType(), Tile::m3(), and MP_WATER.
Referenced by AfterLoadGame(), ClearNeighbourNonFloodingStates(), and TileLoop_Water().
|
inline |
Set the water class at a tile.
| t | Water tile to change. |
| wc | New water class. |
Definition at line 126 of file water_map.h.
References HasTileWaterClass(), Tile::m1(), and SB().
Referenced by AfterLoadGame(), MakeIndustry(), MakeLockTile(), MakeObject(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeWater(), SetTreeGroundDensity(), and SetWaterClassDependingOnSurroundings().
|
inline |
Set the water tile type of a tile.
| t | Water tile to set. |
| type | Water tile type of the tile. |
Definition at line 91 of file water_map.h.
References IsTileType(), Tile::m5(), MP_WATER, SB(), to_underlying(), WBL_TYPE_BEGIN, and WBL_TYPE_COUNT.
Referenced by AfterLoadGame(), MakeLockTile(), MakeShipDepot(), MakeShore(), and MakeWater().
|
staticconstexpr |
Depot axis flag.
Definition at line 28 of file water_map.h.
Referenced by GetShipDepotAxis(), and MakeShipDepot().
|
staticconstexpr |
Depot part flag.
Definition at line 27 of file water_map.h.
Referenced by GetShipDepotPart(), and MakeShipDepot().
|
staticconstexpr |
Start of lock orientation bitfield.
Definition at line 22 of file water_map.h.
Referenced by GetLockDirection(), and MakeLockTile().
|
staticconstexpr |
Length of lock orientation bitfield.
Definition at line 23 of file water_map.h.
Referenced by GetLockDirection().
|
staticconstexpr |
Start of lock part bitfield.
Definition at line 24 of file water_map.h.
Referenced by GetLockPart(), and MakeLockTile().
|
staticconstexpr |
Length of lock part bitfield.
Definition at line 25 of file water_map.h.
Referenced by GetLockPart().
|
staticconstexpr |
Bit field layout of m5 for water tiles.
Start of the 'type' bitfield.
Definition at line 19 of file water_map.h.
Referenced by GetWaterTileType(), and SetWaterTileType().
|
staticconstexpr |
Length of the 'type' bitfield.
Definition at line 20 of file water_map.h.
Referenced by GetWaterTileType(), and SetWaterTileType().