Merge pull request #15490 from Broxzier/bugfix/invalid-clearance-surfaces

Fix: Surface slopes edited by TI have invalid clearance
This commit is contained in:
Michael Steenbeek 2021-10-15 19:55:50 +02:00 committed by GitHub
commit 0b6c6bb22a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 34 deletions

View File

@ -34,6 +34,7 @@
- Fix: [#15377] Entrance/exit ghost doesn't work on different stations without touching them first.
- Fix: [#15476] Crash when placing/clearing small scenery.
- Fix: [#15487] Map animations do not work correctly when loading an exported SV6 file in vanilla RCT2.
- Fix: [#15490] Tile inspector needlessly updates clearance height when changing surface slopes.
- Fix: [#15496] Crash in paint_swinging_inverter_ship_structure().
- Fix: [#15503] Freeze when doing specific coaster merges with block brakes.
- Fix: [#15514] Two different “quit to menu” menu items are available in track designer and track design manager.

View File

@ -587,49 +587,37 @@ namespace OpenRCT2::TileInspector
if (isExecuting)
{
const uint8_t originalSlope = surfaceElement->GetSlope();
const bool diagonal = (originalSlope & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) >> 4;
uint8_t newSlope = surfaceElement->GetSlope() ^ (1 << cornerIndex);
surfaceElement->SetSlope(newSlope);
if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP)
{
surfaceElement->clearance_height = surfaceElement->base_height + 2;
}
else
{
surfaceElement->clearance_height = surfaceElement->base_height;
}
// All corners are raised
if ((surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) == TILE_ELEMENT_SLOPE_ALL_CORNERS_UP)
if ((newSlope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) == TILE_ELEMENT_SLOPE_ALL_CORNERS_UP)
{
uint8_t slope = TILE_ELEMENT_SLOPE_FLAT;
if (diagonal)
newSlope = TILE_ELEMENT_SLOPE_FLAT;
if ((originalSlope & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) != 0)
{
switch (originalSlope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP)
{
case TILE_ELEMENT_SLOPE_S_CORNER_DN:
slope |= TILE_ELEMENT_SLOPE_N_CORNER_UP;
newSlope |= TILE_ELEMENT_SLOPE_N_CORNER_UP;
break;
case TILE_ELEMENT_SLOPE_W_CORNER_DN:
slope |= TILE_ELEMENT_SLOPE_E_CORNER_UP;
newSlope |= TILE_ELEMENT_SLOPE_E_CORNER_UP;
break;
case TILE_ELEMENT_SLOPE_N_CORNER_DN:
slope |= TILE_ELEMENT_SLOPE_S_CORNER_UP;
newSlope |= TILE_ELEMENT_SLOPE_S_CORNER_UP;
break;
case TILE_ELEMENT_SLOPE_E_CORNER_DN:
slope |= TILE_ELEMENT_SLOPE_W_CORNER_UP;
newSlope |= TILE_ELEMENT_SLOPE_W_CORNER_UP;
break;
}
}
surfaceElement->SetSlope(slope);
// Update base and clearance heights
surfaceElement->base_height += 2;
surfaceElement->clearance_height = surfaceElement->base_height + (diagonal ? 2 : 0);
surfaceElement->clearance_height = surfaceElement->base_height;
}
surfaceElement->SetSlope(newSlope);
map_invalidate_tile_full(loc);
if (auto* inspector = GetTileInspectorWithPos(loc); inspector != nullptr)
@ -653,18 +641,6 @@ namespace OpenRCT2::TileInspector
{
uint8_t newSlope = surfaceElement->GetSlope() ^ TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT;
surfaceElement->SetSlope(newSlope);
if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)
{
surfaceElement->clearance_height = surfaceElement->base_height + 4;
}
else if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP)
{
surfaceElement->clearance_height = surfaceElement->base_height + 2;
}
else
{
surfaceElement->clearance_height = surfaceElement->base_height;
}
map_invalidate_tile_full(loc);