1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 17:42:29 +01:00

Fix #9401, Fix #9387. Check for tile element before deref. (#9409)

This fixes two crashes that can occur when surface elements are deleted. For normal play you should never delete a surface element as the game expects there to be a surface element on all usable terrain.
This commit is contained in:
Duncan
2019-06-12 21:16:40 +01:00
committed by GitHub
parent 17cc6a862d
commit e5972f8a67

View File

@@ -515,7 +515,8 @@ static void viewport_surface_smoothen_edge(
static bool tile_is_inside_clip_view(const tile_descriptor& tile)
{
Guard::ArgumentNotNull(tile.tile_element);
if (tile.tile_element == nullptr)
return false;
if (tile.tile_element->base_height > gClipHeight)
return false;
@@ -584,7 +585,7 @@ static void viewport_surface_draw_tile_side_bottom(
neighbourCornerHeight1 = MINIMUM_LAND_HEIGHT / 2;
}
if (isWater)
if (isWater && neighbour.tile_element != nullptr)
{
uint8_t waterHeight = neighbour.tile_element->AsSurface()->GetWaterHeight();
if (waterHeight == height && !neighbourIsClippedAway)