Properly reset surface objects

This commit is contained in:
Michael Steenbeek 2018-09-17 13:07:25 +02:00
parent a7eb005501
commit 66f9e9d646
3 changed files with 13 additions and 6 deletions

View File

@ -565,26 +565,26 @@ static void viewport_surface_smoothen_edge(
return;
}
uint8_t waterHeight = 0, cl = 0;
uint8_t dh = 0, cl = 0;
switch (edge)
{
case EDGE_BOTTOMLEFT:
waterHeight = byte_97B524[byte_97B444[self.slope]];
dh = byte_97B524[byte_97B444[self.slope]];
cl = byte_97B54A[byte_97B444[neighbour.slope]];
break;
case EDGE_TOPLEFT:
waterHeight = byte_97B537[byte_97B444[self.slope]];
dh = byte_97B537[byte_97B444[self.slope]];
cl = byte_97B55D[byte_97B444[neighbour.slope]];
break;
case EDGE_BOTTOMRIGHT:
waterHeight = byte_97B55D[byte_97B444[self.slope]];
dh = byte_97B55D[byte_97B444[self.slope]];
cl = byte_97B537[byte_97B444[neighbour.slope]];
break;
case EDGE_TOPRIGHT:
waterHeight = byte_97B54A[byte_97B444[self.slope]];
dh = byte_97B54A[byte_97B444[self.slope]];
cl = byte_97B524[byte_97B444[neighbour.slope]];
break;
}
@ -592,7 +592,7 @@ static void viewport_surface_smoothen_edge(
if (self.terrain == neighbour.terrain)
{
// same tint
if (cl == waterHeight)
if (cl == dh)
return;
if (byte_97B83C[self.terrain] & FLAG_DONT_SMOOTHEN_SELF)

View File

@ -2326,15 +2326,18 @@ static void track_design_preview_clear_map()
for (int32_t i = 0; i < MAX_TILE_TILE_ELEMENT_POINTERS; i++)
{
rct_tile_element* tile_element = &gTileElements[i];
memset(tile_element, 0, sizeof(rct_tile_element));
tile_element->type = TILE_ELEMENT_TYPE_SURFACE;
tile_element->flags = TILE_ELEMENT_FLAG_LAST_TILE;
tile_element->base_height = 2;
tile_element->clearance_height = 0;
tile_element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT);
tile_element->AsSurface()->SetWaterHeight(0);
tile_element->AsSurface()->SetSurfaceStyle(TERRAIN_GRASS);
tile_element->AsSurface()->SetEdgeStyle(TERRAIN_EDGE_ROCK);
tile_element->AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0);
tile_element->AsSurface()->SetOwnership(OWNERSHIP_UNOWNED);
tile_element->AsSurface()->SetParkFences(0);
}
map_update_tile_pointers();
}

View File

@ -3749,6 +3749,7 @@ void map_extend_boundary_surface()
newTileElement->SetEdgeStyle(existingTileElement->GetEdgeStyle());
newTileElement->SetGrassLength(existingTileElement->GetGrassLength());
newTileElement->SetOwnership(OWNERSHIP_UNOWNED);
newTileElement->SetWaterHeight(existingTileElement->GetWaterHeight());
z = existingTileElement->base_height;
slope = existingTileElement->GetSlope() & TILE_ELEMENT_SLOPE_NW_SIDE_UP;
@ -3791,6 +3792,7 @@ void map_extend_boundary_surface()
newTileElement->SetEdgeStyle(existingTileElement->GetEdgeStyle());
newTileElement->SetGrassLength(existingTileElement->GetGrassLength());
newTileElement->SetOwnership(OWNERSHIP_UNOWNED);
newTileElement->SetWaterHeight(existingTileElement->GetWaterHeight());
z = existingTileElement->base_height;
slope = existingTileElement->GetSlope() & TILE_ELEMENT_SLOPE_NE_SIDE_UP;
@ -3841,6 +3843,8 @@ static void clear_element_at(int32_t x, int32_t y, rct_tile_element** elementPtr
element->AsSurface()->SetEdgeStyle(TERRAIN_EDGE_ROCK);
element->AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0);
element->AsSurface()->SetOwnership(OWNERSHIP_UNOWNED);
element->AsSurface()->SetParkFences(0);
element->AsSurface()->SetWaterHeight(0);
// Because this element is not completely removed, the pointer must be updated manually
// The rest of the elements are removed from the array, so the pointer doesn't need to be updated.
(*elementPtr)++;