diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 95e8eeffab..f0eee8cfe6 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -2093,7 +2093,64 @@ void top_toolbar_tool_update_scenery(sint16 x, sint16 y){ RCT2_GLOBAL(0x00F64EB4, money32) = cost; break; case 3: - //6e29f2 + scenery = g_largeSceneryEntries[selected_scenery]; + rct_xy16* selectedTile = gMapSelectionTiles; + + for (rct_large_scenery_tile* tile = scenery->large_scenery.tiles; tile->x_offset != (sint16)0xFFFF; tile++){ + rct_xy16 tileLocation = { + .x = tile->x_offset, + .y = tile->y_offset + }; + + rotate_map_coordinates(&tileLocation.x, &tileLocation.y, (parameter1 >> 8) & 0xFF); + + tileLocation.x += mapTile.x; + tileLocation.y += mapTile.y; + + selectedTile->x = tileLocation.x; + selectedTile->y = tileLocation.y; + selectedTile++; + } + selectedTile->x = 0xFFFF; + + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 1); + map_invalidate_map_selection_tiles(); + + // If no change in ghost placement + if ((RCT2_GLOBAL(0x00F64F0D, uint8) & (1 << 3)) && + mapTile.x == RCT2_GLOBAL(0x00F64EC4, sint16) && + mapTile.y == RCT2_GLOBAL(0x00F64EC6, sint16) && + RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) == RCT2_GLOBAL(0x00F64F0A, sint16) && + (parameter3 & 0xFFFF) == RCT2_GLOBAL(0x00F64EDA, uint16)){ + return; + } + + scenery_remove_ghost_tool_placement(); + + RCT2_GLOBAL(0x00F64EDA, uint16) = (parameter3 & 0xFFFF); + RCT2_GLOBAL(0x00F64F0A, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16); + + bl = 1; + if (RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) != 0 && + RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_TOOL_SHIFT_PRESSED, uint8) != 0){ + bl = 20; + } + + cost = 0; + for (; bl != 0; bl--){ + cost = sub_6E24F6( + mapTile, + parameter1, + parameter2, + parameter3, + selected_tab); + + if (cost != MONEY32_UNDEFINED) + break; + RCT2_GLOBAL(RCT2_ADDRESS_SCENERY_Z_COORDINATE, sint16) += 8; + } + + RCT2_GLOBAL(0x00F64EB4, money32) = cost; break; case 4: RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= (1 << 0); diff --git a/src/world/map.h b/src/world/map.h index f978ed971b..7d9337fa12 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -279,6 +279,7 @@ rct_map_element *map_element_insert(int x, int y, int z, int flags); int map_can_construct_with_clear_at(int x, int y, int zLow, int zHigh, void *clearFunc, uint8 bl); int map_can_construct_at(int x, int y, int zLow, int zHigh, uint8 bl); int sub_6BA278(int ebx); +void rotate_map_coordinates(sint16* x, sint16* y, uint8 rotation); money32 map_clear_scenery(int x0, int y0, int x1, int y1, int flags); money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags); money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags);