diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index e6233cee0d..6fba36a48c 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -296,7 +296,8 @@ int32_t viewport_interaction_get_item_right(ScreenCoordsXY screenCoords, viewpor } else { - if (!gCheatsSandboxMode && !map_is_location_owned({ info->x, info->y, tileElement->base_height << 4 })) + // FIXME: Why does it *2 the value? + if (!gCheatsSandboxMode && !map_is_location_owned({ info->x, info->y, tileElement->GetBaseZ() * 2 })) { return info->type = VIEWPORT_INTERACTION_ITEM_NONE; } diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index c83ad51272..fe3c3ce23b 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -731,7 +731,7 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC { // Check for change if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) && gFootpathProvisionalPosition.x == mapCoord.x - && gFootpathProvisionalPosition.y == mapCoord.y && gFootpathProvisionalPosition.z / 8 == tileElement->base_height) + && gFootpathProvisionalPosition.y == mapCoord.y && gFootpathProvisionalPosition.z == tileElement->GetBaseZ()) { return; } @@ -771,15 +771,15 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC break; } } - uint8_t z = tileElement->base_height; + uint8_t z = tileElement->GetBaseZ(); if (slope & RAISE_FOOTPATH_FLAG) { slope &= ~RAISE_FOOTPATH_FLAG; - z += 2; + z += (2 * 8); } int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); - _window_footpath_cost = footpath_provisional_set(pathType, { mapCoord, z * 8 }, slope); + _window_footpath_cost = footpath_provisional_set(pathType, { mapCoord, z }, slope); window_invalidate_by_class(WC_FOOTPATH); } } @@ -815,20 +815,20 @@ static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY s gMapSelectArrowPosition.x = x; gMapSelectArrowPosition.y = y; - int32_t z = tileElement->base_height; + int32_t z = tileElement->GetBaseZ(); if (tileElement->GetType() == TILE_ELEMENT_TYPE_SURFACE) { uint8_t slope = tileElement->AsSurface()->GetSlope(); if (slope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) { - z += 2; + z += (2 * 8); } // Add 2 for a slope if (slope & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) - z += 2; // Add another 2 for a steep slope + z += (2 * 8); // Add another 2 for a steep slope } - gMapSelectArrowPosition.z = z << 3; + gMapSelectArrowPosition.z = z; map_invalidate_selection_rect(); } @@ -874,17 +874,17 @@ static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords) } break; } - z = tileElement->base_height; + z = tileElement->GetBaseZ(); if (currentType & RAISE_FOOTPATH_FLAG) { currentType &= ~RAISE_FOOTPATH_FLAG; - z += 2; + z += (2 * 8); } selectedType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); // Try and place path gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE; - auto footpathPlaceAction = FootpathPlaceAction({ mapCoord.x, mapCoord.y, z * 8 }, currentType, selectedType); + auto footpathPlaceAction = FootpathPlaceAction({ mapCoord.x, mapCoord.y, z }, currentType, selectedType); footpathPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { if (result->Error == GA_ERROR::OK) { @@ -922,28 +922,28 @@ static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords) // If we start the path on a slope, the arrow is slightly raised, so we // expect the path to be slightly raised as well. uint8_t slope = tileElement->AsSurface()->GetSlope(); - z = tileElement->base_height; + z = tileElement->GetBaseZ(); if (slope & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) { // Steep diagonal slope - z += 4; + z += (4 * 8); } else if (slope & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP) { // Normal slope - z += 2; + z += (2 * 8); } } else { - z = tileElement->base_height; + z = tileElement->GetBaseZ(); if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH) { if (tileElement->AsPath()->IsSloped()) { if (direction == (tileElement->AsPath()->GetSlopeDirection())) { - z += 2; + z += (2 * 8); } } } @@ -952,7 +952,7 @@ static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords) tool_cancel(); gFootpathConstructFromPosition.x = x; gFootpathConstructFromPosition.y = y; - gFootpathConstructFromPosition.z = z * 8; + gFootpathConstructFromPosition.z = z; gFootpathConstructDirection = direction; gFootpathProvisionalFlags = 0; _window_footpath_provisional_path_arrow_timer = 0; @@ -1016,14 +1016,14 @@ static void window_footpath_construct() */ static void footpath_remove_tile_element(TileElement* tileElement) { - auto z = tileElement->base_height; + auto z = tileElement->GetBaseZ(); if (tileElement->AsPath()->IsSloped()) { uint8_t slopeDirection = tileElement->AsPath()->GetSlopeDirection(); slopeDirection = direction_reverse(slopeDirection); if (slopeDirection == gFootpathConstructDirection) { - z += 2; + z += (2 * 8); } } @@ -1054,7 +1054,7 @@ static void footpath_remove_tile_element(TileElement* tileElement) edge = direction_reverse(edge); gFootpathConstructFromPosition.x -= CoordsDirectionDelta[edge].x; gFootpathConstructFromPosition.y -= CoordsDirectionDelta[edge].y; - gFootpathConstructFromPosition.z = z * 8; + gFootpathConstructFromPosition.z = z; gFootpathConstructDirection = edge; gFootpathConstructValidDirections = 255; } diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 67c0ce1448..af647d8c90 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2459,8 +2459,8 @@ static void sub_6CBCE2( _tempTrackTileElement.AsTrack()->SetHasChain((liftHillAndInvertedState & CONSTRUCTION_LIFT_HILL_SELECTED) != 0); _tempTrackTileElement.SetOccupiedQuadrants(quarterTile.GetBaseQuarterOccupied()); _tempTrackTileElement.SetLastForTile(true); - _tempTrackTileElement.base_height = baseZ / 8; - _tempTrackTileElement.clearance_height = clearanceZ / 8; + _tempTrackTileElement.SetBaseZ(baseZ); + _tempTrackTileElement.SetClearanceZ(clearanceZ); _tempTrackTileElement.AsTrack()->SetTrackType(trackType); _tempTrackTileElement.AsTrack()->SetSequenceIndex(trackBlock->index); _tempTrackTileElement.AsTrack()->SetHasCableLift(false); diff --git a/src/openrct2/actions/BannerPlaceAction.hpp b/src/openrct2/actions/BannerPlaceAction.hpp index 402ad6d5fb..d085e0091b 100644 --- a/src/openrct2/actions/BannerPlaceAction.hpp +++ b/src/openrct2/actions/BannerPlaceAction.hpp @@ -184,7 +184,7 @@ private: auto pathElement = tileElement->AsPath(); - if (pathElement->base_height != _loc.z / 8 && pathElement->base_height != _loc.z / 8 - 2) + if (pathElement->GetBaseZ() != _loc.z && pathElement->GetBaseZ() != _loc.z - (2 * 8)) continue; if (!(pathElement->GetEdges() & (1 << _loc.direction))) diff --git a/src/openrct2/actions/BannerRemoveAction.hpp b/src/openrct2/actions/BannerRemoveAction.hpp index a5ee7251fe..69c97425c1 100644 --- a/src/openrct2/actions/BannerRemoveAction.hpp +++ b/src/openrct2/actions/BannerRemoveAction.hpp @@ -138,7 +138,7 @@ private: break; if (tileElement->GetType() != TILE_ELEMENT_TYPE_BANNER) continue; - if (tileElement->base_height != _loc.z / 8) + if (tileElement->GetBaseZ() != _loc.z) continue; if (tileElement->IsGhost() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST)) continue; diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.hpp b/src/openrct2/actions/LargeSceneryRemoveAction.hpp index 724c75620c..076edd7acd 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.hpp +++ b/src/openrct2/actions/LargeSceneryRemoveAction.hpp @@ -178,7 +178,7 @@ public: if (sceneryElement->AsLargeScenery()->GetSequenceIndex() != i) continue; - if (sceneryElement->base_height != currentTile.z / 8) + if (sceneryElement->GetBaseZ() != currentTile.z) continue; // If we are removing ghost elements @@ -216,7 +216,7 @@ private: if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY) continue; - if (tileElement->base_height != _loc.z / 8) + if (tileElement->GetBaseZ() != _loc.z) continue; if (tileElement->AsLargeScenery()->GetSequenceIndex() != _tileIndex) diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index a3cacaa06e..25dbc9cc9a 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -744,8 +744,8 @@ private: if (surfaceElement->GetOwnership() & OWNERSHIP_OWNED) continue; - int32_t base_z = surfaceElement->base_height; - int32_t destOwnership = check_max_allowable_land_rights_for_tile({ coords, base_z << 3 }); + int32_t base_z = surfaceElement->GetBaseZ(); + int32_t destOwnership = check_max_allowable_land_rights_for_tile({ coords, base_z }); // only own tiles that were not set to 0 if (destOwnership != OWNERSHIP_UNOWNED) diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.hpp b/src/openrct2/actions/SmallSceneryPlaceAction.hpp index de4f8eb9c9..59a7deda93 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.hpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.hpp @@ -441,7 +441,7 @@ public: sceneryElement->SetAge(0); sceneryElement->SetPrimaryColour(_primaryColour); sceneryElement->SetSecondaryColour(_secondaryColour); - sceneryElement->clearance_height = sceneryElement->base_height + ((sceneryEntry->small_scenery.height + 7) / 8); + sceneryElement->SetClearanceZ(sceneryElement->GetBaseZ() + sceneryEntry->small_scenery.height + 7); if (supportsRequired) { diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.hpp b/src/openrct2/actions/SmallSceneryRemoveAction.hpp index b4a82942b9..d459f23faf 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.hpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.hpp @@ -145,7 +145,7 @@ private: continue; if ((tileElement->AsSmallScenery()->GetSceneryQuadrant()) != _quadrant) continue; - if (tileElement->base_height != _loc.z / 8) + if (tileElement->GetBaseZ() != _loc.z) continue; if (tileElement->AsSmallScenery()->GetEntryIndex() != _sceneryType) continue; diff --git a/src/openrct2/actions/TrackRemoveAction.hpp b/src/openrct2/actions/TrackRemoveAction.hpp index e32c9fce56..9e6155e21e 100644 --- a/src/openrct2/actions/TrackRemoveAction.hpp +++ b/src/openrct2/actions/TrackRemoveAction.hpp @@ -163,7 +163,7 @@ public: if (tileElement == nullptr) break; - if (tileElement->base_height != mapLoc.z / 8) + if (tileElement->GetBaseZ() != mapLoc.z) continue; if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) @@ -353,7 +353,7 @@ public: if (tileElement == nullptr) break; - if (tileElement->base_height != mapLoc.z / 8) + if (tileElement->GetBaseZ() != mapLoc.z) continue; if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) diff --git a/src/openrct2/actions/WallPlaceAction.hpp b/src/openrct2/actions/WallPlaceAction.hpp index 401614a749..5869065581 100644 --- a/src/openrct2/actions/WallPlaceAction.hpp +++ b/src/openrct2/actions/WallPlaceAction.hpp @@ -176,7 +176,7 @@ public: } } - if (targetHeight / 8 < surfaceElement->base_height && !gCheatsDisableClearanceChecks) + if (targetHeight < surfaceElement->GetBaseZ() && !gCheatsDisableClearanceChecks) { return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); } diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index 2311bb88a0..c5b00532a2 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -104,7 +104,7 @@ private: { if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) continue; - if (tileElement->base_height != location.z / 8) + if (tileElement->GetBaseZ() != location.z) continue; if (tileElement->GetDirection() != location.direction) continue; diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index fb33deb447..32ef8dddea 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -317,14 +317,14 @@ void lightfx_prepare_light_list() } int32_t minDist = 0; - int32_t baseHeight = -999; + int32_t baseHeight = (-999) * 8; if (interactionType != VIEWPORT_INTERACTION_ITEM_SPRITE && tileElement) { - baseHeight = tileElement->base_height; + baseHeight = tileElement->GetBaseZ(); } - minDist = ((baseHeight * 8) - coord_3d.z) / 2; + minDist = (baseHeight - coord_3d.z) / 2; int32_t deltaX = mapCoord.x - coord_3d.x; int32_t deltaY = mapCoord.y - coord_3d.y; diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 0005f1f6fa..ae7ea29037 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -860,12 +860,11 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile auto surface = map_get_surface_element_at(CoordsXY{ session->MapPosition.x, session->MapPosition.y }); - uint16_t bl = height / 8; if (surface == nullptr) { hasSupports = true; } - else if (surface->base_height != bl) + else if (surface->GetBaseZ() != height) { hasSupports = true; } diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index 6b863e976b..91bc54b046 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -960,10 +960,10 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c const uint32_t surfaceSlope = viewport_surface_paint_setup_get_relative_slope( reinterpret_cast(surfaceElement), rotation); - const uint8_t baseHeight = surfaceElement->base_height / 2; + const uint8_t baseHeight = surfaceElement->GetBaseZ() / 16; const corner_height& ch = corner_heights[surfaceSlope]; - descriptor.tile_coords = { position.x / 32, position.y / 32 }; + descriptor.tile_coords = TileCoordsXY{ position }; descriptor.tile_element = reinterpret_cast(surfaceElement); descriptor.terrain = surfaceElement->GetSurfaceStyle(); descriptor.slope = surfaceSlope; diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index 815924c7c7..48611e5b5a 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -263,7 +263,7 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y) TileElement* tile_element_sub_iterator = tile_element; while (!(tile_element_sub_iterator++)->IsLastForTile()) { - if (tile_element_sub_iterator->base_height != tile_element->base_height) + if (tile_element_sub_iterator->GetBaseZ() != tile_element->GetBaseZ()) { break; } diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 275403cfa8..9478551cf0 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -4181,7 +4181,7 @@ void Guest::UpdateRideLeaveVehicle() { if (inner_map->GetType() != TILE_ELEMENT_TYPE_TRACK) continue; - if (inner_map->base_height == vehicle->track_z / 8) + if (inner_map->GetBaseZ() == vehicle->track_z) break; } @@ -6893,7 +6893,7 @@ void Guest::UpdateSpriteType() { if (tileElement == nullptr) break; - if ((z / 8) < tileElement->base_height) + if (z < tileElement->GetBaseZ()) break; if (tileElement->IsLastForTile()) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 9e991ecace..503c9f987a 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2040,8 +2040,8 @@ private: dst->ClearAs(tileElementType); dst->SetDirection(src->GetDirection()); dst->flags = src->flags; - dst->base_height = src->base_height / 2; - dst->clearance_height = src->clearance_height / 2; + dst->SetBaseZ(src->base_height * 4); + dst->SetClearanceZ(src->clearance_height * 4); switch (tileElementType) { diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 0d4d858e0c..94f3321a2c 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -6961,7 +6961,6 @@ void sub_6CB945(Ride* ride) while ((++trackBlock)->index != 0xFF) { CoordsXYZ blockLocation = location + CoordsXYZ{ CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(direction), 0 }; - auto blockTileHeight = TileCoordsXYZ(blockLocation).z; bool trackFound = false; tileElement = map_get_first_element_at(blockLocation); @@ -6969,7 +6968,7 @@ void sub_6CB945(Ride* ride) break; do { - if (blockTileHeight != tileElement->base_height) + if (blockLocation.z != tileElement->GetBaseZ()) continue; if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) continue; diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index f28d26291f..10e5be6ab2 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -133,7 +133,7 @@ void maze_entrance_hedge_replacement(int32_t x, int32_t y, TileElement* tileElem int32_t direction = tileElement->GetDirection(); x += CoordsDirectionDelta[direction].x; y += CoordsDirectionDelta[direction].y; - int32_t z = tileElement->base_height; + int32_t z = tileElement->GetBaseZ(); ride_id_t rideIndex = tileElement->AsEntrance()->GetRideIndex(); tileElement = map_get_first_element_at({ x, y }); @@ -145,7 +145,7 @@ void maze_entrance_hedge_replacement(int32_t x, int32_t y, TileElement* tileElem continue; if (tileElement->AsTrack()->GetRideIndex() != rideIndex) continue; - if (tileElement->base_height != z) + if (tileElement->GetBaseZ() != z) continue; if (tileElement->AsTrack()->GetTrackType() != TRACK_ELEM_MAZE) continue; @@ -171,7 +171,7 @@ void maze_entrance_hedge_removal(int32_t x, int32_t y, TileElement* tileElement) int32_t direction = tileElement->GetDirection(); x += CoordsDirectionDelta[direction].x; y += CoordsDirectionDelta[direction].y; - int32_t z = tileElement->base_height; + int32_t z = tileElement->GetBaseZ(); ride_id_t rideIndex = tileElement->AsEntrance()->GetRideIndex(); tileElement = map_get_first_element_at({ x, y }); @@ -183,7 +183,7 @@ void maze_entrance_hedge_removal(int32_t x, int32_t y, TileElement* tileElement) continue; if (tileElement->AsTrack()->GetRideIndex() != rideIndex) continue; - if (tileElement->base_height != z) + if (tileElement->GetBaseZ() != z) continue; if (tileElement->AsTrack()->GetTrackType() != TRACK_ELEM_MAZE) continue; diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index 1da21deaaf..ff705a92b2 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -243,7 +243,7 @@ bool JumpingFountain::IsJumpingFountain(const int32_t newType, const CoordsXYZ n { if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) continue; - if (tileElement->base_height != newLoc.z / 8) + if (tileElement->GetBaseZ() != newLoc.z) continue; if (tileElement->AsPath()->AdditionIsGhost()) continue; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 7aed934a0a..a9ba97a822 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -706,7 +706,7 @@ bool map_is_location_owned(const CoordsXYZ& loc) if (surfaceElement->GetOwnership() & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) { - if (loc.z / 8 < surfaceElement->base_height || loc.z / 8 - 2 > surfaceElement->base_height) + if (loc.z < surfaceElement->GetBaseZ() || loc.z - (2 * 8) > surfaceElement->GetBaseZ()) return true; } } @@ -2212,7 +2212,7 @@ TrackElement* map_get_track_element_at_of_type(CoordsXYZD location, int32_t trac auto trackElement = tileElement->AsTrack(); if (trackElement != nullptr) { - if (trackElement->base_height != location.z / 8) + if (trackElement->GetBaseZ() != location.z) continue; if (trackElement->GetDirection() != location.direction) continue; @@ -2235,7 +2235,7 @@ TrackElement* map_get_track_element_at_of_type_seq(CoordsXYZD location, int32_t auto trackElement = tileElement->AsTrack(); if (trackElement != nullptr) { - if (trackElement->base_height != location.z / 8) + if (trackElement->GetBaseZ() != location.z) continue; if (trackElement->GetDirection() != location.direction) continue; diff --git a/src/openrct2/world/Surface.cpp b/src/openrct2/world/Surface.cpp index 4fd14ceb19..cd667c4ff9 100644 --- a/src/openrct2/world/Surface.cpp +++ b/src/openrct2/world/Surface.cpp @@ -121,10 +121,10 @@ void SurfaceElement::UpdateGrassLength(CoordsXY coords) // Grass can't grow any further than CLUMPS_2 but this code also cuts grass // if there is an object placed on top of it. - int32_t z0 = base_height; - int32_t z1 = base_height + 2; + int32_t zLow = GetBaseZ(); + int32_t zHigh = GetBaseZ() + (2 * 8); if (Slope & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) - z1 += 2; + zHigh += (2 * 8); // Check objects above grass TileElement* tileElementAbove = (TileElement*)this; @@ -166,9 +166,9 @@ void SurfaceElement::UpdateGrassLength(CoordsXY coords) // Grass should not be affected by ghost elements. if (tileElementAbove->IsGhost()) continue; - if (z0 >= tileElementAbove->clearance_height) + if (zLow >= tileElementAbove->GetClearanceZ()) continue; - if (z1 < tileElementAbove->base_height) + if (zHigh < tileElementAbove->GetBaseZ()) continue; if (grassLengthTmp != GRASS_LENGTH_CLEAR_0) diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp index cdb749a2c6..db1cc26f37 100644 --- a/src/openrct2/world/TileElement.cpp +++ b/src/openrct2/world/TileElement.cpp @@ -230,7 +230,17 @@ int32_t TileElementBase::GetBaseZ() const return base_height * 8; } +void TileElementBase::SetBaseZ(int32_t newZ) +{ + base_height = (newZ / 8); +} + int32_t TileElementBase::GetClearanceZ() const { return clearance_height * 8; } + +void TileElementBase::SetClearanceZ(int32_t newZ) +{ + clearance_height = (newZ / 8); +} diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 917608a35d..b6362668b5 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -79,7 +79,9 @@ struct TileElementBase uint8_t GetOccupiedQuadrants() const; void SetOccupiedQuadrants(uint8_t quadrants); int32_t GetBaseZ() const; + void SetBaseZ(int32_t newZ); int32_t GetClearanceZ() const; + void SetClearanceZ(int32_t newZ); }; /** diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 6722d41011..13712782e9 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -794,7 +794,7 @@ GameActionResult::Ptr tile_inspector_track_base_height_offset( if (tileElement == nullptr) break; - if (tileElement->base_height != elemZ / 8) + if (tileElement->GetBaseZ() != elemZ) continue; if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) @@ -901,7 +901,7 @@ GameActionResult::Ptr tile_inspector_track_set_chain( if (tileElement == nullptr) break; - if (tileElement->base_height != elemZ / 8) + if (tileElement->GetBaseZ() != elemZ) continue; if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK) diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index 656f989d9c..c052f5d886 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -469,7 +469,17 @@ int32_t TileElementBase::GetBaseZ() const return base_height * 8; } +void TileElementBase::SetBaseZ(int32_t newZ) +{ + base_height = (newZ / 8); +} + int32_t TileElementBase::GetClearanceZ() const { return clearance_height * 8; } + +void TileElementBase::SetClearanceZ(int32_t newZ) +{ + clearance_height = (newZ / 8); +}