mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Use continue to prevent nested brackets
This commit is contained in:
@@ -100,39 +100,39 @@ 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();
|
||||||
|
uint8_t height = surfaceElement->base_height;
|
||||||
|
if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK)
|
||||||
|
height += 2;
|
||||||
|
if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG)
|
||||||
|
height += 2;
|
||||||
|
|
||||||
|
if (height < maxHeight)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
height = surfaceElement->base_height;
|
||||||
|
uint8_t currentSlope = surfaceElement->GetSlope();
|
||||||
|
uint8_t newSlope = tile_element_lower_styles[tableRow][currentSlope];
|
||||||
|
if (newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT)
|
||||||
|
height -= 2;
|
||||||
|
|
||||||
|
newSlope &= TILE_ELEMENT_SURFACE_SLOPE_MASK;
|
||||||
|
|
||||||
|
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
|
||||||
|
landSetHeightAction.SetFlags(GetFlags());
|
||||||
|
auto result = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction)
|
||||||
|
: GameActions::QueryNested(&landSetHeightAction);
|
||||||
|
if (result->Error == GA_ERROR::OK)
|
||||||
{
|
{
|
||||||
SurfaceElement* surfaceElement = tileElement->AsSurface();
|
res->Cost += result->Cost;
|
||||||
uint8_t height = surfaceElement->base_height;
|
}
|
||||||
if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK)
|
else
|
||||||
height += 2;
|
{
|
||||||
if (surfaceElement->GetSlope() & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG)
|
result->ErrorTitle = STR_CANT_LOWER_LAND_HERE;
|
||||||
height += 2;
|
return result;
|
||||||
|
|
||||||
if (height >= maxHeight)
|
|
||||||
{
|
|
||||||
height = surfaceElement->base_height;
|
|
||||||
uint8_t currentSlope = surfaceElement->GetSlope();
|
|
||||||
uint8_t newSlope = tile_element_lower_styles[tableRow][currentSlope];
|
|
||||||
if (newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT)
|
|
||||||
height -= 2;
|
|
||||||
|
|
||||||
newSlope &= TILE_ELEMENT_SURFACE_SLOPE_MASK;
|
|
||||||
|
|
||||||
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
|
|
||||||
landSetHeightAction.SetFlags(GetFlags());
|
|
||||||
auto result = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction)
|
|
||||||
: GameActions::QueryNested(&landSetHeightAction);
|
|
||||||
if (result->Error == GA_ERROR::OK)
|
|
||||||
{
|
|
||||||
res->Cost += result->Cost;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result->ErrorTitle = STR_CANT_LOWER_LAND_HERE;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,34 +100,34 @@ 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();
|
||||||
|
uint8_t height = surfaceElement->base_height;
|
||||||
|
|
||||||
|
if (height > minHeight)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uint8_t currentSlope = surfaceElement->GetSlope();
|
||||||
|
uint8_t newSlope = tile_element_raise_styles[tableRow][currentSlope];
|
||||||
|
if (newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT)
|
||||||
|
height += 2;
|
||||||
|
|
||||||
|
newSlope &= TILE_ELEMENT_SURFACE_SLOPE_MASK;
|
||||||
|
|
||||||
|
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
|
||||||
|
landSetHeightAction.SetFlags(GetFlags());
|
||||||
|
auto result = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction)
|
||||||
|
: GameActions::QueryNested(&landSetHeightAction);
|
||||||
|
if (result->Error == GA_ERROR::OK)
|
||||||
{
|
{
|
||||||
SurfaceElement* surfaceElement = tileElement->AsSurface();
|
res->Cost += result->Cost;
|
||||||
uint8_t height = surfaceElement->base_height;
|
}
|
||||||
|
else
|
||||||
if (height <= minHeight)
|
{
|
||||||
{
|
result->ErrorTitle = STR_CANT_RAISE_LAND_HERE;
|
||||||
uint8_t currentSlope = surfaceElement->GetSlope();
|
return result;
|
||||||
uint8_t newSlope = tile_element_raise_styles[tableRow][currentSlope];
|
|
||||||
if (newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT)
|
|
||||||
height += 2;
|
|
||||||
|
|
||||||
newSlope &= TILE_ELEMENT_SURFACE_SLOPE_MASK;
|
|
||||||
|
|
||||||
auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope);
|
|
||||||
landSetHeightAction.SetFlags(GetFlags());
|
|
||||||
auto result = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction)
|
|
||||||
: GameActions::QueryNested(&landSetHeightAction);
|
|
||||||
if (result->Error == GA_ERROR::OK)
|
|
||||||
{
|
|
||||||
res->Cost += result->Cost;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result->ErrorTitle = STR_CANT_RAISE_LAND_HERE;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,31 +81,32 @@ 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();
|
||||||
|
uint8_t height = surfaceElement->GetWaterHeight();
|
||||||
|
if (height == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
height *= 2;
|
||||||
|
if (height < minHeight)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
height -= 2;
|
||||||
|
auto waterSetHeightAction = WaterSetHeightAction({ x, y }, height);
|
||||||
|
waterSetHeightAction.SetFlags(GetFlags());
|
||||||
|
auto result = isExecuting ? GameActions::ExecuteNested(&waterSetHeightAction)
|
||||||
|
: GameActions::QueryNested(&waterSetHeightAction);
|
||||||
|
if (result->Error == GA_ERROR::OK)
|
||||||
{
|
{
|
||||||
SurfaceElement* surfaceElement = tileElement->AsSurface();
|
res->Cost += result->Cost;
|
||||||
uint8_t height = surfaceElement->GetWaterHeight();
|
hasChanged = true;
|
||||||
if (height != 0)
|
}
|
||||||
{
|
else
|
||||||
height *= 2;
|
{
|
||||||
if (height < minHeight)
|
result->ErrorTitle = STR_CANT_LOWER_WATER_LEVEL_HERE;
|
||||||
continue;
|
return result;
|
||||||
height -= 2;
|
|
||||||
auto waterSetHeightAction = WaterSetHeightAction({ x, y }, height);
|
|
||||||
waterSetHeightAction.SetFlags(GetFlags());
|
|
||||||
auto result = isExecuting ? GameActions::ExecuteNested(&waterSetHeightAction)
|
|
||||||
: GameActions::QueryNested(&waterSetHeightAction);
|
|
||||||
if (result->Error == GA_ERROR::OK)
|
|
||||||
{
|
|
||||||
res->Cost += result->Cost;
|
|
||||||
hasChanged = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result->ErrorTitle = STR_CANT_LOWER_WATER_LEVEL_HERE;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,15 +130,17 @@ 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();
|
||||||
|
if (height == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
height *= 2;
|
||||||
|
if (height > minHeight)
|
||||||
{
|
{
|
||||||
uint8_t height = tile_element->AsSurface()->GetWaterHeight();
|
minHeight = height;
|
||||||
if (height != 0)
|
|
||||||
{
|
|
||||||
height *= 2;
|
|
||||||
if (height > minHeight)
|
|
||||||
minHeight = height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,35 +81,35 @@ 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();
|
||||||
|
uint8_t height = surfaceElement->GetWaterHeight();
|
||||||
|
if (height != 0)
|
||||||
{
|
{
|
||||||
SurfaceElement* surfaceElement = tileElement->AsSurface();
|
height *= 2;
|
||||||
uint8_t height = surfaceElement->GetWaterHeight();
|
if (height > maxHeight)
|
||||||
if (height != 0)
|
continue;
|
||||||
{
|
height += 2;
|
||||||
height *= 2;
|
}
|
||||||
if (height > maxHeight)
|
else
|
||||||
continue;
|
{
|
||||||
height += 2;
|
height = surfaceElement->base_height + 2;
|
||||||
}
|
}
|
||||||
else
|
auto waterSetHeightAction = WaterSetHeightAction({ x, y }, height);
|
||||||
{
|
waterSetHeightAction.SetFlags(GetFlags());
|
||||||
height = surfaceElement->base_height + 2;
|
auto result = isExecuting ? GameActions::ExecuteNested(&waterSetHeightAction)
|
||||||
}
|
: GameActions::QueryNested(&waterSetHeightAction);
|
||||||
auto waterSetHeightAction = WaterSetHeightAction({ x, y }, height);
|
if (result->Error == GA_ERROR::OK)
|
||||||
waterSetHeightAction.SetFlags(GetFlags());
|
{
|
||||||
auto result = isExecuting ? GameActions::ExecuteNested(&waterSetHeightAction)
|
res->Cost += result->Cost;
|
||||||
: GameActions::QueryNested(&waterSetHeightAction);
|
hasChanged = true;
|
||||||
if (result->Error == GA_ERROR::OK)
|
}
|
||||||
{
|
else
|
||||||
res->Cost += result->Cost;
|
{
|
||||||
hasChanged = true;
|
result->ErrorTitle = STR_CANT_RAISE_WATER_LEVEL_HERE;
|
||||||
}
|
return result;
|
||||||
else
|
|
||||||
{
|
|
||||||
result->ErrorTitle = STR_CANT_RAISE_WATER_LEVEL_HERE;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,16 +133,16 @@ 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();
|
||||||
|
if (height != 0)
|
||||||
{
|
{
|
||||||
uint8_t height = tile_element->AsSurface()->GetWaterHeight();
|
height *= 2;
|
||||||
if (height != 0)
|
if (maxHeight > height)
|
||||||
{
|
{
|
||||||
height *= 2;
|
maxHeight = height;
|
||||||
if (maxHeight > height)
|
|
||||||
{
|
|
||||||
maxHeight = height;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user