From 19b65cd3e71e82705d54e144ad099fd77be17e5e Mon Sep 17 00:00:00 2001 From: Kuhnovic <68320206+Kuhnovic@users.noreply.github.com> Date: Wed, 10 Dec 2025 14:14:13 +0100 Subject: [PATCH] Codechange: Added DIAGDIRECTIONS_ALL. (#14895) --- src/direction_type.h | 3 +++ src/pathfinder/water_regions.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/direction_type.h b/src/direction_type.h index e1775647ac..8ff73fdb48 100644 --- a/src/direction_type.h +++ b/src/direction_type.h @@ -89,6 +89,9 @@ DECLARE_ENUM_AS_ADDABLE(DiagDirection) using DiagDirections = EnumBitSet; +/** All possible diagonal directions. */ +static constexpr DiagDirections DIAGDIRECTIONS_ALL{DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_NW}; + /** * Enumeration for the difference between to DiagDirection. * diff --git a/src/pathfinder/water_regions.cpp b/src/pathfinder/water_regions.cpp index e725401f52..5342d9421b 100644 --- a/src/pathfinder/water_regions.cpp +++ b/src/pathfinder/water_regions.cpp @@ -325,7 +325,7 @@ void InvalidateWaterRegion(TileIndex tile) /* When updating the water region we look into the first tile of adjacent water regions to determine edge * traversability. This means that if we invalidate any region edge tiles we might also change the traversability * of the adjacent region. This code ensures the adjacent regions also get invalidated in such a case. */ - for (DiagDirection side = DIAGDIR_BEGIN; side < DIAGDIR_END; side++) { + for (DiagDirection side : DIAGDIRECTIONS_ALL) { const TileIndex adjacent_tile = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(side)); if (adjacent_tile == INVALID_TILE) continue; if (GetWaterRegionIndex(adjacent_tile) != GetWaterRegionIndex(tile)) invalidate_region(adjacent_tile); @@ -395,7 +395,7 @@ void VisitWaterRegionPatchNeighbours(const WaterRegionPatchDesc &water_region_pa const WaterRegion current_region = GetUpdatedWaterRegion(water_region_patch.x, water_region_patch.y); /* Visit adjacent water region patches in each cardinal direction */ - for (DiagDirection side = DIAGDIR_BEGIN; side < DIAGDIR_END; side++) VisitAdjacentWaterRegionPatchNeighbours(water_region_patch, side, callback); + for (DiagDirection side : DIAGDIRECTIONS_ALL) VisitAdjacentWaterRegionPatchNeighbours(water_region_patch, side, callback); /* Visit neighbouring water patches accessible via cross-region aqueducts */ if (current_region.HasCrossRegionAqueducts()) {