OpenTTD Source 20241224-master-gee860a5c8e
|
Represents a square section of the map of a fixed size. More...
Public Member Functions | |
WaterRegion (int region_x, int region_y, WaterRegionData &water_region_data) | |
OrthogonalTileIterator | begin () const |
OrthogonalTileIterator | end () const |
TWaterRegionTraversabilityBits | GetEdgeTraversabilityBits (DiagDirection side) const |
Returns a set of bits indicating whether an edge tile on a particular side is traversable or not. | |
int | NumberOfPatches () const |
bool | HasCrossRegionAqueducts () const |
TWaterRegionPatchLabel | GetLabel (TileIndex tile) const |
Returns the patch label that was assigned to the tile. | |
void | ForceUpdate () |
Performs the connected component labeling and other data gathering. | |
void | PrintDebugInfo () |
Private Member Functions | |
int | GetLocalIndex (TileIndex tile) const |
Returns the local index of the tile within the region. | |
Private Attributes | |
WaterRegionData & | data |
const OrthogonalTileArea | tile_area |
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 60 of file water_regions.cpp.
|
inline |
Definition at line 79 of file water_regions.cpp.
|
inline |
Definition at line 84 of file water_regions.cpp.
|
inline |
Definition at line 85 of file water_regions.cpp.
|
inline |
Performs the connected component labeling and other data gathering.
Definition at line 125 of file water_regions.cpp.
References AXIS_X, OrthogonalTileArea::Contains(), Debug, DiagdirBetweenTiles(), DiagDirToAxis(), DistanceManhattan(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetLocalIndex(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_bridge, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_tile, NumberOfPatches(), SetBit(), OrthogonalTileArea::tile, TileX(), TileY(), TrackBitsToTrackdirBits(), and TRACKDIR_BIT_NONE.
|
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 94 of file water_regions.cpp.
Referenced by VisitAdjacentWaterRegionPatchNeighbors().
|
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 112 of file water_regions.cpp.
References OrthogonalTileArea::Contains(), GetLocalIndex(), and NumberOfPatches().
Referenced by GetWaterRegionPatchInfo(), and VisitAdjacentWaterRegionPatchNeighbors().
|
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 72 of file water_regions.cpp.
References OrthogonalTileArea::Contains(), OrthogonalTileArea::tile, TileX(), and TileY().
Referenced by ForceUpdate(), and GetLabel().
|
inline |
Definition at line 105 of file water_regions.cpp.
Referenced by VisitWaterRegionPatchNeighbors().
|
inline |
Definition at line 100 of file water_regions.cpp.
Referenced by ForceUpdate(), GetLabel(), and VisitAdjacentWaterRegionPatchNeighbors().
|
inline |
Definition at line 193 of file water_regions.cpp.
|
private |
Definition at line 63 of file water_regions.cpp.
|
private |
Definition at line 64 of file water_regions.cpp.