OpenTTD Source
20241108-master-g80f628063a
|
Map accessors for water tiles. More...
Go to the source code of this file.
Enumerations | |
enum | WaterTileType { 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 { DEPOT_PART_NORTH = 0 , DEPOT_PART_SOUTH = 1 , DEPOT_PART_END } |
Sections of the water depot. More... | |
enum | LockPart { LOCK_PART_MIDDLE = 0 , LOCK_PART_LOWER = 1 , LOCK_PART_UPPER = 2 } |
Sections of the water lock. More... | |
Functions | |
bool | IsValidWaterClass (WaterClass wc) |
Checks if a water class is valid. More... | |
bool | IsPossibleDockingTile (Tile t) |
WaterTileType | GetWaterTileType (Tile t) |
Get the water tile type of a tile. More... | |
void | SetWaterTileType (Tile t, WaterTileType type) |
Set the water tile type of a tile. More... | |
bool | HasTileWaterClass (Tile t) |
Checks whether the tile has an waterclass associated. More... | |
WaterClass | GetWaterClass (Tile t) |
Get the water class at a tile. More... | |
void | SetWaterClass (Tile t, WaterClass wc) |
Set the water class at a tile. More... | |
bool | IsTileOnWater (Tile t) |
Tests if the tile was built on water. More... | |
bool | IsWater (Tile t) |
Is it a plain water tile? More... | |
bool | IsSea (Tile t) |
Is it a sea water tile? More... | |
bool | IsCanal (Tile t) |
Is it a canal tile? More... | |
bool | IsRiver (Tile t) |
Is it a river water tile? More... | |
bool | IsWaterTile (Tile t) |
Is it a water tile with plain water? More... | |
bool | IsCoast (Tile t) |
Is it a coast tile? More... | |
bool | IsCoastTile (Tile t) |
Is it a coast tile. More... | |
bool | IsShipDepot (Tile t) |
Is it a water tile with a ship depot on it? More... | |
bool | IsShipDepotTile (Tile t) |
Is it a ship depot tile? More... | |
Axis | GetShipDepotAxis (Tile t) |
Get the axis of the ship depot. More... | |
DepotPart | GetShipDepotPart (Tile t) |
Get the part of a ship depot. More... | |
DiagDirection | GetShipDepotDirection (Tile t) |
Get the direction of the ship depot. More... | |
TileIndex | GetOtherShipDepotTile (Tile t) |
Get the other tile of the ship depot. More... | |
TileIndex | GetShipDepotNorthTile (Tile t) |
Get the most northern tile of a ship depot. More... | |
bool | IsLock (Tile t) |
Is there a lock on a given water tile? More... | |
DiagDirection | GetLockDirection (Tile t) |
Get the direction of the water lock. More... | |
uint8_t | GetLockPart (Tile t) |
Get the part of a lock. More... | |
uint8_t | GetWaterTileRandomBits (Tile t) |
Get the random bits of the water tile. More... | |
bool | HasTileWaterGround (Tile t) |
Checks whether the tile has water at the ground. More... | |
void | SetDockingTile (Tile t, bool b) |
Set the docking tile state of a tile. More... | |
bool | IsDockingTile (Tile t) |
Checks whether the tile is marked as a dockling tile. More... | |
void | MakeShore (Tile t) |
Helper function to make a coast tile. More... | |
void | MakeWater (Tile t, Owner o, WaterClass wc, uint8_t random_bits) |
Helper function for making a watery tile. More... | |
void | MakeSea (Tile t) |
Make a sea tile. More... | |
void | MakeRiver (Tile t, uint8_t random_bits) |
Make a river tile. More... | |
void | MakeCanal (Tile t, Owner o, uint8_t random_bits) |
Make a canal tile. More... | |
void | MakeShipDepot (Tile t, Owner o, DepotID did, DepotPart part, Axis a, WaterClass original_water_class) |
Make a ship depot section. More... | |
void | MakeLockTile (Tile t, Owner o, LockPart part, DiagDirection dir, WaterClass original_water_class) |
Make a lock section. More... | |
void | MakeLock (Tile t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper, WaterClass wc_middle) |
Make a water lock. More... | |
void | SetNonFloodingWaterTile (Tile t, bool b) |
Set the non-flooding water tile state of a tile. More... | |
bool | IsNonFloodingWaterTile (Tile t) |
Checks whether the tile is marked as a non-flooding water tile. More... | |
Variables | |
static constexpr uint8_t | WBL_TYPE_BEGIN = 4 |
Bit field layout of m5 for water tiles. More... | |
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 |
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 |
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 |
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 314 of file water_map.h.
References GB(), IsLock(), Tile::m5(), WBL_LOCK_ORIENT_BEGIN, and WBL_LOCK_ORIENT_COUNT.
Referenced by RemoveLock().
|
inline |
Get the part of a lock.
t | Water tile to query. |
Definition at line 326 of file water_map.h.
References GB(), IsLock(), Tile::m5(), WBL_LOCK_PART_BEGIN, and WBL_LOCK_PART_COUNT.
Referenced by DrawWaterLock(), CanalScopeResolver::GetVariable(), and ShipTestUpDownOnLock().
Get the other tile of the ship depot.
t | Tile to query, containing one section of a ship depot. |
Definition at line 278 of file water_map.h.
References DEPOT_PART_NORTH, GetShipDepotAxis(), GetShipDepotPart(), and TileOffsByAxis().
Referenced by GetShipDepotNorthTile().
Get the axis of the ship depot.
t | Water tile to query. |
Definition at line 243 of file water_map.h.
References GB(), IsShipDepotTile(), Tile::m5(), and WBL_DEPOT_AXIS.
Referenced by GetOtherShipDepotTile(), and GetShipDepotDirection().
|
inline |
Get the direction of the ship depot.
t | Water tile to query. |
Definition at line 267 of file water_map.h.
References GetShipDepotAxis(), GetShipDepotPart(), and XYNSToDiagDir().
Referenced by Ship::GetVehicleTrackdir().
Get the most northern tile of a ship depot.
t | One of the tiles of the ship depot. |
Definition at line 289 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 255 of file water_map.h.
References GB(), IsShipDepotTile(), Tile::m5(), and WBL_DEPOT_PART.
Referenced by GetOtherShipDepotTile(), and GetShipDepotDirection().
|
inline |
Get the water class at a tile.
t | Water tile to query. |
Definition at line 112 of file water_map.h.
References GB(), HasTileWaterClass(), and Tile::m1().
Referenced by CmdBuildShipDepot(), CmdLandscapeClear(), DoBuildLock(), 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 338 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 78 of file water_map.h.
References GB(), IsTileType(), Tile::m5(), MP_WATER, WBL_TYPE_BEGIN, and WBL_TYPE_COUNT.
Referenced by 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 101 of file water_map.h.
References IsTileType(), MP_INDUSTRY, MP_OBJECT, MP_STATION, MP_TREES, and MP_WATER.
Referenced by CheckIfIndustryTilesAreFree(), CmdLandscapeClear(), 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 350 of file water_map.h.
References HasTileWaterClass(), IsCoastTile(), and IsTileOnWater().
Referenced by CanFollowRoad(), CmdBuildBuoy(), CmdBuildShipDepot(), DoBuildLock(), and GetClosestWaterDistance().
|
inline |
Is it a canal tile?
t | Water tile to query. |
true
if it is a canal tile. Definition at line 169 of file water_map.h.
References GetWaterClass(), IsWater(), and WATER_CLASS_CANAL.
Referenced by MarkTileDirtyIfCanalOrRiver().
|
inline |
Is it a coast tile?
t | Water tile to query. |
true
if it is a sea water tile. Definition at line 201 of file water_map.h.
References GetWaterTileType(), and WATER_TILE_COAST.
Referenced by CanPlantTreesOnTile(), GetFloodingBehaviour(), IsCoastTile(), and SetWaterClassDependingOnSurroundings().
|
inline |
Is it a coast tile.
t | Tile to query. |
true
if it is a coast. Definition at line 211 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 371 of file water_map.h.
References HasBit(), IsTileType(), Tile::m1(), MP_RAILWAY, MP_STATION, MP_TUNNELBRIDGE, and MP_WATER.
Referenced by IsShipDestinationTile(), and CYapfCostShipT< Types >::PfCalcCost().
|
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 303 of file water_map.h.
References GetWaterTileType(), and WATER_TILE_LOCK.
Referenced by GetLockDirection(), GetLockPart(), CanalScopeResolver::GetVariable(), SetWaterClassDependingOnSurroundings(), and ShipTestUpDownOnLock().
|
inline |
Checks whether the tile is marked as a non-flooding water tile.
Definition at line 533 of file water_map.h.
References HasBit(), IsTileType(), Tile::m3(), and MP_WATER.
Referenced by TileLoop_Water().
|
inline |
Is it a river water tile?
t | Water tile to query. |
true
if it is a river water tile. Definition at line 180 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 158 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 222 of file water_map.h.
References GetWaterTileType(), and WATER_TILE_DEPOT.
Referenced by 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 232 of file water_map.h.
References IsShipDepot(), IsTileType(), and MP_WATER.
Referenced by GetDepotIndex(), GetShipDepotAxis(), GetShipDepotPart(), and IsDepotTile().
|
inline |
Tests if the tile was built on water.
t | the tile to check |
Definition at line 136 of file water_map.h.
References GetWaterClass(), and WATER_CLASS_INVALID.
Referenced by CheckIfIndustryTilesAreFree(), CmdLandscapeClear(), and HasTileWaterGround().
|
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 147 of file water_map.h.
References GetWaterTileType(), and WATER_TILE_CLEAR.
Referenced by 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 190 of file water_map.h.
References IsTileType(), IsWater(), and MP_WATER.
Referenced by CheckIfIndustryTilesAreFree(), CmdLandscapeClear(), DoBuildLock(), FindSpring(), FlowRiver(), GrowTownWithBridge(), 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 443 of file water_map.h.
References MakeWater(), OWNER_WATER, and WATER_CLASS_CANAL.
|
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 506 of file water_map.h.
References GetTileOwner(), IsWaterTile(), LOCK_PART_LOWER, LOCK_PART_MIDDLE, LOCK_PART_UPPER, MakeLockTile(), and TileOffsByDiagDir().
|
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 482 of file water_map.h.
References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), 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 432 of file water_map.h.
References MakeWater(), OWNER_WATER, and WATER_CLASS_RIVER.
Referenced by MakeRiverAndModifyDesertZoneAround(), and RemoveLock().
|
inline |
Make a sea tile.
t | The tile to change into sea |
Definition at line 422 of file water_map.h.
References MakeWater(), OWNER_WATER, and WATER_CLASS_SEA.
Referenced by 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 458 of file water_map.h.
References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), MP_WATER, SB(), SetDockingTile(), SetTileOwner(), SetTileType(), SetWaterClass(), SetWaterTileType(), WATER_TILE_DEPOT, WBL_DEPOT_AXIS, and WBL_DEPOT_PART.
|
inline |
Helper function to make a coast tile.
t | The tile to change into water |
Definition at line 381 of file water_map.h.
References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), MP_WATER, OWNER_WATER, SB(), SetDockingTile(), SetTileOwner(), SetTileType(), SetWaterClass(), SetWaterTileType(), WATER_CLASS_SEA, and WATER_TILE_COAST.
Referenced by DoFloodTile().
|
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 403 of file water_map.h.
References Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), 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 361 of file water_map.h.
References AssignBit(), IsTileType(), Tile::m1(), MP_RAILWAY, MP_STATION, MP_TUNNELBRIDGE, and MP_WATER.
Referenced by CheckForDockingTile(), 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 524 of file water_map.h.
References AssignBit(), IsTileType(), Tile::m3(), and MP_WATER.
Referenced by ClearNeighbourNonFloodingStates(), and TileLoop_Water().
|
inline |
Set the water class at a tile.
t | Water tile to change. |
wc | New water class. |
Definition at line 124 of file water_map.h.
References HasTileWaterClass(), Tile::m1(), and SB().
Referenced by 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 89 of file water_map.h.
References IsTileType(), Tile::m5(), MP_WATER, SB(), to_underlying(), WBL_TYPE_BEGIN, and WBL_TYPE_COUNT.
Referenced by MakeLockTile(), MakeShipDepot(), MakeShore(), and MakeWater().
|
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().