diff --git a/src/openrct2/paint/tile_element/TileElement.cpp b/src/openrct2/paint/tile_element/TileElement.cpp index c1cb282ae9..5ead360142 100644 --- a/src/openrct2/paint/tile_element/TileElement.cpp +++ b/src/openrct2/paint/tile_element/TileElement.cpp @@ -152,6 +152,11 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y) rct_tile_element* tile_element = map_get_first_element_at(x >> 5, y >> 5); uint8 rotation = get_current_rotation(); + bool partOfVirtualFloor = false; +#ifndef __TESTPAINT__ + partOfVirtualFloor = map_tile_is_part_of_virtual_floor(session->MapPosition.x, session->MapPosition.y); +#endif // __TESTPAINT__ + /* Check if the first (lowest) tile_element is below the clip * height. */ if ((gCurrentViewportFlags & VIEWPORT_FLAG_PAINT_CLIP_TO_HEIGHT) && (tile_element->base_height > gClipHeight)) { @@ -222,6 +227,12 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y) max_height *= 8; + if (partOfVirtualFloor) + { + // We must pretend this tile is at least as tall as the virtual floor + max_height = Math::Max(max_height, gMapVirtualFloorHeight); + } + dx -= max_height + 32; element = tile_element;//pop tile_element @@ -317,7 +328,10 @@ static void sub_68B3FB(paint_session * session, sint32 x, sint32 y) session->MapPosition = dword_9DE574; } while (!tile_element_is_last_for_tile(tile_element++)); - virtual_floor_paint(session); + if (partOfVirtualFloor) + { + virtual_floor_paint(session); + } if (!gShowSupportSegmentHeights) { return; diff --git a/src/openrct2/paint/tile_element/virtual_floor.c b/src/openrct2/paint/tile_element/virtual_floor.c index 20183e22c2..2b7c297c19 100644 --- a/src/openrct2/paint/tile_element/virtual_floor.c +++ b/src/openrct2/paint/tile_element/virtual_floor.c @@ -113,47 +113,8 @@ static void virtual_floor_get_tile_properties(sint16 x, sint16 y, sint16 height, void virtual_floor_paint(paint_session * session) { - // We only show when the placement modifier keys are active - if (!input_test_place_object_modifier(PLACE_OBJECT_MODIFIER_COPY_Z | PLACE_OBJECT_MODIFIER_SHIFT_Z)) - { - return; - } - uint8 direction = get_current_rotation(); - bool show = false; - - // Check if map selection (usually single tiles) are enabled - // and if the current tile is near or on them - if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) && - session->MapPosition.x >= gMapSelectPositionA.x - gMapVirtualFloorBaseSize && - session->MapPosition.y >= gMapSelectPositionA.y - gMapVirtualFloorBaseSize && - session->MapPosition.x <= gMapSelectPositionB.x + gMapVirtualFloorBaseSize && - session->MapPosition.y <= gMapSelectPositionB.y + gMapVirtualFloorBaseSize) - { - show = true; - } - else if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) - { - // Check if we are anywhere near the selection tiles (larger scenery / rides) - for (LocationXY16 * tile = gMapSelectionTiles; tile->x != -1; tile++) - { - if (session->MapPosition.x >= tile->x - gMapVirtualFloorBaseSize && - session->MapPosition.y >= tile->y - gMapVirtualFloorBaseSize && - session->MapPosition.x <= tile->x + gMapVirtualFloorBaseSize && - session->MapPosition.y <= tile->y + gMapVirtualFloorBaseSize) - { - show = true; - break; - } - } - } - - if (!show) - { - return; - } - // This is a virtual floor, so no interactions session->InteractionType = VIEWPORT_INTERACTION_ITEM_NONE; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 3a43a003ac..67edba692c 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -4757,3 +4757,39 @@ void map_invalidate_virtual_floor_tiles() { // TODO: invalidate tiles covered by the current virtual floor } + +bool map_tile_is_part_of_virtual_floor(sint16 x, sint16 y) +{ + // We only show when the placement modifier keys are active + if (!input_test_place_object_modifier(PLACE_OBJECT_MODIFIER_COPY_Z | PLACE_OBJECT_MODIFIER_SHIFT_Z)) + { + return false; + } + + // Check if map selection (usually single tiles) are enabled + // and if the current tile is near or on them + if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) && + x >= gMapSelectPositionA.x - gMapVirtualFloorBaseSize && + y >= gMapSelectPositionA.y - gMapVirtualFloorBaseSize && + x <= gMapSelectPositionB.x + gMapVirtualFloorBaseSize && + y <= gMapSelectPositionB.y + gMapVirtualFloorBaseSize) + { + return true; + } + else if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) + { + // Check if we are anywhere near the selection tiles (larger scenery / rides) + for (LocationXY16 * tile = gMapSelectionTiles; tile->x != -1; tile++) + { + if (x >= tile->x - gMapVirtualFloorBaseSize && + y >= tile->y - gMapVirtualFloorBaseSize && + x <= tile->x + gMapVirtualFloorBaseSize && + y <= tile->y + gMapVirtualFloorBaseSize) + { + return true; + } + } + } + + return false; +} diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index e66e3d81a1..7c156e903e 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -462,6 +462,7 @@ bool tile_element_check_address(const rct_tile_element * const element); void map_set_virtual_floor_height(sint16 height); void map_remove_virtual_floor(); void map_invalidate_virtual_floor_tiles(); +bool map_tile_is_part_of_virtual_floor(sint16 x, sint16 y); typedef sint32 (CLEAR_FUNC)(rct_tile_element** tile_element, sint32 x, sint32 y, uint8 flags, money32* price); sint32 map_place_non_scenery_clear_func(rct_tile_element** tile_element, sint32 x, sint32 y, uint8 flags, money32* price);