This commit is contained in:
@@ -25,6 +25,7 @@ constexpr TWaterRegionPatchLabel FIRST_REGION_LABEL = 1;
|
||||
constexpr TWaterRegionPatchLabel INVALID_WATER_REGION_PATCH = 0;
|
||||
|
||||
static_assert(sizeof(TWaterRegionTraversabilityBits) * 8 == WATER_REGION_EDGE_LENGTH);
|
||||
static_assert(sizeof(TWaterRegionPatchLabel) == sizeof(byte)); // Important for the hash calculation.
|
||||
|
||||
static inline TrackBits GetWaterTracks(TileIndex tile) { return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0)); }
|
||||
static inline bool IsAqueductTile(TileIndex tile) { return IsBridgeTile(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER; }
|
||||
@@ -225,14 +226,23 @@ WaterRegion &GetUpdatedWaterRegion(TileIndex tile)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the water region
|
||||
* @param water_region The Water region to return the index for
|
||||
* Returns the index of the water region.
|
||||
* @param water_region The water region to return the index for.
|
||||
*/
|
||||
TWaterRegionIndex GetWaterRegionIndex(const WaterRegionDesc &water_region)
|
||||
{
|
||||
return GetWaterRegionIndex(water_region.x, water_region.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a number that uniquely identifies the provided water region patch.
|
||||
* @param water_region_patch The Water region to calculate the hash for.
|
||||
*/
|
||||
int CalculateWaterRegionPatchHash(const WaterRegionPatchDesc &water_region_patch)
|
||||
{
|
||||
return water_region_patch.label | GetWaterRegionIndex(water_region_patch) << 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the center tile of a particular water region.
|
||||
* @param water_region The water region to find the center tile for.
|
||||
|
@@ -50,6 +50,8 @@ struct WaterRegionDesc
|
||||
|
||||
TWaterRegionIndex GetWaterRegionIndex(const WaterRegionDesc &water_region);
|
||||
|
||||
int CalculateWaterRegionPatchHash(const WaterRegionPatchDesc &water_region_patch);
|
||||
|
||||
TileIndex GetWaterRegionCenterTile(const WaterRegionDesc &water_region);
|
||||
|
||||
WaterRegionDesc GetWaterRegionInfo(TileIndex tile);
|
||||
|
@@ -24,14 +24,12 @@ constexpr int MAX_NUMBER_OF_NODES = 65536;
|
||||
struct CYapfRegionPatchNodeKey {
|
||||
WaterRegionPatchDesc m_water_region_patch;
|
||||
|
||||
static_assert(sizeof(TWaterRegionPatchLabel) == sizeof(byte)); // Important for the hash calculation.
|
||||
|
||||
inline void Set(const WaterRegionPatchDesc &water_region_patch)
|
||||
{
|
||||
m_water_region_patch = water_region_patch;
|
||||
}
|
||||
|
||||
inline int CalcHash() const { return m_water_region_patch.label | GetWaterRegionIndex(m_water_region_patch) << 8; }
|
||||
inline int CalcHash() const { return CalculateWaterRegionPatchHash(m_water_region_patch); }
|
||||
inline bool operator==(const CYapfRegionPatchNodeKey &other) const { return CalcHash() == other.CalcHash(); }
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user