1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Use continue to prevent nested brackets

This commit is contained in:
duncanspumpkin
2019-03-12 17:43:31 +00:00
parent 6a177e696b
commit cdabb7c388
4 changed files with 130 additions and 127 deletions

View File

@@ -100,8 +100,9 @@ private:
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32)
{ {
TileElement* tileElement = map_get_surface_element_at(x / 32, y / 32); TileElement* tileElement = map_get_surface_element_at(x / 32, y / 32);
if (tileElement != nullptr) if (tileElement == nullptr)
{ continue;
SurfaceElement* surfaceElement = tileElement->AsSurface(); SurfaceElement* surfaceElement = tileElement->AsSurface();
uint8_t height = surfaceElement->base_height; uint8_t height = surfaceElement->base_height;
if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK) if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK)
@@ -109,8 +110,9 @@ private:
if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG) if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG)
height += 2; height += 2;
if (height >= maxHeight) if (height < maxHeight)
{ continue;
height = surfaceElement->base_height; height = surfaceElement->base_height;
uint8_t currentSlope = surfaceElement->GetSlope(); uint8_t currentSlope = surfaceElement->GetSlope();
uint8_t newSlope = tile_element_lower_styles[tableRow][currentSlope]; uint8_t newSlope = tile_element_lower_styles[tableRow][currentSlope];
@@ -134,8 +136,6 @@ private:
} }
} }
} }
}
}
// Force ride construction to recheck area // Force ride construction to recheck area
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_RECHECK; _currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_RECHECK;

View File

@@ -100,13 +100,15 @@ private:
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32)
{ {
TileElement* tileElement = map_get_surface_element_at(x / 32, y / 32); TileElement* tileElement = map_get_surface_element_at(x / 32, y / 32);
if (tileElement != nullptr) if (tileElement == nullptr)
{ continue;
SurfaceElement* surfaceElement = tileElement->AsSurface(); SurfaceElement* surfaceElement = tileElement->AsSurface();
uint8_t height = surfaceElement->base_height; uint8_t height = surfaceElement->base_height;
if (height <= minHeight) if (height > minHeight)
{ continue;
uint8_t currentSlope = surfaceElement->GetSlope(); uint8_t currentSlope = surfaceElement->GetSlope();
uint8_t newSlope = tile_element_raise_styles[tableRow][currentSlope]; uint8_t newSlope = tile_element_raise_styles[tableRow][currentSlope];
if (newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT) if (newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT)
@@ -129,8 +131,6 @@ private:
} }
} }
} }
}
}
// Force ride construction to recheck area // Force ride construction to recheck area
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_RECHECK; _currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_RECHECK;

View File

@@ -81,15 +81,18 @@ private:
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32)
{ {
TileElement* tileElement = map_get_surface_element_at(x / 32, y / 32); TileElement* tileElement = map_get_surface_element_at(x / 32, y / 32);
if (tileElement != nullptr) if (tileElement == nullptr)
{ continue;
SurfaceElement* surfaceElement = tileElement->AsSurface(); SurfaceElement* surfaceElement = tileElement->AsSurface();
uint8_t height = surfaceElement->GetWaterHeight(); uint8_t height = surfaceElement->GetWaterHeight();
if (height != 0) if (height == 0)
{ continue;
height *= 2; height *= 2;
if (height < minHeight) if (height < minHeight)
continue; continue;
height -= 2; height -= 2;
auto waterSetHeightAction = WaterSetHeightAction({ x, y }, height); auto waterSetHeightAction = WaterSetHeightAction({ x, y }, height);
waterSetHeightAction.SetFlags(GetFlags()); waterSetHeightAction.SetFlags(GetFlags());
@@ -107,8 +110,6 @@ private:
} }
} }
} }
}
}
if (isExecuting && hasChanged) if (isExecuting && hasChanged)
{ {
@@ -129,18 +130,20 @@ private:
for (int32_t x = _range.GetLeft(); x <= _range.GetRight(); x += 32) for (int32_t x = _range.GetLeft(); x <= _range.GetRight(); x += 32)
{ {
TileElement* tile_element = map_get_surface_element_at({ x, y }); TileElement* tile_element = map_get_surface_element_at({ x, y });
if (tile_element != nullptr) if (tile_element == nullptr)
{ continue;
uint8_t height = tile_element->AsSurface()->GetWaterHeight(); uint8_t height = tile_element->AsSurface()->GetWaterHeight();
if (height != 0) if (height == 0)
{ continue;
height *= 2; height *= 2;
if (height > minHeight) if (height > minHeight)
{
minHeight = height; minHeight = height;
} }
} }
} }
}
return minHeight; return minHeight;
} }

View File

@@ -81,8 +81,9 @@ private:
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32)
{ {
TileElement* tileElement = map_get_surface_element_at(x / 32, y / 32); TileElement* tileElement = map_get_surface_element_at(x / 32, y / 32);
if (tileElement != nullptr) if (tileElement == nullptr)
{ continue;
SurfaceElement* surfaceElement = tileElement->AsSurface(); SurfaceElement* surfaceElement = tileElement->AsSurface();
uint8_t height = surfaceElement->GetWaterHeight(); uint8_t height = surfaceElement->GetWaterHeight();
if (height != 0) if (height != 0)
@@ -112,7 +113,6 @@ private:
} }
} }
} }
}
if (isExecuting && hasChanged) if (isExecuting && hasChanged)
{ {
@@ -133,8 +133,9 @@ private:
for (int32_t x = _range.GetLeft(); x <= _range.GetRight(); x += 32) for (int32_t x = _range.GetLeft(); x <= _range.GetRight(); x += 32)
{ {
TileElement* tile_element = map_get_surface_element_at({ x, y }); TileElement* tile_element = map_get_surface_element_at({ x, y });
if (tile_element != nullptr) if (tile_element == nullptr)
{ continue;
uint8_t height = tile_element->AsSurface()->GetWaterHeight(); uint8_t height = tile_element->AsSurface()->GetWaterHeight();
if (height != 0) if (height != 0)
{ {
@@ -146,7 +147,6 @@ private:
} }
} }
} }
}
return maxHeight; return maxHeight;
} }