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)
|
||||
{
|
||||
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();
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
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();
|
||||
uint8_t height = surfaceElement->base_height;
|
||||
|
||||
if (height <= minHeight)
|
||||
{
|
||||
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)
|
||||
{
|
||||
res->Cost += result->Cost;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->ErrorTitle = STR_CANT_RAISE_LAND_HERE;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
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();
|
||||
uint8_t height = surfaceElement->GetWaterHeight();
|
||||
if (height != 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
res->Cost += result->Cost;
|
||||
hasChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result->ErrorTitle = STR_CANT_LOWER_WATER_LEVEL_HERE;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
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();
|
||||
if (height != 0)
|
||||
{
|
||||
height *= 2;
|
||||
if (height > minHeight)
|
||||
minHeight = height;
|
||||
}
|
||||
minHeight = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,35 +81,35 @@ private:
|
||||
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 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();
|
||||
uint8_t height = surfaceElement->GetWaterHeight();
|
||||
if (height != 0)
|
||||
{
|
||||
height *= 2;
|
||||
if (height > maxHeight)
|
||||
continue;
|
||||
height += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
height = surfaceElement->base_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_RAISE_WATER_LEVEL_HERE;
|
||||
return result;
|
||||
}
|
||||
height *= 2;
|
||||
if (height > maxHeight)
|
||||
continue;
|
||||
height += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
height = surfaceElement->base_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_RAISE_WATER_LEVEL_HERE;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,16 +133,16 @@ private:
|
||||
for (int32_t x = _range.GetLeft(); x <= _range.GetRight(); x += 32)
|
||||
{
|
||||
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();
|
||||
if (height != 0)
|
||||
height *= 2;
|
||||
if (maxHeight > height)
|
||||
{
|
||||
height *= 2;
|
||||
if (maxHeight > height)
|
||||
{
|
||||
maxHeight = height;
|
||||
}
|
||||
maxHeight = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user