|
OpenTTD Source
14.0-beta3
|
Represents a square section of the map of a fixed size. More...
Public Member Functions | |
| WaterRegion (int region_x, int region_y) | |
| OrthogonalTileIterator | begin () const |
| OrthogonalTileIterator | end () const |
| bool | IsInitialized () const |
| void | Invalidate () |
| TWaterRegionTraversabilityBits | GetEdgeTraversabilityBits (DiagDirection side) const |
| Returns a set of bits indicating whether an edge tile on a particular side is traversable or not. More... | |
| int | NumberOfPatches () const |
| bool | HasCrossRegionAqueducts () const |
| TWaterRegionPatchLabel | GetLabel (TileIndex tile) const |
| Returns the patch label that was assigned to the tile. More... | |
| void | ForceUpdate () |
| Performs the connected component labeling and other data gathering. More... | |
| void | UpdateIfNotInitialized () |
| Updates the patch labels and other data, but only if the region is not yet initialized. | |
| void | PrintDebugInfo () |
Private Member Functions | |
| int | GetLocalIndex (TileIndex tile) const |
| Returns the local index of the tile within the region. More... | |
Private Attributes | |
| std::array< TWaterRegionTraversabilityBits, DIAGDIR_END > | edge_traversability_bits {} |
| bool | has_cross_region_aqueducts = false |
| TWaterRegionPatchLabel | number_of_patches = 0 |
| const OrthogonalTileArea | tile_area |
| std::array< TWaterRegionPatchLabel, WATER_REGION_NUMBER_OF_TILES > | tile_patch_labels {} |
| bool | initialized = false |
Represents a square section of the map of a fixed size.
Within this square individual unconnected patches of water are identified using a Connected Component Labeling (CCL) algorithm. Note that all information stored in this class applies only to tiles within the square section, there is no knowledge about the rest of the map. This makes it easy to invalidate and update a water region if any changes are made to it, such as construction or terraforming.
Definition at line 48 of file water_regions.cpp.
|
inline |
Performs the connected component labeling and other data gathering.
Definition at line 121 of file water_regions.cpp.
References Debug.
Referenced by UpdateIfNotInitialized().
|
inline |
Returns a set of bits indicating whether an edge tile on a particular side is traversable or not.
These values can be used to determine whether a ship can enter/leave the region through a particular edge tile.
| side | Which side of the region we want to know the edge traversability of. |
Definition at line 93 of file water_regions.cpp.
|
inline |
Returns the patch label that was assigned to the tile.
| tile | The tile of which we want to retrieve the label. |
Definition at line 111 of file water_regions.cpp.
References OrthogonalTileArea::Contains(), and GetLocalIndex().
|
inlineprivate |
Returns the local index of the tile within the region.
The N corner represents 0, the x direction is positive in the SW direction, and Y is positive in the SE direction.
| tile | Tile within the water region. |
Definition at line 64 of file water_regions.cpp.
References OrthogonalTileArea::Contains(), OrthogonalTileArea::tile, and TileX().
Referenced by GetLabel().
|
inline |
Definition at line 104 of file water_regions.cpp.
|
inline |
Definition at line 99 of file water_regions.cpp.