From b34b09c6bb95a28d1e3bdf1f33f884ca3ba5c073 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 22 Dec 2018 18:11:08 +0100 Subject: [PATCH 1/6] Implement SceneryRemoveSmallAction. --- .../interface/ViewportInteraction.cpp | 10 +- src/openrct2/Game.cpp | 2 +- .../actions/GameActionRegistration.cpp | 2 + .../actions/SceneryRemoveSmallAction.hpp | 168 ++++++++++++++++++ src/openrct2/ride/TrackDesign.cpp | 9 +- src/openrct2/world/Map.cpp | 17 +- src/openrct2/world/Map.h | 2 - src/openrct2/world/Scenery.cpp | 9 +- src/openrct2/world/SmallScenery.cpp | 100 ----------- 9 files changed, 197 insertions(+), 122 deletions(-) create mode 100644 src/openrct2/actions/SceneryRemoveSmallAction.hpp diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 5402b6fa34..32971b1163 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -465,10 +466,11 @@ int32_t viewport_interaction_right_click(int32_t x, int32_t y) */ static void viewport_interaction_remove_scenery(TileElement* tileElement, int32_t x, int32_t y) { - gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - game_do_command( - x, (tileElement->AsSmallScenery()->GetSceneryQuadrant() << 8) | GAME_COMMAND_FLAG_APPLY, y, - (tileElement->AsSmallScenery()->GetEntryIndex() << 8) | tileElement->base_height, GAME_COMMAND_REMOVE_SCENERY, 0, 0); + auto removeSceneryAction = SceneryRemoveSmallAction( + x, y, tileElement->base_height, tileElement->AsSmallScenery()->GetSceneryQuadrant(), + tileElement->AsSmallScenery()->GetEntryIndex()); + + GameActions::Execute(&removeSceneryAction); } /** diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 57429537c2..c3936aee95 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1469,7 +1469,7 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = { game_command_set_ride_setting, game_command_place_ride_entrance_or_exit, game_command_remove_ride_entrance_or_exit, - game_command_remove_scenery, + nullptr, game_command_place_scenery, game_command_set_water_height, game_command_place_footpath, diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index d5c77b8671..531f627bfb 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -24,6 +24,7 @@ #include "RideSetColourScheme.hpp" #include "RideSetName.hpp" #include "RideSetStatus.hpp" +#include "SceneryRemoveSmallAction.hpp" #include "SetParkEntranceFeeAction.hpp" #include "SignSetNameAction.hpp" #include "StaffSetColourAction.hpp" @@ -55,5 +56,6 @@ namespace GameActions Register(); Register(); Register(); + Register(); } } // namespace GameActions diff --git a/src/openrct2/actions/SceneryRemoveSmallAction.hpp b/src/openrct2/actions/SceneryRemoveSmallAction.hpp new file mode 100644 index 0000000000..c281984032 --- /dev/null +++ b/src/openrct2/actions/SceneryRemoveSmallAction.hpp @@ -0,0 +1,168 @@ +/***************************************************************************** + * Copyright (c) 2014-2018 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../Cheats.h" +#include "../OpenRCT2.h" +#include "../common.h" +#include "../core/MemoryStream.h" +#include "../interface/Window.h" +#include "../localisation/Localisation.h" +#include "../localisation/StringIds.h" +#include "../management/Finance.h" +#include "../ride/Ride.h" +#include "../world/Park.h" +#include "../world/SmallScenery.h" +#include "../world/Sprite.h" +#include "GameAction.h" + +DEFINE_GAME_ACTION(SceneryRemoveSmallAction, GAME_COMMAND_REMOVE_SCENERY, GameActionResult) +{ +private: + int16_t _x; + int16_t _y; + uint8_t _baseHeight; + uint8_t _quadrant; + uint8_t _sceneryType; + +public: + SceneryRemoveSmallAction() = default; + + SceneryRemoveSmallAction(int16_t x, int16_t y, uint8_t baseHeight, uint8_t quadrant, uint8_t sceneryType) + : _x(x) + , _y(y) + , _baseHeight(baseHeight) + , _quadrant(quadrant) + , _sceneryType(sceneryType) + { + } + + uint16_t GetActionFlags() const override + { + return GameAction::GetActionFlags(); + } + + void Serialise(DataSerialiser & stream) override + { + GameAction::Serialise(stream); + + stream << DS_TAG(_x) << DS_TAG(_y) << DS_TAG(_baseHeight) << DS_TAG(_quadrant) << DS_TAG(_sceneryType); + } + + GameActionResult::Ptr Query() const override + { + GameActionResult::Ptr res = std::make_unique(); + + if (!map_is_location_valid({ _x, _y })) + { + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + } + + rct_scenery_entry* entry = get_small_scenery_entry(_sceneryType); + if (entry == nullptr) + { + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); + } + + res->Cost = entry->small_scenery.removal_price * 10; + res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + res->Position.x = _x; + res->Position.y = _y; + res->Position.z = _baseHeight * 8; + + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !gCheatsSandboxMode) + { + // Check if allowed to remove item + if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) + { + if (entry->small_scenery.height > 64) + { + res->Error = GA_ERROR::NO_CLEARANCE; + res->ErrorTitle = STR_CANT_REMOVE_THIS; + res->ErrorMessage = STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY; + return res; + } + } + + // Check if the land is owned + if (!map_is_location_owned(_x, _y, _baseHeight * 8)) + { + res->Error = GA_ERROR::NO_CLEARANCE; + res->ErrorTitle = STR_CANT_REMOVE_THIS; + res->ErrorMessage = STR_LAND_NOT_OWNED_BY_PARK; + return res; + } + } + + TileElement* tileElement = FindSceneryElement(); + if (tileElement == nullptr) + { + res->Cost = 0; + return res; + } + + return res; + } + + GameActionResult::Ptr Execute() const override + { + GameActionResult::Ptr res = std::make_unique(); + + rct_scenery_entry* entry = get_small_scenery_entry(_sceneryType); + if (entry == nullptr) + { + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_SELECTION_OF_OBJECTS); + } + + res->Cost = entry->small_scenery.removal_price * 10; + res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + res->Position.x = _x; + res->Position.y = _y; + res->Position.z = _baseHeight * 8; + + TileElement* tileElement = FindSceneryElement(); + if (tileElement == nullptr) + { + res->Cost = 0; + return res; + } + + res->Position.z = tile_element_height(res->Position.x, res->Position.y); + + map_invalidate_tile_full(_x, _y); + tile_element_remove(tileElement); + + return res; + } + +private: + TileElement* FindSceneryElement() const + { + TileElement* tileElement = map_get_first_element_at(_x / 32, _y / 32); + do + { + if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) + continue; + if ((tileElement->AsSmallScenery()->GetSceneryQuadrant()) != _quadrant) + continue; + if (tileElement->base_height != _baseHeight) + continue; + if (tileElement->AsSmallScenery()->GetEntryIndex() != _sceneryType) + continue; + if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && tileElement->IsGhost() == false) + continue; + + return tileElement; + + } while (!(tileElement++)->IsLastForTile()); + + return nullptr; + } +}; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index e53d9f82f3..2dbdd765e8 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -12,6 +12,7 @@ #include "../Cheats.h" #include "../Game.h" #include "../OpenRCT2.h" +#include "../actions/SceneryRemoveSmallAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../audio/audio.h" #include "../core/File.h" @@ -828,9 +829,11 @@ static int32_t track_design_place_scenery( } z = (scenery->z * 8 + originZ) / 8; - game_do_command( - mapCoord.x, flags | quadrant << 8, mapCoord.y, (entry_index << 8) | z, GAME_COMMAND_REMOVE_SCENERY, - 0, 0); + + auto removeSceneryAction = SceneryRemoveSmallAction(mapCoord.x, mapCoord.y, z, quadrant, entry_index); + removeSceneryAction.SetFlags(flags); + removeSceneryAction.Execute(); + break; } case OBJECT_TYPE_LARGE_SCENERY: diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 1059523993..bca95a8fa1 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -15,6 +15,7 @@ #include "../Input.h" #include "../OpenRCT2.h" #include "../actions/FootpathRemoveAction.hpp" +#include "../actions/SceneryRemoveSmallAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../audio/audio.h" #include "../config/Config.h" @@ -1078,17 +1079,17 @@ restart_from_beginning: case TILE_ELEMENT_TYPE_SMALL_SCENERY: if (clear & (1 << 0)) { - int32_t eax = x * 32; - int32_t ebx = (tileElement->AsSmallScenery()->GetSceneryQuadrant() << 8) | flags; - int32_t ecx = y * 32; - int32_t edx = (tileElement->AsSmallScenery()->GetEntryIndex() << 8) | (tileElement->base_height); - int32_t edi = 0, ebp = 0; - cost = game_do_command(eax, ebx, ecx, edx, GAME_COMMAND_REMOVE_SCENERY, edi, ebp); + auto removeSceneryAction = SceneryRemoveSmallAction( + x * 32, y * 32, tileElement->base_height, tileElement->AsSmallScenery()->GetSceneryQuadrant(), + tileElement->AsSmallScenery()->GetEntryIndex()); + removeSceneryAction.SetFlags(flags); - if (cost == MONEY32_UNDEFINED) + auto res + = ((flags & GAME_COMMAND_FLAG_APPLY) ? removeSceneryAction.Execute() : removeSceneryAction.Query()); + if (res->Error != GA_ERROR::OK) return MONEY32_UNDEFINED; - totalCost += cost; + totalCost += res->Cost; if (flags & GAME_COMMAND_FLAG_APPLY) goto restart_from_beginning; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 2c037d08d7..481a70ef0d 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -187,8 +187,6 @@ void game_command_set_land_height( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_set_land_ownership( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -void game_command_remove_scenery( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_remove_large_scenery( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_remove_banner( diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index e88f54b59e..0ab8f0237a 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -12,6 +12,7 @@ #include "../Cheats.h" #include "../Context.h" #include "../Game.h" +#include "../actions/SceneryRemoveSmallAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../common.h" #include "../localisation/Localisation.h" @@ -184,10 +185,10 @@ void scenery_remove_ghost_tool_placement() if (gSceneryGhostType & SCENERY_GHOST_FLAG_0) { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_0; - uint8_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 - | GAME_COMMAND_FLAG_GHOST; - game_do_command( - x, flags | (gSceneryQuadrant << 8), y, z | (gSceneryPlaceObject << 8), GAME_COMMAND_REMOVE_SCENERY, 0, 0); + + auto removeSceneryAction = SceneryRemoveSmallAction(x, y, z, gSceneryQuadrant, gSceneryPlaceObject); + removeSceneryAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST); + removeSceneryAction.Execute(); } if (gSceneryGhostType & SCENERY_GHOST_FLAG_1) diff --git a/src/openrct2/world/SmallScenery.cpp b/src/openrct2/world/SmallScenery.cpp index 97ae0958f4..2ccd2f4501 100644 --- a/src/openrct2/world/SmallScenery.cpp +++ b/src/openrct2/world/SmallScenery.cpp @@ -24,95 +24,6 @@ #include "Scenery.h" #include "Surface.h" -static money32 SmallSceneryRemove( - int16_t x, int16_t y, uint8_t baseHeight, uint8_t quadrant, uint8_t sceneryType, uint8_t flags) -{ - if (!map_is_location_valid({ x, y })) - { - return MONEY32_UNDEFINED; - } - money32 cost; - - rct_scenery_entry* entry = get_small_scenery_entry(sceneryType); - if (entry == nullptr) - { - log_warning("Invalid game command for scenery removal, scenery_type = %u", sceneryType); - return MONEY32_UNDEFINED; - } - cost = entry->small_scenery.removal_price * 10; - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - gCommandPosition.x = x + 16; - gCommandPosition.y = y + 16; - gCommandPosition.z = baseHeight * 8; - - if (!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode) - { - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - return MONEY32_UNDEFINED; - } - - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !(flags & GAME_COMMAND_FLAG_GHOST) && !gCheatsSandboxMode) - { - // Check if allowed to remove item - if (gParkFlags & PARK_FLAGS_FORBID_TREE_REMOVAL) - { - if (entry->small_scenery.height > 64) - { - gGameCommandErrorText = STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY; - return MONEY32_UNDEFINED; - } - } - - // Check if the land is owned - if (!map_is_location_owned(x, y, gCommandPosition.z)) - { - return MONEY32_UNDEFINED; - } - } - - bool sceneryFound = false; - TileElement* tileElement = map_get_first_element_at(x / 32, y / 32); - do - { - if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) - continue; - if ((tileElement->AsSmallScenery()->GetSceneryQuadrant()) != quadrant) - continue; - if (tileElement->base_height != baseHeight) - continue; - if (tileElement->AsSmallScenery()->GetEntryIndex() != sceneryType) - continue; - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(tileElement->flags & TILE_ELEMENT_FLAG_GHOST)) - continue; - - sceneryFound = true; - break; - } while (!(tileElement++)->IsLastForTile()); - - if (!sceneryFound) - { - return 0; - } - - // Remove element - if (flags & GAME_COMMAND_FLAG_APPLY) - { - if (gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) - { - LocationXYZ16 coord; - coord.x = x + 16; - coord.y = y + 16; - coord.z = tile_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } - - map_invalidate_tile_full(x, y); - tile_element_remove(tileElement); - } - return (gParkFlags & PARK_FLAGS_NO_MONEY) ? 0 : cost; -} - static money32 SmallScenerySetColour( int16_t x, int16_t y, uint8_t baseHeight, uint8_t quadrant, uint8_t sceneryType, uint8_t primaryColour, uint8_t secondaryColour, uint8_t flags) @@ -412,17 +323,6 @@ static money32 SmallSceneryPlace( return cost; } -/** - * - * rct2: 0x006E0E01 - */ -void game_command_remove_scenery( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, [[maybe_unused]] int32_t* edi, - [[maybe_unused]] int32_t* ebp) -{ - *ebx = SmallSceneryRemove(*eax & 0xFFFF, *ecx & 0xFFFF, *edx & 0xFF, ((*ebx >> 8) & 0xFF), (*edx >> 8) & 0xFF, *ebx & 0xFF); -} - /** * * rct2: 0x006E0F26 From d7096f71cbf028ad7e849d6da8fd0e3320f98e19 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 22 Dec 2018 19:46:59 +0100 Subject: [PATCH 2/6] Implement SceneryRemoveLargeAction. --- .../interface/ViewportInteraction.cpp | 9 +- src/openrct2-ui/windows/Sign.cpp | 13 +- src/openrct2/Game.cpp | 2 +- .../actions/GameActionRegistration.cpp | 2 + .../actions/SceneryRemoveLargeAction.hpp | 251 ++++++++++++++++++ src/openrct2/ride/TrackDesign.cpp | 15 +- src/openrct2/world/Map.cpp | 192 ++------------ src/openrct2/world/Map.h | 2 - src/openrct2/world/Scenery.cpp | 11 +- 9 files changed, 303 insertions(+), 194 deletions(-) create mode 100644 src/openrct2/actions/SceneryRemoveLargeAction.hpp diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 32971b1163..606ec30598 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -574,11 +575,9 @@ static void viewport_interaction_remove_large_scenery(TileElement* tileElement, } else { - gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - game_do_command( - x, 1 | (tileElement->GetDirection() << 8), y, - tileElement->base_height | (tileElement->AsLargeScenery()->GetSequenceIndex() << 8), - GAME_COMMAND_REMOVE_LARGE_SCENERY, 0, 0); + auto removeSceneryAction = SceneryRemoveLargeAction( + x, y, tileElement->base_height, tileElement->GetDirection(), tileElement->AsLargeScenery()->GetSequenceIndex()); + GameActions::Execute(&removeSceneryAction); } } diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index dede2f54c8..1eeda799c3 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -214,6 +215,7 @@ static void window_sign_mouseup(rct_window* w, rct_widgetindex widgetIndex) window_close(w); break; case WIDX_SIGN_DEMOLISH: + { while (1) { if (tile_element->GetType() == TILE_ELEMENT_TYPE_LARGE_SCENERY) @@ -228,11 +230,14 @@ static void window_sign_mouseup(rct_window* w, rct_widgetindex widgetIndex) } tile_element++; } - game_do_command( - x, 1 | (tile_element->GetDirection() << 8), y, - tile_element->base_height | (tile_element->AsLargeScenery()->GetSequenceIndex() << 8), - GAME_COMMAND_REMOVE_LARGE_SCENERY, 0, 0); + + auto sceneryRemoveAction = SceneryRemoveLargeAction( + x, y, tile_element->base_height, tile_element->GetDirection(), + tile_element->AsLargeScenery()->GetSequenceIndex()); + GameActions::Execute(&sceneryRemoveAction); + break; + } case WIDX_SIGN_TEXT: if (banner->flags & BANNER_FLAG_LINKED_TO_RIDE) { diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index c3936aee95..d0c32640c5 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1500,7 +1500,7 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = { game_command_place_wall, nullptr, game_command_place_large_scenery, - game_command_remove_large_scenery, + nullptr, nullptr, nullptr, game_command_place_track_design, diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index 531f627bfb..f4ce2666d7 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -24,6 +24,7 @@ #include "RideSetColourScheme.hpp" #include "RideSetName.hpp" #include "RideSetStatus.hpp" +#include "SceneryRemoveLargeAction.hpp" #include "SceneryRemoveSmallAction.hpp" #include "SetParkEntranceFeeAction.hpp" #include "SignSetNameAction.hpp" @@ -57,5 +58,6 @@ namespace GameActions Register(); Register(); Register(); + Register(); } } // namespace GameActions diff --git a/src/openrct2/actions/SceneryRemoveLargeAction.hpp b/src/openrct2/actions/SceneryRemoveLargeAction.hpp new file mode 100644 index 0000000000..50c79b010e --- /dev/null +++ b/src/openrct2/actions/SceneryRemoveLargeAction.hpp @@ -0,0 +1,251 @@ +/***************************************************************************** + * Copyright (c) 2014-2018 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../Cheats.h" +#include "../OpenRCT2.h" +#include "../common.h" +#include "../core/MemoryStream.h" +#include "../interface/Window.h" +#include "../localisation/Localisation.h" +#include "../localisation/StringIds.h" +#include "../management/Finance.h" +#include "../ride/Ride.h" +#include "../world/Park.h" +#include "../world/SmallScenery.h" +#include "../world/Sprite.h" +#include "GameAction.h" + +DEFINE_GAME_ACTION(SceneryRemoveLargeAction, GAME_COMMAND_REMOVE_LARGE_SCENERY, GameActionResult) +{ +private: + int16_t _x; + int16_t _y; + uint8_t _baseHeight; + uint8_t _direction; + uint16_t _tileIndex; + +public: + SceneryRemoveLargeAction() = default; + + SceneryRemoveLargeAction(int16_t x, int16_t y, uint8_t baseHeight, uint8_t direction, uint16_t tileIndex) + : _x(x) + , _y(y) + , _baseHeight(baseHeight) + , _direction(direction) + , _tileIndex(tileIndex) + { + } + + uint16_t GetActionFlags() const override + { + return GameAction::GetActionFlags(); + } + + void Serialise(DataSerialiser & stream) override + { + GameAction::Serialise(stream); + + stream << DS_TAG(_x) << DS_TAG(_y) << DS_TAG(_baseHeight) << DS_TAG(_direction) << DS_TAG(_tileIndex); + } + + GameActionResult::Ptr Query() const override + { + GameActionResult::Ptr res = std::make_unique(); + + const uint32_t flags = GetFlags(); + + int32_t z = tile_element_height(_x, _y); + res->Position.x = _x + 16; + res->Position.y = _y + 16; + res->Position.z = z; + res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + res->Cost = 0; + + TileElement* tileElement = FindLargeSceneryElement(); + if (tileElement == nullptr) + { + log_warning("Invalid game command for scenery removal, x = %d, y = %d", _x, _y); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_SELECTION_OF_OBJECTS); + } + + rct_scenery_entry* scenery_entry = tileElement->AsLargeScenery()->GetEntry(); + + LocationXYZ16 firstTile = { + scenery_entry->large_scenery.tiles[_tileIndex].x_offset, scenery_entry->large_scenery.tiles[_tileIndex].y_offset, + static_cast((_baseHeight * 8) - scenery_entry->large_scenery.tiles[_tileIndex].z_offset) + }; + + rotate_map_coordinates(&firstTile.x, &firstTile.y, _direction); + + firstTile.x = _x - firstTile.x; + firstTile.y = _y - firstTile.y; + + bool calculate_cost = true; + for (int32_t i = 0; scenery_entry->large_scenery.tiles[i].x_offset != -1; i++) + { + LocationXYZ16 currentTile = { scenery_entry->large_scenery.tiles[i].x_offset, + scenery_entry->large_scenery.tiles[i].y_offset, + scenery_entry->large_scenery.tiles[i].z_offset }; + + rotate_map_coordinates(¤tTile.x, ¤tTile.y, _direction); + + currentTile.x += firstTile.x; + currentTile.y += firstTile.y; + currentTile.z += firstTile.z; + + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) + { + if (!map_is_location_owned(currentTile.x, currentTile.y, currentTile.z)) + { + return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + } + } + + // NOTE: Not sure what to make of this, is this actually correct? + if (flags & GAME_COMMAND_FLAG_PATH_SCENERY) + { + if (tileElement->flags & (1 << 6)) + calculate_cost = false; + + tileElement->flags |= (1 << 6); + } + } + + if (calculate_cost == true) + res->Cost = scenery_entry->large_scenery.removal_price * 10; + + return res; + } + + GameActionResult::Ptr Execute() const override + { + GameActionResult::Ptr res = std::make_unique(); + + const uint32_t flags = GetFlags(); + + int32_t z = tile_element_height(_x, _y); + res->Position.x = _x + 16; + res->Position.y = _y + 16; + res->Position.z = z; + res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + res->Cost = 0; + + TileElement* tileElement = FindLargeSceneryElement(); + if (tileElement == nullptr) + { + log_warning("Invalid game command for scenery removal, x = %d, y = %d", _x, _y); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_SELECTION_OF_OBJECTS); + } + + tile_element_remove_banner_entry(tileElement); + + rct_scenery_entry* scenery_entry = tileElement->AsLargeScenery()->GetEntry(); + + LocationXYZ16 firstTile = { + scenery_entry->large_scenery.tiles[_tileIndex].x_offset, scenery_entry->large_scenery.tiles[_tileIndex].y_offset, + static_cast((_baseHeight * 8) - scenery_entry->large_scenery.tiles[_tileIndex].z_offset) + }; + + rotate_map_coordinates(&firstTile.x, &firstTile.y, _direction); + + firstTile.x = _x - firstTile.x; + firstTile.y = _y - firstTile.y; + + for (int32_t i = 0; scenery_entry->large_scenery.tiles[i].x_offset != -1; i++) + { + LocationXYZ16 currentTile = { scenery_entry->large_scenery.tiles[i].x_offset, + scenery_entry->large_scenery.tiles[i].y_offset, + scenery_entry->large_scenery.tiles[i].z_offset }; + + rotate_map_coordinates(¤tTile.x, ¤tTile.y, _direction); + + currentTile.x += firstTile.x; + currentTile.y += firstTile.y; + currentTile.z += firstTile.z; + + if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) + { + if (!map_is_location_owned(currentTile.x, currentTile.y, currentTile.z)) + { + return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + } + } + + TileElement* sceneryElement = map_get_first_element_at(currentTile.x / 32, currentTile.y / 32); + bool element_found = false; + do + { + if (sceneryElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY) + continue; + + if (sceneryElement->GetDirection() != _direction) + continue; + + if (sceneryElement->AsLargeScenery()->GetSequenceIndex() != i) + continue; + + if (sceneryElement->base_height != currentTile.z / 8) + continue; + + // If we are removing ghost elements + if ((flags & GAME_COMMAND_FLAG_GHOST) && sceneryElement->IsGhost() == false) + continue; + + map_invalidate_tile_full(currentTile.x, currentTile.y); + tile_element_remove(sceneryElement); + + element_found = true; + break; + } while (!(sceneryElement++)->IsLastForTile()); + + if (element_found == false) + { + log_error("Tile not found when trying to remove element!"); + } + } + + res->Cost = scenery_entry->large_scenery.removal_price * 10; + + return res; + } + +private: + TileElement* FindLargeSceneryElement() const + { + TileElement* tileElement = map_get_first_element_at(_x / 32, _y / 32); + if (tileElement == nullptr) + return nullptr; + + do + { + if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY) + continue; + + if (tileElement->base_height != _baseHeight) + continue; + + if (tileElement->AsLargeScenery()->GetSequenceIndex() != _tileIndex) + continue; + + if (tileElement->GetDirection() != _direction) + continue; + + // If we are removing ghost elements + if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && tileElement->IsGhost() == false) + continue; + + return tileElement; + + } while (!(tileElement++)->IsLastForTile()); + + return nullptr; + } +}; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 2dbdd765e8..541cd653a9 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -12,6 +12,7 @@ #include "../Cheats.h" #include "../Game.h" #include "../OpenRCT2.h" +#include "../actions/SceneryRemoveLargeAction.hpp" #include "../actions/SceneryRemoveSmallAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../audio/audio.h" @@ -837,11 +838,16 @@ static int32_t track_design_place_scenery( break; } case OBJECT_TYPE_LARGE_SCENERY: + { z = (scenery->z * 8 + originZ) / 8; - game_do_command( - mapCoord.x, flags | (((rotation + scenery->flags) & 0x3) << 8), mapCoord.y, z, - GAME_COMMAND_REMOVE_LARGE_SCENERY, 0, 0); + + auto removeSceneryAction = SceneryRemoveLargeAction( + mapCoord.x, mapCoord.y, z, (rotation + scenery->flags) & 0x3, 0); + removeSceneryAction.SetFlags(flags); + removeSceneryAction.Execute(); + break; + } case OBJECT_TYPE_WALLS: { z = (scenery->z * 8 + originZ) / 8; @@ -853,8 +859,9 @@ static int32_t track_design_place_scenery( wallRemoveAction.SetFlags(flags); GameActions::Execute(&wallRemoveAction); + + break; } - break; case OBJECT_TYPE_PATHS: z = (scenery->z * 8 + originZ) / 8; footpath_remove(mapCoord.x, mapCoord.y, z, flags); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index bca95a8fa1..41a2cf90ea 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -15,6 +15,7 @@ #include "../Input.h" #include "../OpenRCT2.h" #include "../actions/FootpathRemoveAction.hpp" +#include "../actions/SceneryRemoveLargeAction.hpp" #include "../actions/SceneryRemoveSmallAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../audio/audio.h" @@ -789,167 +790,6 @@ bool map_is_location_owned_or_has_rights(int32_t x, int32_t y) return false; } -/** - * - * rct2: 0x006B8E1B - */ -void game_command_remove_large_scenery( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, [[maybe_unused]] int32_t* edi, - [[maybe_unused]] int32_t* ebp) -{ - uint8_t base_height = *edx; - uint8_t tileIndex = *edx >> 8; - uint8_t tile_element_direction = *ebx >> 8; - int32_t x = *eax; - int32_t y = *ecx; - int32_t z = tile_element_height(x, y); - uint8_t flags = *ebx & 0xFF; - gCommandPosition.x = x + 16; - gCommandPosition.y = y + 16; - gCommandPosition.z = z; - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - - if (!(flags & GAME_COMMAND_FLAG_GHOST) && game_is_paused() && !gCheatsBuildInPauseMode) - { - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - *ebx = MONEY32_UNDEFINED; - return; - } - - bool element_found = false; - TileElement* tileElement = map_get_first_element_at(x / 32, y / 32); - if (tileElement == nullptr) - { - log_warning("Invalid game command for scenery removal, x = %d, y = %d", x, y); - *ebx = MONEY32_UNDEFINED; - return; - } - do - { - if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY) - continue; - - if (tileElement->base_height != base_height) - continue; - - if (tileElement->AsLargeScenery()->GetSequenceIndex() != tileIndex) - continue; - - if (tileElement->GetDirection() != tile_element_direction) - continue; - - // If we are removing ghost elements - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(tileElement->flags & TILE_ELEMENT_FLAG_GHOST)) - continue; - - element_found = true; - break; - } while (!(tileElement++)->IsLastForTile()); - - if (element_found == false) - { - *ebx = 0; - return; - } - - if (flags & GAME_COMMAND_FLAG_APPLY) - { - tile_element_remove_banner_entry(tileElement); - } - - rct_scenery_entry* scenery_entry = tileElement->AsLargeScenery()->GetEntry(); - LocationXYZ16 firstTile = { - scenery_entry->large_scenery.tiles[tileIndex].x_offset, scenery_entry->large_scenery.tiles[tileIndex].y_offset, - static_cast((base_height * 8) - scenery_entry->large_scenery.tiles[tileIndex].z_offset) - }; - - rotate_map_coordinates(&firstTile.x, &firstTile.y, tile_element_direction); - - firstTile.x = x - firstTile.x; - firstTile.y = y - firstTile.y; - - bool calculate_cost = true; - for (int32_t i = 0; scenery_entry->large_scenery.tiles[i].x_offset != -1; i++) - { - LocationXYZ16 currentTile = { scenery_entry->large_scenery.tiles[i].x_offset, - scenery_entry->large_scenery.tiles[i].y_offset, - scenery_entry->large_scenery.tiles[i].z_offset }; - - rotate_map_coordinates(¤tTile.x, ¤tTile.y, tile_element_direction); - - currentTile.x += firstTile.x; - currentTile.y += firstTile.y; - currentTile.z += firstTile.z; - - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) - { - if (!map_is_location_owned(currentTile.x, currentTile.y, currentTile.z)) - { - *ebx = MONEY32_UNDEFINED; - return; - } - } - - // If not applying then no need to delete the actual element - if (!(flags & GAME_COMMAND_FLAG_APPLY)) - { - if (flags & (1 << 7)) - { - if (tileElement->flags & (1 << 6)) - calculate_cost = false; - tileElement->flags |= (1 << 6); - } - continue; - } - - TileElement* sceneryElement = map_get_first_element_at(currentTile.x / 32, currentTile.y / 32); - element_found = false; - do - { - if (sceneryElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY) - continue; - - if (sceneryElement->GetDirection() != tile_element_direction) - continue; - - if (sceneryElement->AsLargeScenery()->GetSequenceIndex() != i) - continue; - - if (sceneryElement->base_height != currentTile.z / 8) - continue; - - // If we are removing ghost elements - if ((flags & GAME_COMMAND_FLAG_GHOST) && !(sceneryElement->flags & TILE_ELEMENT_FLAG_GHOST)) - continue; - - map_invalidate_tile_full(currentTile.x, currentTile.y); - tile_element_remove(sceneryElement); - element_found = true; - break; - } while (!(sceneryElement++)->IsLastForTile()); - - if (element_found == false) - { - log_error("Tile not found when trying to remove element!"); - } - } - - if (flags & GAME_COMMAND_FLAG_APPLY && gGameCommandNestLevel == 1 && !(flags & GAME_COMMAND_FLAG_GHOST)) - { - LocationXYZ16 coord; - coord.x = x + 16; - coord.y = y + 16; - coord.z = tile_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } - - *ebx = scenery_entry->large_scenery.removal_price * 10; - if (gParkFlags & PARK_FLAGS_NO_MONEY || calculate_cost == false) - { - *ebx = 0; - } -} - /** * * rct2: 0x006B909A @@ -1044,7 +884,7 @@ void game_command_set_large_scenery_colour( static money32 map_clear_scenery_from_tile(int32_t x, int32_t y, int32_t clear, int32_t flags) { int32_t type; - money32 cost, totalCost; + money32 totalCost; TileElement* tileElement; totalCost = 0; @@ -1112,17 +952,17 @@ restart_from_beginning: case TILE_ELEMENT_TYPE_LARGE_SCENERY: if (clear & (1 << 1)) { - int32_t eax = x * 32; - int32_t ebx = flags | ((tileElement->GetDirection()) << 8); - int32_t ecx = y * 32; - int32_t edx = tileElement->base_height | (tileElement->AsLargeScenery()->GetSequenceIndex() << 8); - int32_t edi = 0, ebp = 0; - cost = game_do_command(eax, ebx | (1 << 7), ecx, edx, GAME_COMMAND_REMOVE_LARGE_SCENERY, edi, ebp); + auto removeSceneryAction = SceneryRemoveLargeAction( + x * 32, y * 32, tileElement->base_height, tileElement->GetDirection(), + tileElement->AsLargeScenery()->GetSequenceIndex()); + removeSceneryAction.SetFlags(flags | GAME_COMMAND_FLAG_PATH_SCENERY); - if (cost == MONEY32_UNDEFINED) + auto res + = ((flags & GAME_COMMAND_FLAG_APPLY) ? removeSceneryAction.Execute() : removeSceneryAction.Query()); + if (res->Error != GA_ERROR::OK) return MONEY32_UNDEFINED; - totalCost += cost; + totalCost += res->Cost; if (flags & GAME_COMMAND_FLAG_APPLY) goto restart_from_beginning; @@ -3859,12 +3699,12 @@ static void clear_element_at(int32_t x, int32_t y, TileElement** elementPtr) } break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: - gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - game_do_command( - x, (GAME_COMMAND_FLAG_APPLY) | (element->GetDirection() << 8), y, - (element->base_height) | (element->AsLargeScenery()->GetSequenceIndex() << 8), - GAME_COMMAND_REMOVE_LARGE_SCENERY, 0, 0); - break; + { + auto removeSceneryAction = SceneryRemoveLargeAction( + x, y, element->base_height, element->GetDirection(), element->AsLargeScenery()->GetSequenceIndex()); + GameActions::Execute(&removeSceneryAction); + } + break; case TILE_ELEMENT_TYPE_BANNER: gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; game_do_command( diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 481a70ef0d..cee7ab1607 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -187,8 +187,6 @@ void game_command_set_land_height( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_set_land_ownership( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -void game_command_remove_large_scenery( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_remove_banner( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_set_scenery_colour( diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 0ab8f0237a..efc948a249 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -12,6 +12,7 @@ #include "../Cheats.h" #include "../Context.h" #include "../Game.h" +#include "../actions/SceneryRemoveLargeAction.hpp" #include "../actions/SceneryRemoveSmallAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../common.h" @@ -224,13 +225,19 @@ void scenery_remove_ghost_tool_placement() if (gSceneryGhostType & SCENERY_GHOST_FLAG_3) { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_3; - game_do_command(x, 105 | (gSceneryPlaceRotation << 8), y, z, GAME_COMMAND_REMOVE_LARGE_SCENERY, 0, 0); + + auto removeSceneryAction = SceneryRemoveLargeAction(x, y, z, gSceneryPlaceRotation, 0); + removeSceneryAction.SetFlags( + GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5); + removeSceneryAction.Execute(); } if (gSceneryGhostType & SCENERY_GHOST_FLAG_4) { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_4; - game_do_command(x, 105, y, z | (gSceneryPlaceRotation << 8), GAME_COMMAND_REMOVE_BANNER, 0, 0); + constexpr uint32_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED + | GAME_COMMAND_FLAG_5; + game_do_command(x, flags, y, z | (gSceneryPlaceRotation << 8), GAME_COMMAND_REMOVE_BANNER, 0, 0); } } From b9fd90ffd36b1d0fe2f2066b00429453964069d6 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Wed, 2 Jan 2019 12:59:37 +0100 Subject: [PATCH 3/6] Implement ClearAction. --- src/openrct2-ui/title/TitleSequencePlayer.cpp | 2 +- src/openrct2-ui/windows/TopToolbar.cpp | 65 ++--- src/openrct2/Game.cpp | 2 +- src/openrct2/Game.h | 6 +- src/openrct2/actions/ClearAction.hpp | 247 ++++++++++++++++++ .../actions/GameActionRegistration.cpp | 2 + .../actions/SceneryRemoveSmallAction.hpp | 3 + src/openrct2/actions/WallRemoveAction.hpp | 3 + src/openrct2/core/DataSerialiserTraits.h | 29 ++ src/openrct2/paint/VirtualFloor.cpp | 8 +- src/openrct2/world/Location.hpp | 68 ++++- src/openrct2/world/Map.cpp | 197 -------------- src/openrct2/world/Map.h | 2 - 13 files changed, 393 insertions(+), 241 deletions(-) create mode 100644 src/openrct2/actions/ClearAction.hpp diff --git a/src/openrct2-ui/title/TitleSequencePlayer.cpp b/src/openrct2-ui/title/TitleSequencePlayer.cpp index 30aef26573..05872d80d8 100644 --- a/src/openrct2-ui/title/TitleSequencePlayer.cpp +++ b/src/openrct2-ui/title/TitleSequencePlayer.cpp @@ -57,7 +57,7 @@ private: int32_t _lastScreenWidth = 0; int32_t _lastScreenHeight = 0; - CoordsXY _viewCentreLocation = {}; + CoordsXY _viewCentreLocation; public: explicit TitleSequencePlayer(IScenarioRepository& scenarioRepository, GameState& gameState) diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index f11f255355..48a64c1115 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -292,6 +293,8 @@ static void toggle_water_window(rct_window* topToolbar, rct_widgetindex widgetIn static money32 selection_lower_land(uint8_t flags); static money32 selection_raise_land(uint8_t flags); +static ClearAction GetClearAction(); + static bool _menuDropdownIncludesTwitch; static uint8_t _unkF64F0E; static int16_t _unkF64F0A; @@ -1940,18 +1943,13 @@ static void top_toolbar_tool_update_scenery_clear(int16_t x, int16_t y) if (!state_changed) return; - int32_t eax = gMapSelectPositionA.x; - int32_t ecx = gMapSelectPositionA.y; - int32_t edi = gMapSelectPositionB.x; - int32_t ebp = gMapSelectPositionB.y; - int32_t clear = (gClearSmallScenery << 0) | (gClearLargeScenery << 1) | (gClearFootpath << 2); - money32 cost = game_do_command(eax, 0, ecx, clear, GAME_COMMAND_CLEAR_SCENERY, edi, ebp); - + auto action = GetClearAction(); + auto result = GameActions::Query(&action); + auto cost = (result->Error == GA_ERROR::OK ? result->Cost : MONEY32_UNDEFINED); if (gClearSceneryCost != cost) { gClearSceneryCost = cost; window_invalidate_by_class(WC_CLEAR_SCENERY); - return; } } @@ -2815,16 +2813,12 @@ static void window_top_toolbar_tool_down(rct_window* w, rct_widgetindex widgetIn switch (widgetIndex) { case WIDX_CLEAR_SCENERY: - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) - break; - - gGameCommandErrorTitle = STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE; - - game_do_command( - gMapSelectPositionA.x, 1, gMapSelectPositionA.y, - ((gClearSmallScenery ? 1 : 0) | (gClearLargeScenery ? 1 : 0) << 1 | (gClearFootpath ? 1 : 0) << 2), - GAME_COMMAND_CLEAR_SCENERY, gMapSelectPositionB.x, gMapSelectPositionB.y); - gCurrentToolId = TOOL_CROSSHAIR; + if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + { + auto action = GetClearAction(); + GameActions::Execute(&action); + gCurrentToolId = TOOL_CROSSHAIR; + } break; case WIDX_LAND: if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) @@ -3008,19 +3002,12 @@ static void window_top_toolbar_tool_drag(rct_window* w, rct_widgetindex widgetIn switch (widgetIndex) { case WIDX_CLEAR_SCENERY: - if (window_find_by_class(WC_ERROR) != nullptr) - break; - - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) - break; - - gGameCommandErrorTitle = STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE; - - game_do_command( - gMapSelectPositionA.x, 1, gMapSelectPositionA.y, - ((gClearSmallScenery ? 1 : 0) | (gClearLargeScenery ? 1 : 0) << 1 | (gClearFootpath ? 1 : 0) << 2), - GAME_COMMAND_CLEAR_SCENERY, gMapSelectPositionB.x, gMapSelectPositionB.y); - gCurrentToolId = TOOL_CROSSHAIR; + if (window_find_by_class(WC_ERROR) == nullptr && (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + { + auto action = GetClearAction(); + GameActions::Execute(&action); + gCurrentToolId = TOOL_CROSSHAIR; + } break; case WIDX_LAND: // Custom setting to only change land style instead of raising or lowering land @@ -3539,3 +3526,19 @@ bool water_tool_is_active() return false; return true; } + +static ClearAction GetClearAction() +{ + auto range = MapRange(gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y); + + ClearableItems itemsToClear = 0; + + if (gClearSmallScenery) + itemsToClear |= CLEARABLE_ITEMS::SCENERY_SMALL; + if (gClearLargeScenery) + itemsToClear |= CLEARABLE_ITEMS::SCENERY_LARGE; + if (gClearFootpath) + itemsToClear |= CLEARABLE_ITEMS::SCENERY_FOOTPATH; + + return ClearAction(range, itemsToClear); +} diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index d0c32640c5..97574ac59c 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1513,7 +1513,7 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = { game_command_set_large_scenery_colour, game_command_set_banner_colour, game_command_set_land_ownership, - game_command_clear_scenery, + nullptr, nullptr, nullptr, game_command_set_banner_style, diff --git a/src/openrct2/Game.h b/src/openrct2/Game.h index 000790d790..a5026ee75c 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -32,7 +32,7 @@ enum GAME_COMMAND GAME_COMMAND_SET_RIDE_SETTING, GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, - GAME_COMMAND_REMOVE_SCENERY, + GAME_COMMAND_REMOVE_SCENERY, // GA GAME_COMMAND_PLACE_SCENERY, GAME_COMMAND_SET_WATER_HEIGHT, GAME_COMMAND_PLACE_PATH, @@ -63,7 +63,7 @@ enum GAME_COMMAND GAME_COMMAND_PLACE_WALL, GAME_COMMAND_REMOVE_WALL, // GA GAME_COMMAND_PLACE_LARGE_SCENERY, - GAME_COMMAND_REMOVE_LARGE_SCENERY, + GAME_COMMAND_REMOVE_LARGE_SCENERY, // GA GAME_COMMAND_SET_CURRENT_LOAN, // GA GAME_COMMAND_SET_RESEARCH_FUNDING, // GA GAME_COMMAND_PLACE_TRACK_DESIGN, @@ -76,7 +76,7 @@ enum GAME_COMMAND GAME_COMMAND_SET_LARGE_SCENERY_COLOUR, GAME_COMMAND_SET_BANNER_COLOUR, GAME_COMMAND_SET_LAND_OWNERSHIP, - GAME_COMMAND_CLEAR_SCENERY, + GAME_COMMAND_CLEAR_SCENERY, // GA GAME_COMMAND_SET_BANNER_NAME, // GA GAME_COMMAND_SET_SIGN_NAME, // GA GAME_COMMAND_SET_BANNER_STYLE, diff --git a/src/openrct2/actions/ClearAction.hpp b/src/openrct2/actions/ClearAction.hpp new file mode 100644 index 0000000000..8406832fd6 --- /dev/null +++ b/src/openrct2/actions/ClearAction.hpp @@ -0,0 +1,247 @@ +/***************************************************************************** + * Copyright (c) 2014-2019 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../Context.h" +#include "../core/MemoryStream.h" +#include "../drawing/Drawing.h" +#include "../localisation/StringIds.h" +#include "../management/Finance.h" +#include "../world/LargeScenery.h" +#include "../world/Location.hpp" +#include "../world/Map.h" +#include "FootpathRemoveAction.hpp" +#include "GameAction.h" +#include "SceneryRemoveLargeAction.hpp" +#include "SceneryRemoveSmallAction.hpp" +#include "WallRemoveAction.hpp" + +#include + +using namespace OpenRCT2; + +using ClearableItems = uint8_t; + +namespace CLEARABLE_ITEMS +{ + constexpr ClearableItems SCENERY_SMALL = 1 << 0; + constexpr ClearableItems SCENERY_LARGE = 1 << 1; + constexpr ClearableItems SCENERY_FOOTPATH = 1 << 2; +} // namespace CLEARABLE_ITEMS + +DEFINE_GAME_ACTION(ClearAction, GAME_COMMAND_CLEAR_SCENERY, GameActionResult) +{ +private: + MapRange _range; + ClearableItems _itemsToClear; + +public: + ClearAction() + { + } + ClearAction(MapRange range, ClearableItems itemsToClear) + : _range(range) + , _itemsToClear(itemsToClear) + { + } + + void Serialise(DataSerialiser & stream) override + { + GameAction::Serialise(stream); + + stream << DS_TAG(_range) << DS_TAG(_itemsToClear); + } + + GameActionResult::Ptr Query() const override + { + return QueryExecute(false); + } + + GameActionResult::Ptr Execute() const override + { + return QueryExecute(true); + } + +private: + GameActionResult::Ptr CreateResult() const + { + auto result = MakeResult(); + result->ErrorTitle = STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE; + result->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + + auto x = (_range.GetLeft() + _range.GetRight()) / 2 + 16; + auto y = (_range.GetTop() + _range.GetBottom()) / 2 + 16; + auto z = tile_element_height(x, y); + result->Position = CoordsXYZ(x, y, z); + + return result; + } + + GameActionResult::Ptr QueryExecute(bool executing) const + { + auto result = CreateResult(); + + auto noValidTiles = true; + auto error = GA_ERROR::OK; + rct_string_id errorMessage = STR_NONE; + money32 totalCost = 0; + + auto x0 = std::max(_range.GetLeft(), 32); + auto y0 = std::max(_range.GetTop(), 32); + auto x1 = std::min(_range.GetRight(), (int32_t)gMapSizeMaxXY); + auto y1 = std::min(_range.GetBottom(), (int32_t)gMapSizeMaxXY); + + for (int32_t y = y0; y <= y1; y += 32) + { + for (int32_t x = x0; x <= x1; x += 32) + { + if (MapCanClearAt(x, y)) + { + auto cost = ClearSceneryFromTile(x / 32, y / 32, executing); + if (cost != MONEY32_UNDEFINED) + { + noValidTiles = false; + totalCost += cost; + } + } + else + { + error = GA_ERROR::NOT_OWNED; + errorMessage = STR_LAND_NOT_OWNED_BY_PARK; + } + } + } + + if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_LARGE) + { + ResetClearLargeSceneryFlag(); + } + + if (noValidTiles) + { + result->Error = error; + result->ErrorMessage = errorMessage; + } + + result->Cost = totalCost; + return result; + } + + money32 ClearSceneryFromTile(int32_t x, int32_t y, bool executing) const + { + // Pass down all flags. + TileElement* tileElement = nullptr; + money32 totalCost = 0; + bool tileEdited; + do + { + tileEdited = false; + tileElement = map_get_first_element_at(x, y); + do + { + auto type = tileElement->GetType(); + switch (type) + { + case TILE_ELEMENT_TYPE_PATH: + if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_FOOTPATH) + { + auto footpathRemoveAction = FootpathRemoveAction(x * 32, y * 32, tileElement->base_height); + footpathRemoveAction.SetFlags(GetFlags()); + + auto res = executing ? footpathRemoveAction.Execute() : footpathRemoveAction.Query(); + if (res->Error != GA_ERROR::OK) + return MONEY32_UNDEFINED; + + totalCost += res->Cost; + tileEdited = executing; + } + break; + case TILE_ELEMENT_TYPE_SMALL_SCENERY: + if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_SMALL) + { + auto removeSceneryAction = SceneryRemoveSmallAction( + x * 32, y * 32, tileElement->base_height, tileElement->AsSmallScenery()->GetSceneryQuadrant(), + tileElement->AsSmallScenery()->GetEntryIndex()); + removeSceneryAction.SetFlags(GetFlags()); + + auto res = executing ? removeSceneryAction.Execute() : removeSceneryAction.Query(); + if (res->Error != GA_ERROR::OK) + return MONEY32_UNDEFINED; + + totalCost += res->Cost; + tileEdited = executing; + } + break; + case TILE_ELEMENT_TYPE_WALL: + if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_SMALL) + { + TileCoordsXYZD wallLocation = { x, y, tileElement->base_height, tileElement->GetDirection() }; + auto wallRemoveAction = WallRemoveAction(wallLocation); + wallRemoveAction.SetFlags(GetFlags()); + + auto res = executing ? wallRemoveAction.Execute() : wallRemoveAction.Query(); + if (res->Error != GA_ERROR::OK) + return MONEY32_UNDEFINED; + + totalCost += res->Cost; + tileEdited = executing; + } + break; + case TILE_ELEMENT_TYPE_LARGE_SCENERY: + if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_LARGE) + { + auto removeSceneryAction = SceneryRemoveLargeAction( + x * 32, y * 32, tileElement->base_height, tileElement->GetDirection(), + tileElement->AsLargeScenery()->GetSequenceIndex()); + removeSceneryAction.SetFlags(GetFlags() | GAME_COMMAND_FLAG_PATH_SCENERY); + + auto res = executing ? removeSceneryAction.Execute() : removeSceneryAction.Query(); + if (res->Error != GA_ERROR::OK) + return MONEY32_UNDEFINED; + + totalCost += res->Cost; + tileEdited = executing; + } + break; + } + } while (!tileEdited && !(tileElement++)->IsLastForTile()); + } while (tileEdited); + + return totalCost; + } + + /** + * Function to clear the flag that is set to prevent cost duplication + * when using the clear scenery tool with large scenery. + */ + static void ResetClearLargeSceneryFlag() + { + // TODO: Improve efficiency of this + for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++) + { + for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++) + { + auto tileElement = map_get_first_element_at(x, y); + do + { + if (tileElement->GetType() == TILE_ELEMENT_TYPE_LARGE_SCENERY) + { + tileElement->flags &= ~(1 << 6); + } + } while (!(tileElement++)->IsLastForTile()); + } + } + } + + static bool MapCanClearAt(int32_t x, int32_t y) + { + return (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode || map_is_location_owned_or_has_rights(x, y); + } +}; diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index f4ce2666d7..a350c15982 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -8,6 +8,7 @@ *****************************************************************************/ #include "BannerSetNameAction.hpp" +#include "ClearAction.hpp" #include "ClimateSetAction.hpp" #include "FootpathRemoveAction.hpp" #include "GameAction.h" @@ -59,5 +60,6 @@ namespace GameActions Register(); Register(); Register(); + Register(); } } // namespace GameActions diff --git a/src/openrct2/actions/SceneryRemoveSmallAction.hpp b/src/openrct2/actions/SceneryRemoveSmallAction.hpp index c281984032..49e4d8e043 100644 --- a/src/openrct2/actions/SceneryRemoveSmallAction.hpp +++ b/src/openrct2/actions/SceneryRemoveSmallAction.hpp @@ -146,6 +146,9 @@ private: TileElement* FindSceneryElement() const { TileElement* tileElement = map_get_first_element_at(_x / 32, _y / 32); + if (!tileElement) + return nullptr; + do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index 4746113587..ea385c75dd 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -99,6 +99,9 @@ private: TileElement* GetFirstWallElementAt(const TileCoordsXYZD& location, bool isGhost) const { TileElement* tileElement = map_get_first_element_at(location.x, location.y); + if (!tileElement) + return nullptr; + do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) diff --git a/src/openrct2/core/DataSerialiserTraits.h b/src/openrct2/core/DataSerialiserTraits.h index a95cebe730..c496398259 100644 --- a/src/openrct2/core/DataSerialiserTraits.h +++ b/src/openrct2/core/DataSerialiserTraits.h @@ -14,6 +14,7 @@ #include "../network/NetworkTypes.h" #include "../network/network.h" #include "../ride/Ride.h" +#include "../world/Location.hpp" #include "DataSerialiserTag.h" #include "Endianness.h" #include "MemoryStream.h" @@ -292,3 +293,31 @@ template struct DataSerializerTraitsWrite("}", 1); } }; + +template<> struct DataSerializerTraits +{ + static void encode(IStream* stream, const MapRange& v) + { + stream->WriteValue(ByteSwapBE(v.LeftTop.x)); + stream->WriteValue(ByteSwapBE(v.LeftTop.y)); + stream->WriteValue(ByteSwapBE(v.RightBottom.x)); + stream->WriteValue(ByteSwapBE(v.RightBottom.y)); + } + static void decode(IStream* stream, MapRange& v) + { + auto l = ByteSwapBE(stream->ReadValue()); + auto t = ByteSwapBE(stream->ReadValue()); + auto r = ByteSwapBE(stream->ReadValue()); + auto b = ByteSwapBE(stream->ReadValue()); + v = MapRange(l, t, r, b); + } + static void log(IStream* stream, const MapRange& v) + { + char coords[128] = {}; + snprintf( + coords, sizeof(coords), "MapRange(l = %d, t = %d, r = %d, b = %d)", v.LeftTop.x, v.LeftTop.y, v.RightBottom.x, + v.RightBottom.y); + + stream->Write(coords, strlen(coords)); + } +}; diff --git a/src/openrct2/paint/VirtualFloor.cpp b/src/openrct2/paint/VirtualFloor.cpp index a4b2c84195..43b4cb3b95 100644 --- a/src/openrct2/paint/VirtualFloor.cpp +++ b/src/openrct2/paint/VirtualFloor.cpp @@ -290,10 +290,10 @@ static void virtual_floor_get_tile_properties( void virtual_floor_paint(paint_session* session) { static constexpr const CoordsXY scenery_half_tile_offsets[4] = { - { -32, 0 }, - { 0, 32 }, - { 32, 0 }, - { 0, -32 }, + CoordsXY{ -32, 0 }, + CoordsXY{ 0, 32 }, + CoordsXY{ 32, 0 }, + CoordsXY{ 0, -32 }, }; if (_virtualFloorHeight < MINIMUM_LAND_HEIGHT) diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index 950a2937c6..66cf5e71d9 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -11,6 +11,8 @@ #include "../common.h" +#include + #define LOCATION_NULL ((int16_t)(uint16_t)0x8000) #define RCT_XY8_UNDEFINED 0xFFFF #define MakeXY16(x, y) \ @@ -59,7 +61,15 @@ constexpr int32_t COORDS_NULL = -1; */ struct CoordsXY { - int32_t x, y; + int32_t x = 0; + int32_t y = 0; + + CoordsXY() = default; + constexpr CoordsXY(int32_t _x, int32_t _y) + : x(_x) + , y(_y) + { + } }; struct TileCoordsXY @@ -86,7 +96,17 @@ struct TileCoordsXY struct CoordsXYZ { - int32_t x, y, z; + int32_t x = 0; + int32_t y = 0; + int32_t z = 0; + + CoordsXYZ() = default; + constexpr CoordsXYZ(int32_t _x, int32_t _y, int32_t _z) + : x(_x) + , y(_y) + , z(_z) + { + } }; struct TileCoordsXYZ @@ -150,3 +170,47 @@ struct TileCoordsXYZD return x == COORDS_NULL; }; }; + +/** + * Represents a rectangular range of the map using regular coordinates (32 per tile). + */ +struct MapRange +{ + CoordsXY LeftTop; + CoordsXY RightBottom; + + int32_t GetLeft() const + { + return LeftTop.x; + } + int32_t GetTop() const + { + return LeftTop.y; + } + int32_t GetRight() const + { + return RightBottom.x; + } + int32_t GetBottom() const + { + return RightBottom.y; + } + + MapRange() + : MapRange(0, 0, 0, 0) + { + } + MapRange(int32_t left, int32_t top, int32_t right, int32_t bottom) + : LeftTop(left, top) + , RightBottom(right, bottom) + { + } + + MapRange Normalise() const + { + auto result = MapRange( + std::min(GetLeft(), GetRight()), std::min(GetTop(), GetBottom()), std::max(GetLeft(), GetRight()), + std::max(GetTop(), GetBottom())); + return result; + } +}; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 41a2cf90ea..37bdc90f4b 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -873,203 +873,6 @@ void game_command_set_large_scenery_colour( *ebx = 0; } -// This will cause clear scenery to remove paths -// This should be a flag for the game command which can be set via a checkbox on the clear scenery window. -// #define CLEAR_SCENERY_REMOVES_PATHS - -/** - * - * rct2: 0x0068DFE4 - */ -static money32 map_clear_scenery_from_tile(int32_t x, int32_t y, int32_t clear, int32_t flags) -{ - int32_t type; - money32 totalCost; - TileElement* tileElement; - - totalCost = 0; - -restart_from_beginning: - tileElement = map_get_first_element_at(x, y); - do - { - type = tileElement->GetType(); - switch (type) - { - case TILE_ELEMENT_TYPE_PATH: - if (clear & (1 << 2)) - { - auto footpathRemoveAction = FootpathRemoveAction(x * 32, y * 32, tileElement->base_height); - footpathRemoveAction.SetFlags(flags); - auto res - = ((flags & GAME_COMMAND_FLAG_APPLY) ? footpathRemoveAction.Execute() : footpathRemoveAction.Query()); - if (res->Error == GA_ERROR::OK) - { - totalCost += res->Cost; - } - else - { - return MONEY32_UNDEFINED; - } - - if (flags & GAME_COMMAND_FLAG_APPLY) - goto restart_from_beginning; - } - break; - case TILE_ELEMENT_TYPE_SMALL_SCENERY: - if (clear & (1 << 0)) - { - auto removeSceneryAction = SceneryRemoveSmallAction( - x * 32, y * 32, tileElement->base_height, tileElement->AsSmallScenery()->GetSceneryQuadrant(), - tileElement->AsSmallScenery()->GetEntryIndex()); - removeSceneryAction.SetFlags(flags); - - auto res - = ((flags & GAME_COMMAND_FLAG_APPLY) ? removeSceneryAction.Execute() : removeSceneryAction.Query()); - if (res->Error != GA_ERROR::OK) - return MONEY32_UNDEFINED; - - totalCost += res->Cost; - - if (flags & GAME_COMMAND_FLAG_APPLY) - goto restart_from_beginning; - } - break; - case TILE_ELEMENT_TYPE_WALL: - if (clear & (1 << 0)) - { - // NOTE: We execute the game action directly as this function is already called from such. - TileCoordsXYZD wallLocation = { x, y, tileElement->base_height, tileElement->GetDirection() }; - auto wallRemoveAction = WallRemoveAction(wallLocation); - wallRemoveAction.SetFlags(flags); - auto res = ((flags & GAME_COMMAND_FLAG_APPLY) ? wallRemoveAction.Execute() : wallRemoveAction.Query()); - if (res->Error == GA_ERROR::OK) - { - totalCost += res->Cost; - } - } - break; - case TILE_ELEMENT_TYPE_LARGE_SCENERY: - if (clear & (1 << 1)) - { - auto removeSceneryAction = SceneryRemoveLargeAction( - x * 32, y * 32, tileElement->base_height, tileElement->GetDirection(), - tileElement->AsLargeScenery()->GetSequenceIndex()); - removeSceneryAction.SetFlags(flags | GAME_COMMAND_FLAG_PATH_SCENERY); - - auto res - = ((flags & GAME_COMMAND_FLAG_APPLY) ? removeSceneryAction.Execute() : removeSceneryAction.Query()); - if (res->Error != GA_ERROR::OK) - return MONEY32_UNDEFINED; - - totalCost += res->Cost; - - if (flags & GAME_COMMAND_FLAG_APPLY) - goto restart_from_beginning; - } - break; - } - } while (!(tileElement++)->IsLastForTile()); - - return totalCost; -} - -/** - * Function to clear the flag that is set to prevent cost duplication - * when using the clear scenery tool with large scenery. - */ -static void map_reset_clear_large_scenery_flag() -{ - TileElement* tileElement; - // TODO: Improve efficiency of this - for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++) - { - for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++) - { - tileElement = map_get_first_element_at(x, y); - do - { - if (tileElement->GetType() == TILE_ELEMENT_TYPE_LARGE_SCENERY) - { - tileElement->flags &= ~(1 << 6); - } - } while (!(tileElement++)->IsLastForTile()); - } - } -} - -money32 map_clear_scenery(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t clear, int32_t flags) -{ - int32_t x, y, z; - money32 totalCost, cost; - bool noValidTiles; - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - - x = (x0 + x1) / 2 + 16; - y = (y0 + y1) / 2 + 16; - z = tile_element_height(x, y); - gCommandPosition.x = x; - gCommandPosition.y = y; - gCommandPosition.z = z; - - x0 = std::max(x0, 32); - y0 = std::max(y0, 32); - x1 = std::min(x1, (int32_t)gMapSizeMaxXY); - y1 = std::min(y1, (int32_t)gMapSizeMaxXY); - - noValidTiles = true; - totalCost = 0; - for (y = y0; y <= y1; y += 32) - { - for (x = x0; x <= x1; x += 32) - { - if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode - || map_is_location_owned_or_has_rights(x, y)) - { - cost = map_clear_scenery_from_tile(x / 32, y / 32, clear, flags); - if (cost != MONEY32_UNDEFINED) - { - noValidTiles = false; - totalCost += cost; - } - } - else - { - gGameCommandErrorText = STR_LAND_NOT_OWNED_BY_PARK; - } - } - } - - if (gGameCommandNestLevel == 1 && flags & GAME_COMMAND_FLAG_APPLY) - { - LocationXYZ16 coord; - coord.x = ((x0 + x1) / 2) + 16; - coord.y = ((y0 + y1) / 2) + 16; - coord.z = tile_element_height(coord.x, coord.y); - network_set_player_last_action_coord(network_get_player_index(game_command_playerid), coord); - } - - if (clear & (1 << 1)) - { - map_reset_clear_large_scenery_flag(); - } - - return noValidTiles ? MONEY32_UNDEFINED : totalCost; -} - -/** - * - * rct2: 0x0068DF91 - */ -void game_command_clear_scenery( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, int32_t* edi, int32_t* ebp) -{ - *ebx = map_clear_scenery( - (int16_t)(*eax & 0xFFFF), (int16_t)(*ecx & 0xFFFF), (int16_t)(*edi & 0xFFFF), (int16_t)(*ebp & 0xFFFF), *edx, - *ebx & 0xFF); -} - /** * * rct2: 0x00663CCD diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index cee7ab1607..e0fa34a4ab 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -197,8 +197,6 @@ void game_command_set_large_scenery_colour( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_set_banner_colour( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -void game_command_clear_scenery( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_change_surface_style( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_raise_land(int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); From b01c93ba4ce688ebaac77098a6eb9732e2265e31 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 2 Jan 2019 13:59:42 +0100 Subject: [PATCH 4/6] Normalise replays. --- test/tests/testdata/replays/issue5953.sv6r | Bin 491644 -> 491828 bytes test/tests/testdata/replays/issue6807.sv6r | Bin 491457 -> 491784 bytes test/tests/testdata/replays/issue7828.sv6r | Bin 515735 -> 515920 bytes test/tests/testdata/replays/issue7867.sv6r | Bin 493685 -> 494048 bytes test/tests/testdata/replays/issue8203.sv6r | Bin 467529 -> 467719 bytes test/tests/testdata/replays/issue8216.sv6r | Bin 507362 -> 507544 bytes test/tests/testdata/replays/issue8345.sv6r | Bin 465875 -> 466058 bytes test/tests/testdata/replays/issue8426.sv6r | Bin 469040 -> 469221 bytes 8 files changed, 0 insertions(+), 0 deletions(-) diff --git a/test/tests/testdata/replays/issue5953.sv6r b/test/tests/testdata/replays/issue5953.sv6r index 1f5ea46f030bd3b75a91fb00dc3807b66f099eb2..18ff8b47c5cacdfba5f9b84b99e24d6f12db4a7c 100644 GIT binary patch delta 681 zcmeynr~|wEbsNYW{D)=GPwbzvw>`!{EzwX`#TtQ;LCsff*#G!oxz$2z!+n7#O%gVk%4wJRn+PI$sUQSY9v(VXrC!0|Vc5 zry7vs`KM=qX@P0A?24=!3=9l{V3sBW1A`ElrNzL&AUv%Wq*!FS4@i{`0|SF7h^fNF cAO@lpS@jqg7{nn=eFg>wiS7Gp+4nI40Ga*wrvLx| delta 485 zcmdneB=@I5PCdvu$e)3cfx|%0NY7B$(1L+8v$(i4)zs3|n1O+TAx0-<2Lo&6`9}4v z>Wm5EOzBDOo#Kq`o#IUGo#M>fJH=UCE;DLPKlh47Md8ekkB^VHyMJcaW&VHQzrcTn zAO9U*KHjn5@c)KcO;?w*P7i#|5~VJgum9iSKO@tBCdU5<+L;#oS7Q7R*U7{DpYuP% zkB^U!ZTEh|65q#k+oOF=6>IyNDz@oss@ScW7zL-ltYTMWVicOrQ_Zfz#3(%dLp8g^ zbgyc59wtT+2&Vwd5e0Mj3P9dqU|`UcVPIes1B*@H16Cjo=J0KRDUf4eV3YufsW350 zf@q29dNm+pr9d2UekK8!N<{_+Mrp9%^vW7`UM5Bv2xmT+BMav6Gr?_EVPIgC0}D=n z4OSsP{Z|dh@e0!wYC*K(^qg9DMOF<421X?iQ-z698AL0xYB4Y{sz8|93=E8_(*x?* l6!`N2>>S7j`{!q diff --git a/test/tests/testdata/replays/issue6807.sv6r b/test/tests/testdata/replays/issue6807.sv6r index 81ed5cfc7bd0f8dee7d3ef386d73dd1ed21c1999..1b316d030ecbdb7ba9ad00daca3ebdb011249150 100644 GIT binary patch delta 1926 zcmX^3U$&!3PCdvu$e)3cfx|%0NY7B$(2{{Ov$(i4)y%@coPmLXAx3Ab3Il7IN2B^y zb;g}yOzrXQkHi?;ABi!wKN4f!{z#0)`aGllbh&3ND)sM}W-y(S_&@#s&Ho4f{m=gW zzrOOnL(>1E|4f#z1e*UFu$^lU0r41L9bx=0!|*@wKg)lk!v7ooyR-fO>(=}K$^V@H zcmB`#|NDP^yF255{(Qav2mT8%{&!${yx{Qv2KM8v%#!~Fmb3gn@V`O**#Aa5w*O2# z{{`aZ+1>xLv$IUEd&Xi{Uz@N0-{C(a(|;z${|DNc7W`LYkNtn)|NH+n|GWRcWBSj` z^uPFj>i?n_|6~69{!jd0^5e#Tm;d?ylmD0g&z;G^0UkGx0;Qz({7yiElai!pYf&ZUi27mZ(@PFQa6}2Si|BQ>et~&j?KO&dIkoDeT)qCn1PRB=mrJ`hW$htx{-l_;Q&!8H!(0U9Aso*s7H@`uwNc9 zFmNg`Ft9Oz{Ir>Yf#DDqLorouVPIf5Oq9y43=9lMKq~9ek{+g^+ZY%aj)IgDRJomj zf#Dbqm23@AFM*Tu4h9B><6xDb_-8<*e3131N_R3aFq{A@1!WCX6j@I(FfiN%F(sz^m$7rQ ho@QWRxCQ3(>BE$tVPIgm4Hje71Bq>4Q_U{Q0sx9lb~69~ delta 1566 zcmeBZk~{ccRz1i$$e)3cfx|%0NY7B$(1L+8v$(i4)y%@coPmLXAx0-fih;GXvr&Dk zI^#|;rW0}PkHi?;ABi!wKN4f!{z#0)`aGl7bh&3NDhg+Qe0+So-TgDWF7y8b{{{Xt z{P^$i^6`!ZhyORsYP!0db^6k0EK%x``TGAI{xdTDXJY(+pq**Ket`FsX2H7gky7_NZC6j@g>Ffd#NF(szIt6}G;7hBE1z;KO$fq|pJ zfq{XMfq}Jwfq{XUfq}t_fq`QI0|V;A}3X9DQ3=H=Os@lT9z;K_Ss`{-A3=9tlD%-}u!0?cus_hI6438KX7&sZA&IcI` zbG`xt0~;tki|t@wV0a8uRS$}BtjcyWFfcrUDZ{C17Xt&sQ-Z2?GcYhb!>X#Dfq@h5 zvONq849}62u^}Zzuqse=i0x%yV0b}L)jkFWhL;3Y?XPEGV0cAP87SIcgMvQ+60pb) z<7i-DU;{hsAOi!#8-l71F)%Q^g{!J(V8CwJVFm_mTGi+TpI`#~u{>=*+B!$<7OkW?LKU|{$}P}K3kC)Th8Uf#`V6dh6B^aG zsx!W|XUd-2F6O}4F6O}0F6O}8F6O|pUCevdc7a3O6)tP8BC`n{!jmZ^Z$W= z|5Jbeudn>?(B|Cy-+;}pJ>-AUe@V~-;ceek3-Fp8&`JeOu z&i@(zfB&y;{TE#H~zc)&;OtNzx03Z zg#URPI{*9sFF5%>=)d#-kpD(pudXis-|#>Ff6MC{{%Dm z!+(SS^ZpyCCprITT-0^d>A!v3e>1oL{A~Yu{vZCY@P8)A?Tr6Z8U8af{QvR)@BjaN zKlsELw+HyMR`oKsIT*E{y~Emm_72BL%=e*0V!o+ZQ`og>HimXix3=H=m d%w`4#hWij^3j+hg0}xY%iQ(b&<9FFF008Zw-NgU^ delta 254 zcmcbxPk#DddG#RYAb$o%1`Y!~BRxZ1LkkAZ%;MtGRC5a>3kC)Th8UgneGII3mN%+z zRcCx_&$MYyyO;xGyO;x0yO;xWyO;yZb}GgiBDhg+Qe0+So-TgDWF7y8b z{{{Xt{P^$i^6`!ZhyORsYP!0db(%kGl(A&K{(p!6j73sLt6f} zudn>?(Dt86srkPFn_qj#|Dyj)jIWL`{+D6+ANZf;zfs};5C7fR{{MCB{r}{D&i_0A zXZ-*DzrNj_@jrjQ-v0yt1sMN3Fg;#y_TC1$|2zC=Wcts<`2RpV z(}Mp>?6LnZ{D1$y=70D9cTE48nf@35PyJu?;(yG4-~WmKOMcw=@A5zYfAas*|G5+X z=WXcx@BhExQx{|f(w1VGLU{J;4B!vB{b4iWq>@c$FUT<8A= z|L6Tra{jNZ%DAZOs?&e_w*O{s|M}Ve^ZY;jU*Z2uki!}OvoQQ;G-KU<?MT!3q?r4j=-I*&Z-3upVGwU}s=pV12;Iz`*jGfq~&M zQ7Zp1FfcqJO66Y$28O5gL@E8pz`*c~ph{K-2A2N}3=GeSQOOGO=?lhsLcV8ZU|43#SHXI4uCFWMW`octw;-W(Ed^*NhDH*aIKMP!(h4Q49s8g7-uj%E7?E@PR0moD2*MA3-YXu>~oL^;`@L44*(s(N!K` zU|>~XU;rmp2axZ%85kHo6Qz=efq~%*SS2X_8IV#whM~L+3=ChvNS@ExKOWIw`COr-)03=BUYN*NfC9Ezz@kb!~WCs8Ve7#J9S zK~>h{H&mE`f#Ek)DY8no1_lO@pV$__{3OD_!0?ACm7)v`41ZxN>yi9~X{Z_|#s_G7A4U|?Y6z@n0M0mQLvplsRzO8JTm42+z}Dq;3xDpg`& zVB|tp3bh|or7{BpBR5ehRTvl;c~DeB?FShOs`0=s1qZ1r0|O&3ic*OEm@3s67#R78 zQmM|sz{n3$3CdQW(Y!Z9h`Q+J2;pZTgWac3H;4=@XmT zg@xD_FfgzwFfcGkF)*46L9KD<`Om zk%57sf}kpppDUrN>Tz4i%)r1<1yu%D1#$?A!&n#?7^(@X0%@zkrm7yrFg6AThFWB0 z4N$+sR4oAUL7`GdP!$IQ14BJQRrQ<<3=AM!*kHl$0J4IC0UrDbAU+oZ14ARSVOUjh zGcYhT5md#)z`)Q9Q&kU&ajb^%GB7Z-z?9)s#mB(F&`MAhKLZ0p8%WgwXc_}0XHcA2 z)iW@Fk}WIP2?7iZ4DDEzA*&K(U|{GVs7i=|fuWP2Dq&CzbuoZaI@D#LgbsEY0|UDP z0|P7Ar6LRr4BZ4(i83%S^bk}f#=yYP3s+SS&082&iZd`U^ud+kQYFE_z|ar!Wdo-3 zLFER-`H~C_3=^=cs%JnblVV_Cn222&k}7Ei28KxlRmm_gFia+>N*0turht?&K-~`x zZb<3}m3feKA;-YLFqNPxc?JfCX#`b)ESQc^B?FCNbSo7Z7#L1BZd0k)ENhp(O)nW^r+8s)dn(F#`hwLyXQ=7Y0_vSsT^0 zr!uAYG>1%W51Go?9x|0_d&pE~zZZ=9(-+sWs3gB*n!$8R;{WvjH~$~__domh|N6@R z4oUxu{xey=5@`N!z;>=Z1jJ)}b%gQ148#Ax|1AHF3jYWEcW3+m*RA*elm9vY@BE+f z|M&m;c6Y}A{P}wS5BwKk{O`c@c){WS4eZBTnWsOmWr?b<&Da0$@Slx4C;l(_apS+s|NQ^S|4aYpPWYd< zq4U50|ALeMgZ?}J5BYDz_3G;4{}=v8{$KXL=*NGi!2gT?FZ_QA;t;|A0{=h3%>D4+ z;Qze;N&0He{}~r`U3L0z-}c|k?LR-;f1dw`|112T3358)e{qKY>Kj#lV zF~;pBbu8VBm^GxXwKFNQwlgWRO=nVMw_;+Ho^GeeuE@kFGd)p}U4@BJc6vLQmYcp- Hk$nyTk!a9B delta 222 zcmZoaCUf$LjCzoBkUs+>1BZd0k)ENhp#=kHW^r+8s)dn(F#`hwLyS&b4g;&gosH_+ zQ<+wFH-}7Z51Go?9x|0_d&pE~zZZ;J(-+sWs3@HI@$vETcK6Thy3GF%{1^Do@Z-P3 z%f~ww9RA-htLf@;*6CVxEK$ai`TGAI{xdTDXJY(+pq**KeRGxMF+W{=wf%r1Yx@C3w&@2H*{zruxTgP6WLIQj;GQn8 U#IC}`z%$(yO!H39R$`w60N|!ug#Z8m diff --git a/test/tests/testdata/replays/issue8216.sv6r b/test/tests/testdata/replays/issue8216.sv6r index 2893f2f81f006a5a6440d00ebda305ecae38f6d4..ec4b0f930af33a5b86cef00bce53f5d1b4677b54 100644 GIT binary patch delta 583 zcmaF#TW-c*IrSjtAb$o%1`Y!~BRxZ1LrVtE%;MtGR0|_RGX@3*h8Uf#-VCfePB*G= zRcE|!!uX_}-ITGN-IS@F-IRGdyD7`oFO2%r_iD1L#J*#i!E{RE|MdSi{~!4GKlS(j z`pW+fZU4EHn*STH`L&1qFZ$2K`05Dbe;J1Vf&W?l8x{R`XZ!!xt@r;HH7&&c$jiShq|cBTdY zmDpqdU-UoGc)}!{-654=*9n-|Gxhd|Cju@@!#ct{{Q6vrT=p${LkCa z`QQJ4!O8zY|DFGb{5Rryb#<}F{{{aA1wd{K{J;4B!vB{b?hyPh@c$Fc*bn~={?GfL zO{`0f_=lOs5zrz2SAeS@#w_y0s%*WnS zmhF?YSeNxOuaH%2x8A|pZoPwTy7dlrYexC$wUW>;l2*nYqAS!D591s;fU1t}&BI_vz2F94_FF+!()A@F>%QD7+BvcvWr|;X% zF3Eb1fq^k$dciJsRnA0^ml+%ww5NaA$u7xyfq{WBY5E?JOfpo410r*Yfq^k)I>&By zRmRlmdb`1BZd0k)ENhp(O)nW^r+8s)ezMDFXuoLyXSWPzF{hp^fT) zCNuH1HLFf(SDnJxt~!NjyXq9?+J}t#(-)VrsKmTun!$8R;{WvjH~$~__h0t+|N6@R z4sHLrl$!q=u=%xz{4e^?#Q5sS|F!?~{~!GK-}(3ddg=e}Z2$kV%wzcf8F#KmVvt!$yQ^q2+n7L8% zQhTE$YkQ+4+w?|Bb}J@E)9HI9*;SYr&89yF)8^9`O0g@lb}%q7T0oec3=E8x5M~zx a1EUp$+0DSfXbobjFfrO}KQ6`2!w3LH>d*cF delta 276 zcmeC$DRX(djCzoBkUs+>1BZd0k)ENhp#=kHW^r+8s)ezMDFXuoLyV5iK?YXI=#A=s zCNqV%Hmgo)SDnJxt~!NjyXq9?+J}r<(-)Vrs3@HI@$vETcK6Thy3GF%{1^Do@Z-P3 z%f~ww9RA-htLf@;*6GS+EK%B$`TGAI{xdTDXJY(+pq**Ke5M~bp0|Wo|I%#$uMgU9a BS&RSx diff --git a/test/tests/testdata/replays/issue8426.sv6r b/test/tests/testdata/replays/issue8426.sv6r index 0055e5a2d12747f0aa46509b423ad19d56e17b1e..389ed0e180923e020a16effcfc4275b10602fcca 100644 GIT binary patch delta 370 zcmdmRLFVa28TBCNAb$o%1`Y!~BRxZ1LrVtE%;MtGR0|U$GX@3*h8Uf#(G08_rW@7$ zrZV1dE}Pn3HkGlxY%0_CvZ>6`?-=!`UutGiiG9a3gXxsS|LOm4{y*^Vf9mi5^_Bk} z+Ws>sHUBqY^J@?JU-X}e@zoK=|1u2!1OK!9H!Aw?&i4PWTkroT|8xG|`9I_T@Bj7f z?u`HW^Y#88_%Fct-+}4zg2VqC*pIg|PZw)piK?&7*Z=SEpONW56XX8_?Mw^)E3wD^ zzwrP4|C;~Z|KBnFXJ-0e{6F=7(To2v|9$@_{xA7)gr;T|4jckO8hT+5cq%b|AqfAL7XA@U*P{In5iHB8~mU5Kgs#O ziU#ANuB%S}?c4sFx&7y7`_J?L@PCE>GeHh#{4dM!pT*3MZTsvN7LLVCO()xzs From 9f613833ce88bd4b967cde088615648af2e4fecf Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 3 Jan 2019 02:20:35 +0100 Subject: [PATCH 5/6] Rename actions. --- src/openrct2-ui/interface/ViewportInteraction.cpp | 8 ++++---- src/openrct2-ui/title/TitleSequencePlayer.cpp | 2 +- src/openrct2-ui/windows/Sign.cpp | 4 ++-- src/openrct2/actions/ClearAction.hpp | 8 ++++---- src/openrct2/actions/GameActionRegistration.cpp | 8 ++++---- ...RemoveLargeAction.hpp => LargeSceneryRemoveAction.hpp} | 6 +++--- ...RemoveSmallAction.hpp => SmallSceneryRemoveAction.hpp} | 6 +++--- src/openrct2/paint/VirtualFloor.cpp | 8 ++++---- src/openrct2/ride/TrackDesign.cpp | 8 ++++---- src/openrct2/world/Map.cpp | 6 +++--- src/openrct2/world/Scenery.cpp | 8 ++++---- 11 files changed, 36 insertions(+), 36 deletions(-) rename src/openrct2/actions/{SceneryRemoveLargeAction.hpp => LargeSceneryRemoveAction.hpp} (98%) rename src/openrct2/actions/{SceneryRemoveSmallAction.hpp => SmallSceneryRemoveAction.hpp} (96%) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 606ec30598..e9444b2f85 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -467,7 +467,7 @@ int32_t viewport_interaction_right_click(int32_t x, int32_t y) */ static void viewport_interaction_remove_scenery(TileElement* tileElement, int32_t x, int32_t y) { - auto removeSceneryAction = SceneryRemoveSmallAction( + auto removeSceneryAction = SmallSceneryRemoveAction( x, y, tileElement->base_height, tileElement->AsSmallScenery()->GetSceneryQuadrant(), tileElement->AsSmallScenery()->GetEntryIndex()); @@ -575,7 +575,7 @@ static void viewport_interaction_remove_large_scenery(TileElement* tileElement, } else { - auto removeSceneryAction = SceneryRemoveLargeAction( + auto removeSceneryAction = LargeSceneryRemoveAction( x, y, tileElement->base_height, tileElement->GetDirection(), tileElement->AsLargeScenery()->GetSequenceIndex()); GameActions::Execute(&removeSceneryAction); } diff --git a/src/openrct2-ui/title/TitleSequencePlayer.cpp b/src/openrct2-ui/title/TitleSequencePlayer.cpp index 05872d80d8..30aef26573 100644 --- a/src/openrct2-ui/title/TitleSequencePlayer.cpp +++ b/src/openrct2-ui/title/TitleSequencePlayer.cpp @@ -57,7 +57,7 @@ private: int32_t _lastScreenWidth = 0; int32_t _lastScreenHeight = 0; - CoordsXY _viewCentreLocation; + CoordsXY _viewCentreLocation = {}; public: explicit TitleSequencePlayer(IScenarioRepository& scenarioRepository, GameState& gameState) diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 1eeda799c3..c8a9705e91 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -231,7 +231,7 @@ static void window_sign_mouseup(rct_window* w, rct_widgetindex widgetIndex) tile_element++; } - auto sceneryRemoveAction = SceneryRemoveLargeAction( + auto sceneryRemoveAction = LargeSceneryRemoveAction( x, y, tile_element->base_height, tile_element->GetDirection(), tile_element->AsLargeScenery()->GetSequenceIndex()); GameActions::Execute(&sceneryRemoveAction); diff --git a/src/openrct2/actions/ClearAction.hpp b/src/openrct2/actions/ClearAction.hpp index 8406832fd6..ba5e28ddee 100644 --- a/src/openrct2/actions/ClearAction.hpp +++ b/src/openrct2/actions/ClearAction.hpp @@ -19,8 +19,8 @@ #include "../world/Map.h" #include "FootpathRemoveAction.hpp" #include "GameAction.h" -#include "SceneryRemoveLargeAction.hpp" -#include "SceneryRemoveSmallAction.hpp" +#include "LargeSceneryRemoveAction.hpp" +#include "SmallSceneryRemoveAction.hpp" #include "WallRemoveAction.hpp" #include @@ -166,7 +166,7 @@ private: case TILE_ELEMENT_TYPE_SMALL_SCENERY: if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_SMALL) { - auto removeSceneryAction = SceneryRemoveSmallAction( + auto removeSceneryAction = SmallSceneryRemoveAction( x * 32, y * 32, tileElement->base_height, tileElement->AsSmallScenery()->GetSceneryQuadrant(), tileElement->AsSmallScenery()->GetEntryIndex()); removeSceneryAction.SetFlags(GetFlags()); @@ -197,7 +197,7 @@ private: case TILE_ELEMENT_TYPE_LARGE_SCENERY: if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_LARGE) { - auto removeSceneryAction = SceneryRemoveLargeAction( + auto removeSceneryAction = LargeSceneryRemoveAction( x * 32, y * 32, tileElement->base_height, tileElement->GetDirection(), tileElement->AsLargeScenery()->GetSequenceIndex()); removeSceneryAction.SetFlags(GetFlags() | GAME_COMMAND_FLAG_PATH_SCENERY); diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index a350c15982..e769d1ff9e 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -13,6 +13,7 @@ #include "FootpathRemoveAction.hpp" #include "GameAction.h" #include "GuestSetNameAction.hpp" +#include "LargeSceneryRemoveAction.hpp" #include "MazeSetTrackAction.hpp" #include "ParkMarketingAction.hpp" #include "ParkSetLoanAction.hpp" @@ -25,10 +26,9 @@ #include "RideSetColourScheme.hpp" #include "RideSetName.hpp" #include "RideSetStatus.hpp" -#include "SceneryRemoveLargeAction.hpp" -#include "SceneryRemoveSmallAction.hpp" #include "SetParkEntranceFeeAction.hpp" #include "SignSetNameAction.hpp" +#include "SmallSceneryRemoveAction.hpp" #include "StaffSetColourAction.hpp" #include "StaffSetNameAction.hpp" #include "WallRemoveAction.hpp" @@ -58,8 +58,8 @@ namespace GameActions Register(); Register(); Register(); - Register(); - Register(); + Register(); + Register(); Register(); } } // namespace GameActions diff --git a/src/openrct2/actions/SceneryRemoveLargeAction.hpp b/src/openrct2/actions/LargeSceneryRemoveAction.hpp similarity index 98% rename from src/openrct2/actions/SceneryRemoveLargeAction.hpp rename to src/openrct2/actions/LargeSceneryRemoveAction.hpp index 50c79b010e..e3d8cc4d97 100644 --- a/src/openrct2/actions/SceneryRemoveLargeAction.hpp +++ b/src/openrct2/actions/LargeSceneryRemoveAction.hpp @@ -23,7 +23,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(SceneryRemoveLargeAction, GAME_COMMAND_REMOVE_LARGE_SCENERY, GameActionResult) +DEFINE_GAME_ACTION(LargeSceneryRemoveAction, GAME_COMMAND_REMOVE_LARGE_SCENERY, GameActionResult) { private: int16_t _x; @@ -33,9 +33,9 @@ private: uint16_t _tileIndex; public: - SceneryRemoveLargeAction() = default; + LargeSceneryRemoveAction() = default; - SceneryRemoveLargeAction(int16_t x, int16_t y, uint8_t baseHeight, uint8_t direction, uint16_t tileIndex) + LargeSceneryRemoveAction(int16_t x, int16_t y, uint8_t baseHeight, uint8_t direction, uint16_t tileIndex) : _x(x) , _y(y) , _baseHeight(baseHeight) diff --git a/src/openrct2/actions/SceneryRemoveSmallAction.hpp b/src/openrct2/actions/SmallSceneryRemoveAction.hpp similarity index 96% rename from src/openrct2/actions/SceneryRemoveSmallAction.hpp rename to src/openrct2/actions/SmallSceneryRemoveAction.hpp index 49e4d8e043..60d6ab1925 100644 --- a/src/openrct2/actions/SceneryRemoveSmallAction.hpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.hpp @@ -23,7 +23,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(SceneryRemoveSmallAction, GAME_COMMAND_REMOVE_SCENERY, GameActionResult) +DEFINE_GAME_ACTION(SmallSceneryRemoveAction, GAME_COMMAND_REMOVE_SCENERY, GameActionResult) { private: int16_t _x; @@ -33,9 +33,9 @@ private: uint8_t _sceneryType; public: - SceneryRemoveSmallAction() = default; + SmallSceneryRemoveAction() = default; - SceneryRemoveSmallAction(int16_t x, int16_t y, uint8_t baseHeight, uint8_t quadrant, uint8_t sceneryType) + SmallSceneryRemoveAction(int16_t x, int16_t y, uint8_t baseHeight, uint8_t quadrant, uint8_t sceneryType) : _x(x) , _y(y) , _baseHeight(baseHeight) diff --git a/src/openrct2/paint/VirtualFloor.cpp b/src/openrct2/paint/VirtualFloor.cpp index 43b4cb3b95..a4b2c84195 100644 --- a/src/openrct2/paint/VirtualFloor.cpp +++ b/src/openrct2/paint/VirtualFloor.cpp @@ -290,10 +290,10 @@ static void virtual_floor_get_tile_properties( void virtual_floor_paint(paint_session* session) { static constexpr const CoordsXY scenery_half_tile_offsets[4] = { - CoordsXY{ -32, 0 }, - CoordsXY{ 0, 32 }, - CoordsXY{ 32, 0 }, - CoordsXY{ 0, -32 }, + { -32, 0 }, + { 0, 32 }, + { 32, 0 }, + { 0, -32 }, }; if (_virtualFloorHeight < MINIMUM_LAND_HEIGHT) diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 541cd653a9..6a32094701 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -12,8 +12,8 @@ #include "../Cheats.h" #include "../Game.h" #include "../OpenRCT2.h" -#include "../actions/SceneryRemoveLargeAction.hpp" -#include "../actions/SceneryRemoveSmallAction.hpp" +#include "../actions/LargeSceneryRemoveAction.hpp" +#include "../actions/SmallSceneryRemoveAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../audio/audio.h" #include "../core/File.h" @@ -831,7 +831,7 @@ static int32_t track_design_place_scenery( z = (scenery->z * 8 + originZ) / 8; - auto removeSceneryAction = SceneryRemoveSmallAction(mapCoord.x, mapCoord.y, z, quadrant, entry_index); + auto removeSceneryAction = SmallSceneryRemoveAction(mapCoord.x, mapCoord.y, z, quadrant, entry_index); removeSceneryAction.SetFlags(flags); removeSceneryAction.Execute(); @@ -841,7 +841,7 @@ static int32_t track_design_place_scenery( { z = (scenery->z * 8 + originZ) / 8; - auto removeSceneryAction = SceneryRemoveLargeAction( + auto removeSceneryAction = LargeSceneryRemoveAction( mapCoord.x, mapCoord.y, z, (rotation + scenery->flags) & 0x3, 0); removeSceneryAction.SetFlags(flags); removeSceneryAction.Execute(); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 37bdc90f4b..a7a40a7393 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -15,8 +15,8 @@ #include "../Input.h" #include "../OpenRCT2.h" #include "../actions/FootpathRemoveAction.hpp" -#include "../actions/SceneryRemoveLargeAction.hpp" -#include "../actions/SceneryRemoveSmallAction.hpp" +#include "../actions/LargeSceneryRemoveAction.hpp" +#include "../actions/SmallSceneryRemoveAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../audio/audio.h" #include "../config/Config.h" @@ -3503,7 +3503,7 @@ static void clear_element_at(int32_t x, int32_t y, TileElement** elementPtr) break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: { - auto removeSceneryAction = SceneryRemoveLargeAction( + auto removeSceneryAction = LargeSceneryRemoveAction( x, y, element->base_height, element->GetDirection(), element->AsLargeScenery()->GetSequenceIndex()); GameActions::Execute(&removeSceneryAction); } diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index efc948a249..6aed6e3766 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -12,8 +12,8 @@ #include "../Cheats.h" #include "../Context.h" #include "../Game.h" -#include "../actions/SceneryRemoveLargeAction.hpp" -#include "../actions/SceneryRemoveSmallAction.hpp" +#include "../actions/LargeSceneryRemoveAction.hpp" +#include "../actions/SmallSceneryRemoveAction.hpp" #include "../actions/WallRemoveAction.hpp" #include "../common.h" #include "../localisation/Localisation.h" @@ -187,7 +187,7 @@ void scenery_remove_ghost_tool_placement() { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_0; - auto removeSceneryAction = SceneryRemoveSmallAction(x, y, z, gSceneryQuadrant, gSceneryPlaceObject); + auto removeSceneryAction = SmallSceneryRemoveAction(x, y, z, gSceneryQuadrant, gSceneryPlaceObject); removeSceneryAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST); removeSceneryAction.Execute(); } @@ -226,7 +226,7 @@ void scenery_remove_ghost_tool_placement() { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_3; - auto removeSceneryAction = SceneryRemoveLargeAction(x, y, z, gSceneryPlaceRotation, 0); + auto removeSceneryAction = LargeSceneryRemoveAction(x, y, z, gSceneryPlaceRotation, 0); removeSceneryAction.SetFlags( GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5); removeSceneryAction.Execute(); From 0d2fd33fd8ac8dc775b8d99642e2deed81db176b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 5 Jan 2019 20:18:21 +0100 Subject: [PATCH 6/6] Bump network version Co-Authored-By: ZehMatt --- src/openrct2/network/Network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index a58661a970..d3713b59ab 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -30,7 +30,7 @@ // This string specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "19" +#define NETWORK_STREAM_VERSION "20" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static rct_peep* _pickup_peep = nullptr;