mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Use range-based for loops for checking all directions
This commit is contained in:
@@ -339,7 +339,7 @@ private:
|
||||
money32 GetSurfaceHeightChangeCost(SurfaceElement * surfaceElement) const
|
||||
{
|
||||
money32 cost{ 0 };
|
||||
for (int32_t i = 0; i < 4; i += 1)
|
||||
for (Direction i : ALL_DIRECTIONS)
|
||||
{
|
||||
int32_t cornerHeight = tile_element_get_corner_height(surfaceElement, i);
|
||||
cornerHeight -= map_get_corner_height(_height, _style & TILE_ELEMENT_SURFACE_SLOPE_MASK, i);
|
||||
|
||||
@@ -332,7 +332,7 @@ private:
|
||||
{ 16, 0 },
|
||||
};
|
||||
|
||||
for (uint8_t dir = 0; dir < 4; dir++)
|
||||
for (Direction dir : ALL_DIRECTIONS)
|
||||
{
|
||||
const LocationXY16& off = DirOffsets[dir];
|
||||
money32 removePrice = MazeRemoveTrack(x + off.x, y + off.y, z, dir);
|
||||
|
||||
@@ -344,23 +344,23 @@ static uint8_t footpath_element_dest_in_dir(TileCoordsXYZ loc, Direction chosenD
|
||||
edges &= ~(1 << direction_reverse(chosenDirection));
|
||||
loc.z = tileElement->base_height;
|
||||
|
||||
for (direction = 0; direction < 4; direction++)
|
||||
for (Direction dir : ALL_DIRECTIONS)
|
||||
{
|
||||
if (!(edges & (1 << direction)))
|
||||
if (!(edges & (1 << dir)))
|
||||
continue;
|
||||
|
||||
edges &= ~(1 << direction);
|
||||
edges &= ~(1 << dir);
|
||||
if (edges != 0)
|
||||
return PATH_SEARCH_JUNCTION;
|
||||
|
||||
if (tileElement->AsPath()->IsSloped())
|
||||
{
|
||||
if (tileElement->AsPath()->GetSlopeDirection() == direction)
|
||||
if (tileElement->AsPath()->GetSlopeDirection() == dir)
|
||||
{
|
||||
loc.z += 2;
|
||||
}
|
||||
}
|
||||
return footpath_element_dest_in_dir(loc, direction, outRideIndex, level + 1);
|
||||
return footpath_element_dest_in_dir(loc, dir, outRideIndex, level + 1);
|
||||
}
|
||||
return PATH_SEARCH_DEAD_END;
|
||||
}
|
||||
@@ -1889,7 +1889,7 @@ int32_t guest_path_finding(Guest* peep)
|
||||
/* If this tileElement is adjacent to any non-wide paths,
|
||||
* remove all of the edges to wide paths. */
|
||||
uint8_t adjustedEdges = edges;
|
||||
for (Direction chosenDirection = 0; direction_valid(chosenDirection); chosenDirection++)
|
||||
for (Direction chosenDirection : ALL_DIRECTIONS)
|
||||
{
|
||||
// If there is no path in that direction try another
|
||||
if (!(adjustedEdges & (1 << chosenDirection)))
|
||||
@@ -1971,7 +1971,7 @@ int32_t guest_path_finding(Guest* peep)
|
||||
if (!peep->HasFood() && (scenario_rand() & 0xFFFF) >= 2184)
|
||||
{
|
||||
uint8_t adjustedEdges = edges;
|
||||
for (Direction chosenDirection = 0; direction_valid(chosenDirection); chosenDirection++)
|
||||
for (Direction chosenDirection : ALL_DIRECTIONS)
|
||||
{
|
||||
// If there is no path in that direction try another
|
||||
if (!(adjustedEdges & (1 << chosenDirection)))
|
||||
|
||||
@@ -234,7 +234,7 @@ bool staff_can_ignore_wide_flag(Peep* staff, int32_t x, int32_t y, uint8_t z, Ti
|
||||
uint8_t total = 0;
|
||||
uint8_t pathcount = 0;
|
||||
uint8_t widecount = 0;
|
||||
for (int32_t adjac_dir = 0; adjac_dir <= 3; adjac_dir++)
|
||||
for (Direction adjac_dir : ALL_DIRECTIONS)
|
||||
{
|
||||
int32_t adjac_x = x + CoordsDirectionDelta[adjac_dir].x;
|
||||
int32_t adjac_y = y + CoordsDirectionDelta[adjac_dir].y;
|
||||
|
||||
@@ -741,7 +741,7 @@ static bool footpath_disconnect_queue_from_path(int32_t x, int32_t y, TileElemen
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int32_t direction = 0; direction < 4; direction++)
|
||||
for (Direction direction : ALL_DIRECTIONS)
|
||||
{
|
||||
if ((action < 0) && (direction == tileElement->AsPath()->GetSlopeDirection()))
|
||||
continue;
|
||||
@@ -980,7 +980,7 @@ void footpath_connect_edges(int32_t x, int32_t y, TileElement* tileElement, int3
|
||||
neighbour_list_init(&neighbourList);
|
||||
|
||||
footpath_update_queue_entrance_banner(x, y, tileElement);
|
||||
for (int32_t direction = 0; direction < 4; direction++)
|
||||
for (Direction direction : ALL_DIRECTIONS)
|
||||
{
|
||||
loc_6A6C85(x, y, direction, tileElement, flags, true, &neighbourList);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user