diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 4ebc4a0d39..6c3ccaf0be 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #define WW 113 #define WH 96 @@ -499,18 +500,23 @@ static void window_sign_small_mouseup(rct_window *w, rct_widgetindex widgetIndex window_close(w); break; case WIDX_SIGN_DEMOLISH: - while (1){ - if (tile_element->GetType() == TILE_ELEMENT_TYPE_WALL) { - rct_scenery_entry* scenery_entry = get_wall_entry(tile_element->properties.wall.type); - if (scenery_entry->wall.scrolling_mode != 0xFF){ - if (tile_element->properties.wall.banner_index == w->number) - break; + { + while (1) + { + if (tile_element_get_type(tile_element) == TILE_ELEMENT_TYPE_WALL) + { + rct_scenery_entry* scenery_entry = get_wall_entry(tile_element->properties.wall.type); + if (scenery_entry->wall.scrolling_mode != 0xFF) + { + if (tile_element->properties.wall.banner_index == w->number) + break; + } } + tile_element++; } - tile_element++; + auto wallRemoveAction = WallRemoveAction(x, y, tile_element->base_height, tile_element_get_direction(tile_element)); + GameActions::Execute(&wallRemoveAction); } - gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - wall_remove(x, y, tile_element->base_height, tile_element_get_direction(tile_element), GAME_COMMAND_FLAG_APPLY); break; case WIDX_SIGN_TEXT: if (banner->flags & BANNER_FLAG_LINKED_TO_RIDE){ diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index 5d6e3efddc..d02cba5f11 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -347,28 +347,6 @@ #pragma endregion #pragma region RemoveWall - money32 wall_remove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags) - { - auto gameAction = WallRemoveAction(x, y, baseHeight, direction); - gameAction.SetFlags(flags); - - // FIXME: The callee should probably use the game action directly - // once everything is compiled as cpp. - money32 cost = 0; - if (flags & GAME_COMMAND_FLAG_APPLY) - { - auto res = GameActions::Execute(&gameAction); - cost = res->Cost; - } - else - { - auto res = GameActions::Query(&gameAction); - cost = res->Cost; - } - - return cost; - } - /** * * rct2: 0x006E5597 diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index 27d889a9fc..87ce9f261b 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -19,6 +19,7 @@ #include "../OpenRCT2.h" #include "../core/MemoryStream.h" #include "../localisation/StringIds.h" +#include "../management/Finance.h" #include "GameAction.h" #include "../Cheats.h" diff --git a/src/openrct2/interface/ViewportInteraction.cpp b/src/openrct2/interface/ViewportInteraction.cpp index 4066f63323..aba520d586 100644 --- a/src/openrct2/interface/ViewportInteraction.cpp +++ b/src/openrct2/interface/ViewportInteraction.cpp @@ -37,6 +37,7 @@ #include "Viewport.h" #include "Window_internal.h" #include "../Context.h" +#include "../actions/WallRemoveAction.hpp" static void viewport_interaction_remove_scenery(rct_tile_element *tileElement, sint32 x, sint32 y); static void viewport_interaction_remove_footpath(rct_tile_element *tileElement, sint32 x, sint32 y); @@ -511,11 +512,14 @@ void viewport_interaction_remove_park_entrance(rct_tile_element *tileElement, si static void viewport_interaction_remove_park_wall(rct_tile_element *tileElement, sint32 x, sint32 y) { rct_scenery_entry *sceneryEntry = get_wall_entry(tileElement->properties.wall.type); - if (sceneryEntry->wall.scrolling_mode != 0xFF){ + if (sceneryEntry->wall.scrolling_mode != 0xFF) + { context_open_detail_window(WD_SIGN_SMALL, tileElement->properties.wall.banner_index); - } else { - gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - wall_remove(x, y, tileElement->base_height, tile_element_get_direction(tileElement), GAME_COMMAND_FLAG_APPLY); + } + else + { + auto wallRemoveAction = WallRemoveAction(x, y, tileElement->base_height, tile_element_get_direction(tileElement)); + GameActions::Execute(&wallRemoveAction); } } diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index b7d2dde207..440f25c483 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -45,6 +45,7 @@ #include "../world/SmallScenery.h" #include "../world/Surface.h" #include "../world/Wall.h" +#include "../actions/WallRemoveAction.hpp" struct map_backup { @@ -859,8 +860,16 @@ track_design_place_scenery(rct_td6_scenery_element * scenery_start, sint32 origi 0); break; case OBJECT_TYPE_WALLS: - z = (scenery->z * 8 + originZ) / 8; - wall_remove(mapCoord.x, mapCoord.y, z, (rotation + scenery->flags) & TILE_ELEMENT_DIRECTION_MASK, flags); + { + z = (scenery->z * 8 + originZ) / 8; + + uint8_t direction = (rotation + scenery->flags) & TILE_ELEMENT_DIRECTION_MASK; + + auto wallRemoveAction = WallRemoveAction(mapCoord.x, mapCoord.y, z, direction); + wallRemoveAction.SetFlags(flags); + + GameActions::Execute(&wallRemoveAction); + } break; case OBJECT_TYPE_PATHS: z = (scenery->z * 8 + originZ) / 8; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 1eee6cfbdb..c7a893643a 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -3761,8 +3761,10 @@ static void clear_element_at(sint32 x, sint32 y, rct_tile_element **elementPtr) viewport_interaction_remove_park_entrance(element, x, y); break; case TILE_ELEMENT_TYPE_WALL: - gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - wall_remove(x, y, tile_element_get_direction(element), element->base_height, GAME_COMMAND_FLAG_APPLY); + { + auto wallRemoveAction = WallRemoveAction(x, y, element->base_height, tile_element_get_direction(element)); + GameActions::Execute(&wallRemoveAction); + } break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: gGameCommandErrorTitle = STR_CANT_REMOVE_THIS;