From b0f7435e9dd273928ff35139ea96d73a84560631 Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Sun, 10 Dec 2017 10:06:32 +0100 Subject: [PATCH 1/8] Refactor GAME_COMMAND_REMOVE_WALL to game action. --- src/openrct2-ui/windows/Sign.cpp | 9 +- src/openrct2/Game.h | 2 +- src/openrct2/actions/GameActionCompat.cpp | 34 +++++ .../actions/GameActionRegistration.cpp | 2 + src/openrct2/actions/WallRemoveAction.hpp | 136 ++++++++++++++++++ .../interface/ViewportInteraction.cpp | 13 +- src/openrct2/ride/TrackDesign.cpp | 10 +- src/openrct2/world/Map.cpp | 27 ++-- src/openrct2/world/Scenery.cpp | 11 +- src/openrct2/world/Wall.cpp | 82 ----------- src/openrct2/world/Wall.h | 1 + 11 files changed, 194 insertions(+), 133 deletions(-) create mode 100644 src/openrct2/actions/WallRemoveAction.hpp diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index a423ebd77a..4ebc4a0d39 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -510,14 +510,7 @@ static void window_sign_small_mouseup(rct_window *w, rct_widgetindex widgetIndex tile_element++; } gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - game_do_command( - x, - 1 | (tile_element->GetDirection() << 8), - y, - (tile_element->base_height << 8) | tile_element->GetDirection(), - GAME_COMMAND_REMOVE_WALL, - 0, - 0); + 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/Game.h b/src/openrct2/Game.h index 660bde4902..a154e57767 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -66,7 +66,7 @@ enum GAME_COMMAND GAME_COMMAND_SET_PARK_ENTRANCE_FEE, // GA GAME_COMMAND_SET_STAFF_COLOUR, // GA GAME_COMMAND_PLACE_WALL, - GAME_COMMAND_REMOVE_WALL, + GAME_COMMAND_REMOVE_WALL, // GA GAME_COMMAND_PLACE_LARGE_SCENERY, GAME_COMMAND_REMOVE_LARGE_SCENERY, GAME_COMMAND_SET_CURRENT_LOAN, // GA diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index 723a729e2a..5d6e3efddc 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -25,6 +25,7 @@ #include "RideDemolishAction.hpp" #include "PlacePeepSpawnAction.hpp" #include "MazeSetTrackAction.hpp" +#include "WallRemoveAction.hpp" #pragma region PlaceParkEntranceAction money32 place_park_entrance(sint16 x, sint16 y, sint16 z, uint8 direction) @@ -344,3 +345,36 @@ Guard::Assert(false, "GAME_COMMAND_SET_MAZE_TRACK DEPRECATED"); } #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 + */ + void game_command_remove_wall(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp) + { + Guard::Assert(false, "GAME_COMMAND_REMOVE_WALL DEPRECATED"); + } +#pragma endregion diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index 7d6f18fc57..cbdaf6673d 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -32,6 +32,7 @@ #include "SignSetNameAction.hpp" #include "ParkSetNameAction.hpp" #include "BannerSetNameAction.hpp" +#include "WallRemoveAction.hpp" namespace GameActions { @@ -54,5 +55,6 @@ namespace GameActions Register(); Register(); Register(); + Register(); } } // namespace GameActions diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp new file mode 100644 index 0000000000..933c85feab --- /dev/null +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -0,0 +1,136 @@ +#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers +/***************************************************************************** +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* OpenRCT2 is the work of many authors, a full list can be found in contributors.md +* For more information, visit https://github.com/OpenRCT2/OpenRCT2 +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* A full copy of the GNU General Public License can be found in licence.txt +*****************************************************************************/ +#pragma endregion + +#pragma once + +#include "../core/MemoryStream.h" +#include "../localisation/StringIds.h" +#include "GameAction.h" + +#include "../Cheats.h" +#include "../interface/Window.h" +#include "../world/Wall.h" + +struct WallRemoveAction : public GameActionBase +{ +private: + sint32 _x; + sint32 _y; + uint8 _baseHeight; + uint8 _direction; + +public: + WallRemoveAction() {} + WallRemoveAction(sint16 x, sint16 y, uint8 baseHeight, uint8 direction) : + _x(x), + _y(y), + _baseHeight(baseHeight), + _direction(direction) + { + } + + uint16 GetActionFlags() const override + { + return GameAction::GetActionFlags(); + } + + void Serialise(DataSerialiser& stream) override + { + GameAction::Serialise(stream); + + stream << _x << _y << _baseHeight << _direction; + } + + GameActionResult::Ptr Query() const override + { + GameActionResult::Ptr res = std::make_unique(); + res->Cost = 0; + res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + + if (!map_is_location_valid(_x, _y)) + { + res->Error = GA_ERROR::INVALID_PARAMETERS; + res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; + return res; + } + + const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST; + if (!isGhost && + !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && + !gCheatsSandboxMode && + !map_is_location_owned(_x, _y, _baseHeight * 8)) + { + res->Error = GA_ERROR::NOT_OWNED; + res->ErrorMessage = STR_CANT_REMOVE_THIS; + return res; + } + + rct_tile_element * wallElement = GetFirstWallElementAt(_x, _y, _baseHeight, _direction, isGhost); + if (wallElement == nullptr) + { + // NOTE: There seems to be some oddities with calling code currently trying to + // delete the same thing multiple times. + res->Error = GA_ERROR::INVALID_PARAMETERS; + res->ErrorMessage = STR_NONE; + return res; + } + + res->Cost = 0; + return res; + } + + GameActionResult::Ptr Execute() const override + { + GameActionResult::Ptr res = std::make_unique(); + res->Cost = 0; + res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; + + const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST; + + rct_tile_element * wallElement = GetFirstWallElementAt(_x, _y, _baseHeight, _direction, isGhost); + if (wallElement == nullptr) + { + res->Error = GA_ERROR::INVALID_PARAMETERS; + res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; + return res; + } + + res->Position.x = _x + 16; + res->Position.y = _y + 16; + res->Position.z = tile_element_height(res->Position.x, res->Position.y); + + tile_element_remove_banner_entry(wallElement); + map_invalidate_tile_zoom1(_x, _y, wallElement->base_height * 8, (wallElement->base_height * 8) + 72); + tile_element_remove(wallElement); + + return res; + } + +private: + rct_tile_element * GetFirstWallElementAt(sint32 x, sint32 y, uint8 baseZ, uint8 direction, bool isGhost) const + { + rct_tile_element * tileElement = map_get_first_element_at(x / 32, y / 32); + do + { + if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_WALL) continue; + if (tileElement->base_height != baseZ) continue; + if ((tile_element_get_direction(tileElement)) != direction) continue; + if (tile_element_is_ghost(tileElement) != isGhost) continue; + return tileElement; + } while (!tile_element_is_last_for_tile(tileElement++)); + return nullptr; + } +}; diff --git a/src/openrct2/interface/ViewportInteraction.cpp b/src/openrct2/interface/ViewportInteraction.cpp index 2e7408b92d..4066f63323 100644 --- a/src/openrct2/interface/ViewportInteraction.cpp +++ b/src/openrct2/interface/ViewportInteraction.cpp @@ -30,9 +30,10 @@ #include "../world/Map.h" #include "../world/Scenery.h" #include "../world/LargeScenery.h" +#include "../world/Park.h" #include "../world/Sprite.h" #include "../world/Surface.h" -#include "../world/Park.h" +#include "../world/Wall.h" #include "Viewport.h" #include "Window_internal.h" #include "../Context.h" @@ -514,15 +515,7 @@ static void viewport_interaction_remove_park_wall(rct_tile_element *tileElement, context_open_detail_window(WD_SIGN_SMALL, tileElement->properties.wall.banner_index); } else { gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - game_do_command( - x, - GAME_COMMAND_FLAG_APPLY, - y, - tile_element_get_direction(tileElement) | (tileElement->base_height << 8), - GAME_COMMAND_REMOVE_WALL, - 0, - 0 - ); + wall_remove(x, y, tileElement->base_height, tile_element_get_direction(tileElement), GAME_COMMAND_FLAG_APPLY); } } diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 0eb3006313..b7d2dde207 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -44,6 +44,7 @@ #include "../world/Scenery.h" #include "../world/SmallScenery.h" #include "../world/Surface.h" +#include "../world/Wall.h" struct map_backup { @@ -859,14 +860,7 @@ track_design_place_scenery(rct_td6_scenery_element * scenery_start, sint32 origi break; case OBJECT_TYPE_WALLS: z = (scenery->z * 8 + originZ) / 8; - game_do_command( - mapCoord.x, - flags, - mapCoord.y, - (z << 8) | ((rotation + scenery->flags) & 0x3), - GAME_COMMAND_REMOVE_WALL, - 0, - 0); + wall_remove(mapCoord.x, mapCoord.y, z, (rotation + scenery->flags) & TILE_ELEMENT_DIRECTION_MASK, flags); 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 8a9edf1104..f1b254fd41 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1100,6 +1100,7 @@ restart_from_beginning: return MONEY32_UNDEFINED; totalCost += cost; + if (flags & 1) goto restart_from_beginning; } break; @@ -1116,25 +1117,26 @@ restart_from_beginning: return MONEY32_UNDEFINED; totalCost += cost; + if (flags & 1) goto restart_from_beginning; } break; case TILE_ELEMENT_TYPE_WALL: if (clear & (1 << 0)) { - sint32 eax = x * 32; - sint32 ebx = flags; - sint32 ecx = y * 32; - sint32 edx = (tileElement->base_height << 8) | (tile_element_get_direction(tileElement)); - sint32 edi = 0, ebp = 0; - cost = game_do_command(eax, ebx, ecx, edx, GAME_COMMAND_REMOVE_WALL, edi, ebp); - + cost = wall_remove(x * 32, y * 32, tileElement->base_height, tile_element_get_direction(tileElement), flags); if (cost == MONEY32_UNDEFINED) return MONEY32_UNDEFINED; totalCost += cost; + + // NOTE (12/10/2017): This will get us stuck in an infinite loop because game actions are queued + // it seems to be trying to remove the same thing over and over. + // Leaving this here for reference. + /* if (flags & 1) goto restart_from_beginning; + */ } break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: @@ -1150,6 +1152,7 @@ restart_from_beginning: return MONEY32_UNDEFINED; totalCost += cost; + if (flags & 1) goto restart_from_beginning; @@ -3762,15 +3765,7 @@ static void clear_element_at(sint32 x, sint32 y, rct_tile_element **elementPtr) break; case TILE_ELEMENT_TYPE_WALL: gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; - game_do_command( - x, - GAME_COMMAND_FLAG_APPLY, - y, - tile_element_get_direction(element) | (element->base_height << 8), - GAME_COMMAND_REMOVE_WALL, - 0, - 0 - ); + wall_remove(x, y, tile_element_get_direction(element), element->base_height, GAME_COMMAND_FLAG_APPLY); break; case TILE_ELEMENT_TYPE_LARGE_SCENERY: gGameCommandErrorTitle = STR_CANT_REMOVE_THIS; diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 572eda9071..f8dbf8d8fe 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -30,6 +30,7 @@ #include "Park.h" #include "Scenery.h" #include "SmallScenery.h" +#include "Wall.h" uint8 gWindowSceneryActiveTabIndex; uint16 gWindowSceneryTabSelections[20]; @@ -244,14 +245,8 @@ void scenery_remove_ghost_tool_placement(){ if (gSceneryGhostType & SCENERY_ENTRY_FLAG_2){ gSceneryGhostType &= ~SCENERY_ENTRY_FLAG_2; - game_do_command( - x, - 105 | (gSceneryTileElementType << 8), - y, - gSceneryGhostWallRotation |(z << 8), - GAME_COMMAND_REMOVE_WALL, - 0, - 0); + const sint32 flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY; + wall_remove(x, y, gSceneryGhostWallRotation, z, flags); } if (gSceneryGhostType & SCENERY_ENTRY_FLAG_3){ diff --git a/src/openrct2/world/Wall.cpp b/src/openrct2/world/Wall.cpp index 0cc756c653..73d9243506 100644 --- a/src/openrct2/world/Wall.cpp +++ b/src/openrct2/world/Wall.cpp @@ -577,67 +577,6 @@ static money32 WallPlace(uint8 wallType, } } -static rct_tile_element * GetFirstWallElementAt(sint32 x, sint32 y, uint8 baseZ, uint8 direction, bool isGhost) -{ - rct_tile_element * tileElement = map_get_first_element_at(x / 32, y / 32); - do - { - if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) continue; - if (tileElement->base_height != baseZ) continue; - if ((tile_element_get_direction(tileElement)) != direction) continue; - if (tile_element_is_ghost(tileElement) != isGhost) continue; - return tileElement; - } - while (!tile_element_is_last_for_tile(tileElement++)); - return nullptr; -} - -static money32 WallRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags) -{ - if (!map_is_location_valid(x, y)) - { - return MONEY32_UNDEFINED; - } - - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - bool isGhost = (flags & GAME_COMMAND_FLAG_GHOST) != 0; - if (!isGhost && - game_is_paused() && - !gCheatsBuildInPauseMode) - { - gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - return MONEY32_UNDEFINED; - } - - if (!isGhost && - !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !gCheatsSandboxMode && - !map_is_location_owned(x, y, baseHeight * 8)) - { - return MONEY32_UNDEFINED; - } - - rct_tile_element * wallElement = GetFirstWallElementAt(x, y, baseHeight, direction, isGhost); - if (!(flags & GAME_COMMAND_FLAG_APPLY) || (wallElement == nullptr)) - { - return 0; - } - - if (gGameCommandNestLevel == 1 && !isGhost) - { - 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); - } - - tile_element_remove_banner_entry(wallElement); - map_invalidate_tile_zoom1(x, y, wallElement->base_height * 8, (wallElement->base_height * 8) + 72); - tile_element_remove(wallElement); - return 0; -} - static money32 WallSetColour(sint16 x, sint16 y, uint8 baseHeight, @@ -851,27 +790,6 @@ money32 wall_place(sint32 type, return ebx; } -/** - * - * rct2: 0x006E5597 - */ -void game_command_remove_wall(sint32 * eax, - sint32 * ebx, - sint32 * ecx, - sint32 * edx, - [[maybe_unused]] sint32 * esi, - [[maybe_unused]] sint32 * edi, - [[maybe_unused]] sint32 * ebp) -{ - *ebx = WallRemove( - *eax & 0xFFFF, - *ecx & 0xFFFF, - (*edx >> 8) & 0xFF, - *edx & 0xFF, - *ebx & 0xFF - ); -} - /** * * rct2: 0x006E56B5 diff --git a/src/openrct2/world/Wall.h b/src/openrct2/world/Wall.h index b7896a2a55..ce9f9e9fec 100644 --- a/src/openrct2/world/Wall.h +++ b/src/openrct2/world/Wall.h @@ -35,3 +35,4 @@ void wall_set_tertiary_colour(rct_tile_element * tileElement, colour_t colour); uint8 wall_get_animation_frame(const rct_tile_element * fenceElement); void wall_set_animation_frame(rct_tile_element * wallElement, uint8 frameNum); +money32 wall_remove(sint16 x, sint16 y, uint8 baseHeight, uint8 direction, uint8 flags); From 70ee22bbfadb55a72987e4573a212c48539aa43d Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Sun, 10 Dec 2017 10:06:59 +0100 Subject: [PATCH 2/8] Discard empty errors. --- src/openrct2/actions/GameAction.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index 7c31595c1b..d66d493058 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -88,6 +88,10 @@ namespace GameActions { result = factory(); } + else + { + log_error("Attempting to create unregistered gameaction: %u\n", id); + } } Guard::ArgumentNotNull(result); return std::unique_ptr(result); @@ -227,7 +231,8 @@ namespace GameActions if (result->Error != GA_ERROR::OK && !(flags & GAME_COMMAND_FLAG_GHOST) && - !(flags & GAME_COMMAND_FLAG_5)) + !(flags & GAME_COMMAND_FLAG_5) && + result->ErrorMessage != STR_NONE) { // Show the error box std::copy(result->ErrorMessageArgs.begin(), result->ErrorMessageArgs.end(), gCommonFormatArgs); From 8cb76cd969a2cad833f38cf53ab59bb1f28bb184 Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Sun, 11 Mar 2018 10:03:34 +0100 Subject: [PATCH 3/8] Use game action directly when used from different game command/action. --- src/openrct2/actions/WallRemoveAction.hpp | 19 ++++----------- src/openrct2/world/Map.cpp | 29 ++++++++++------------- src/openrct2/world/Scenery.cpp | 10 +++++--- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index 933c85feab..27d889a9fc 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -16,6 +16,7 @@ #pragma once +#include "../OpenRCT2.h" #include "../core/MemoryStream.h" #include "../localisation/StringIds.h" #include "GameAction.h" @@ -62,9 +63,7 @@ public: if (!map_is_location_valid(_x, _y)) { - res->Error = GA_ERROR::INVALID_PARAMETERS; - res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; - return res; + return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST; @@ -73,19 +72,13 @@ public: !gCheatsSandboxMode && !map_is_location_owned(_x, _y, _baseHeight * 8)) { - res->Error = GA_ERROR::NOT_OWNED; - res->ErrorMessage = STR_CANT_REMOVE_THIS; - return res; + return std::make_unique(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } rct_tile_element * wallElement = GetFirstWallElementAt(_x, _y, _baseHeight, _direction, isGhost); if (wallElement == nullptr) { - // NOTE: There seems to be some oddities with calling code currently trying to - // delete the same thing multiple times. - res->Error = GA_ERROR::INVALID_PARAMETERS; - res->ErrorMessage = STR_NONE; - return res; + return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } res->Cost = 0; @@ -103,9 +96,7 @@ public: rct_tile_element * wallElement = GetFirstWallElementAt(_x, _y, _baseHeight, _direction, isGhost); if (wallElement == nullptr) { - res->Error = GA_ERROR::INVALID_PARAMETERS; - res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; - return res; + return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } res->Position.x = _x + 16; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index f1b254fd41..1eee6cfbdb 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -37,6 +37,7 @@ #include "../scenario/Scenario.h" #include "../util/Util.h" #include "../windows/Intent.h" +#include "../actions/WallRemoveAction.hpp" #include "Banner.h" #include "Climate.h" #include "Footpath.h" @@ -1123,22 +1124,18 @@ restart_from_beginning: } break; case TILE_ELEMENT_TYPE_WALL: - if (clear & (1 << 0)) { - cost = wall_remove(x * 32, y * 32, tileElement->base_height, tile_element_get_direction(tileElement), flags); - if (cost == MONEY32_UNDEFINED) - return MONEY32_UNDEFINED; - - totalCost += cost; - - // NOTE (12/10/2017): This will get us stuck in an infinite loop because game actions are queued - // it seems to be trying to remove the same thing over and over. - // Leaving this here for reference. - /* - if (flags & 1) - goto restart_from_beginning; - */ - - } break; + if (clear & (1 << 0)) + { + // NOTE: We execute the game action directly as this function is already called from such. + auto wallRemoveAction = WallRemoveAction(x * 32, y * 32, tileElement->base_height, tile_element_get_direction(tileElement)); + 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)) { sint32 eax = x * 32; diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index f8dbf8d8fe..742bf0a84e 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -23,6 +23,7 @@ #include "../object/ObjectList.h" #include "../object/ObjectManager.h" #include "../scenario/Scenario.h" +#include "../actions/WallRemoveAction.hpp" #include "Climate.h" #include "Footpath.h" #include "Fountain.h" @@ -243,10 +244,13 @@ void scenery_remove_ghost_tool_placement(){ } while (!tile_element_is_last_for_tile(tile_element++)); } - if (gSceneryGhostType & SCENERY_ENTRY_FLAG_2){ + if (gSceneryGhostType & SCENERY_ENTRY_FLAG_2) + { gSceneryGhostType &= ~SCENERY_ENTRY_FLAG_2; - const sint32 flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY; - wall_remove(x, y, gSceneryGhostWallRotation, z, flags); + + auto wallRemoveAction = WallRemoveAction(x, y, z, gSceneryGhostWallRotation); + wallRemoveAction.SetFlags(GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY); + wallRemoveAction.Execute(); } if (gSceneryGhostType & SCENERY_ENTRY_FLAG_3){ From 5e4cdeb78be0d79c10e3cd8d8a4a8ed80b4106ae Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Sun, 22 Apr 2018 19:11:06 +0200 Subject: [PATCH 4/8] Refactor out references to compatibility function wall_remove --- src/openrct2-ui/windows/Sign.cpp | 24 ++++++++++++------- src/openrct2/actions/GameActionCompat.cpp | 22 ----------------- src/openrct2/actions/WallRemoveAction.hpp | 1 + .../interface/ViewportInteraction.cpp | 12 ++++++---- src/openrct2/ride/TrackDesign.cpp | 13 ++++++++-- src/openrct2/world/Map.cpp | 6 +++-- 6 files changed, 39 insertions(+), 39 deletions(-) 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; From 30eb844c7f7b99435d1da49e4560e5b57f3c726e Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Sun, 22 Apr 2018 19:15:05 +0200 Subject: [PATCH 5/8] Remove game_command_remove_wall and references. --- src/openrct2/Game.cpp | 2 +- src/openrct2/actions/GameActionCompat.cpp | 11 ----------- src/openrct2/world/Map.h | 1 - 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index c0eb7346f2..3d1a859832 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1743,7 +1743,7 @@ GAME_COMMAND_POINTER * new_game_command_table[GAME_COMMAND_COUNT] = { game_command_set_park_entrance_fee, nullptr, game_command_place_wall, - game_command_remove_wall, + nullptr, game_command_place_large_scenery, game_command_remove_large_scenery, nullptr, diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index d02cba5f11..ec0e948169 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -345,14 +345,3 @@ Guard::Assert(false, "GAME_COMMAND_SET_MAZE_TRACK DEPRECATED"); } #pragma endregion - -#pragma region RemoveWall - /** - * - * rct2: 0x006E5597 - */ - void game_command_remove_wall(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp) - { - Guard::Assert(false, "GAME_COMMAND_REMOVE_WALL DEPRECATED"); - } -#pragma endregion diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 853fd4b3d2..ad4617d2d3 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -199,7 +199,6 @@ void game_command_smooth_land(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx void game_command_raise_water(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_lower_water(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_set_water_height(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); -void game_command_remove_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_place_banner(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_place_scenery(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); void game_command_place_wall(sint32* eax, sint32* ebx, sint32* ecx, sint32* edx, sint32* esi, sint32* edi, sint32* ebp); From cd0530d176b10b8aaf9c0f91511ca7031b0994b3 Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Fri, 11 May 2018 23:03:19 +0200 Subject: [PATCH 6/8] Fix use of missing function. --- src/openrct2/actions/WallRemoveAction.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index 87ce9f261b..efeef2c435 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -117,10 +117,13 @@ private: rct_tile_element * tileElement = map_get_first_element_at(x / 32, y / 32); do { - if (tile_element_get_type(tileElement) != TILE_ELEMENT_TYPE_WALL) continue; + if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) + { + continue; + } if (tileElement->base_height != baseZ) continue; - if ((tile_element_get_direction(tileElement)) != direction) continue; - if (tile_element_is_ghost(tileElement) != isGhost) continue; + if (tileElement->GetDirection() != direction) continue; + if (tileElement->IsGhost() != isGhost) continue; return tileElement; } while (!tile_element_is_last_for_tile(tileElement++)); return nullptr; From 9f0d820b7cdf5ba1af867c85b26dd4d7cfc5815c Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Mon, 14 May 2018 12:36:45 +0200 Subject: [PATCH 7/8] Use TileCoordsXYZD for wall locations --- src/openrct2-ui/windows/Sign.cpp | 10 ++-- src/openrct2/actions/GameAction.cpp | 9 +--- src/openrct2/actions/WallRemoveAction.hpp | 54 +++++++++---------- .../interface/ViewportInteraction.cpp | 3 +- src/openrct2/ride/TrackDesign.cpp | 3 +- src/openrct2/world/Map.cpp | 6 ++- src/openrct2/world/Scenery.cpp | 3 +- 7 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 6c3ccaf0be..77dc7db00f 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -501,9 +501,9 @@ static void window_sign_small_mouseup(rct_window *w, rct_widgetindex widgetIndex break; case WIDX_SIGN_DEMOLISH: { - while (1) + while (true) { - if (tile_element_get_type(tile_element) == TILE_ELEMENT_TYPE_WALL) + 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) @@ -514,12 +514,14 @@ static void window_sign_small_mouseup(rct_window *w, rct_widgetindex widgetIndex } tile_element++; } - auto wallRemoveAction = WallRemoveAction(x, y, tile_element->base_height, tile_element_get_direction(tile_element)); + TileCoordsXYZD wallLocation = { x >> 5, y >> 5, tile_element->base_height, tile_element->GetDirection() }; + auto wallRemoveAction = WallRemoveAction(wallLocation); GameActions::Execute(&wallRemoveAction); } break; case WIDX_SIGN_TEXT: - if (banner->flags & BANNER_FLAG_LINKED_TO_RIDE){ + if (banner->flags & BANNER_FLAG_LINKED_TO_RIDE) + { Ride* ride = get_ride(banner->colour); set_format_arg(16, uint32, ride->name_arguments); string_id = ride->name; diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index d66d493058..83ccd1118b 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -88,12 +88,8 @@ namespace GameActions { result = factory(); } - else - { - log_error("Attempting to create unregistered gameaction: %u\n", id); - } } - Guard::ArgumentNotNull(result); + Guard::ArgumentNotNull(result, "Attempting to create unregistered gameaction: %u", id); return std::unique_ptr(result); } @@ -231,8 +227,7 @@ namespace GameActions if (result->Error != GA_ERROR::OK && !(flags & GAME_COMMAND_FLAG_GHOST) && - !(flags & GAME_COMMAND_FLAG_5) && - result->ErrorMessage != STR_NONE) + !(flags & GAME_COMMAND_FLAG_5)) { // Show the error box std::copy(result->ErrorMessageArgs.begin(), result->ErrorMessageArgs.end(), gCommonFormatArgs); diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index efeef2c435..386e2ffee0 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -16,31 +16,25 @@ #pragma once +#include "../Cheats.h" #include "../OpenRCT2.h" #include "../core/MemoryStream.h" +#include "../interface/Window.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" -#include "GameAction.h" - -#include "../Cheats.h" -#include "../interface/Window.h" +#include "../world/Location.hpp" #include "../world/Wall.h" +#include "GameAction.h" struct WallRemoveAction : public GameActionBase { private: - sint32 _x; - sint32 _y; - uint8 _baseHeight; - uint8 _direction; + TileCoordsXYZD _location; public: - WallRemoveAction() {} - WallRemoveAction(sint16 x, sint16 y, uint8 baseHeight, uint8 direction) : - _x(x), - _y(y), - _baseHeight(baseHeight), - _direction(direction) + WallRemoveAction() = default; + WallRemoveAction(const TileCoordsXYZD& location) + : _location(location) { } @@ -53,7 +47,7 @@ public: { GameAction::Serialise(stream); - stream << _x << _y << _baseHeight << _direction; + stream << _location.x << _location.y << _location.z << _location.direction; } GameActionResult::Ptr Query() const override @@ -62,7 +56,7 @@ public: res->Cost = 0; res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - if (!map_is_location_valid(_x, _y)) + if (!map_is_location_valid(_location.x << 5, _location.y << 5)) { return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } @@ -71,12 +65,12 @@ public: if (!isGhost && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && - !map_is_location_owned(_x, _y, _baseHeight * 8)) + !map_is_location_owned(_location.x << 5, _location.y << 5, _location.z << 3)) { return std::make_unique(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } - rct_tile_element * wallElement = GetFirstWallElementAt(_x, _y, _baseHeight, _direction, isGhost); + rct_tile_element* wallElement = GetFirstWallElementAt(_location, isGhost); if (wallElement == nullptr) { return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); @@ -94,36 +88,38 @@ public: const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST; - rct_tile_element * wallElement = GetFirstWallElementAt(_x, _y, _baseHeight, _direction, isGhost); + rct_tile_element * wallElement = GetFirstWallElementAt(_location, isGhost); if (wallElement == nullptr) { return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } - res->Position.x = _x + 16; - res->Position.y = _y + 16; + res->Position.x = (_location.x << 5) + 16; + res->Position.y = (_location.y << 5) + 16; res->Position.z = tile_element_height(res->Position.x, res->Position.y); tile_element_remove_banner_entry(wallElement); - map_invalidate_tile_zoom1(_x, _y, wallElement->base_height * 8, (wallElement->base_height * 8) + 72); + map_invalidate_tile_zoom1(_location.x << 5, _location.y << 5, wallElement->base_height * 8, (wallElement->base_height * 8) + 72); tile_element_remove(wallElement); return res; } private: - rct_tile_element * GetFirstWallElementAt(sint32 x, sint32 y, uint8 baseZ, uint8 direction, bool isGhost) const + rct_tile_element* GetFirstWallElementAt(const TileCoordsXYZD& location, bool isGhost) const { - rct_tile_element * tileElement = map_get_first_element_at(x / 32, y / 32); + rct_tile_element* tileElement = map_get_first_element_at(location.x, location.y); do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) - { continue; - } - if (tileElement->base_height != baseZ) continue; - if (tileElement->GetDirection() != direction) continue; - if (tileElement->IsGhost() != isGhost) continue; + if (tileElement->base_height != location.z) + continue; + if (tileElement->GetDirection() != location.direction) + continue; + if (tileElement->IsGhost() != isGhost) + continue; + return tileElement; } while (!tile_element_is_last_for_tile(tileElement++)); return nullptr; diff --git a/src/openrct2/interface/ViewportInteraction.cpp b/src/openrct2/interface/ViewportInteraction.cpp index aba520d586..3a5ad71a7b 100644 --- a/src/openrct2/interface/ViewportInteraction.cpp +++ b/src/openrct2/interface/ViewportInteraction.cpp @@ -518,7 +518,8 @@ static void viewport_interaction_remove_park_wall(rct_tile_element *tileElement, } else { - auto wallRemoveAction = WallRemoveAction(x, y, tileElement->base_height, tile_element_get_direction(tileElement)); + TileCoordsXYZD wallLocation = { x >> 5, y >> 5, tileElement->base_height, tileElement->GetDirection() }; + auto wallRemoveAction = WallRemoveAction(wallLocation); GameActions::Execute(&wallRemoveAction); } } diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 440f25c483..fdb1291d68 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -865,7 +865,8 @@ track_design_place_scenery(rct_td6_scenery_element * scenery_start, sint32 origi uint8_t direction = (rotation + scenery->flags) & TILE_ELEMENT_DIRECTION_MASK; - auto wallRemoveAction = WallRemoveAction(mapCoord.x, mapCoord.y, z, direction); + TileCoordsXYZD wallLocation = { tile.x, tile.y, z, direction }; + auto wallRemoveAction = WallRemoveAction(wallLocation); wallRemoveAction.SetFlags(flags); GameActions::Execute(&wallRemoveAction); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index c7a893643a..b3bf31cc44 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1127,7 +1127,8 @@ restart_from_beginning: if (clear & (1 << 0)) { // NOTE: We execute the game action directly as this function is already called from such. - auto wallRemoveAction = WallRemoveAction(x * 32, y * 32, tileElement->base_height, tile_element_get_direction(tileElement)); + 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) @@ -3762,7 +3763,8 @@ static void clear_element_at(sint32 x, sint32 y, rct_tile_element **elementPtr) break; case TILE_ELEMENT_TYPE_WALL: { - auto wallRemoveAction = WallRemoveAction(x, y, element->base_height, tile_element_get_direction(element)); + TileCoordsXYZD wallLocation = { x >> 5, y >> 5, element->base_height, element->GetDirection() }; + auto wallRemoveAction = WallRemoveAction(wallLocation); GameActions::Execute(&wallRemoveAction); } break; diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 742bf0a84e..18f452c3ce 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -248,7 +248,8 @@ void scenery_remove_ghost_tool_placement(){ { gSceneryGhostType &= ~SCENERY_ENTRY_FLAG_2; - auto wallRemoveAction = WallRemoveAction(x, y, z, gSceneryGhostWallRotation); + TileCoordsXYZD wallLocation = { x >> 5, y >> 5, z, gSceneryGhostWallRotation }; + auto wallRemoveAction = WallRemoveAction(wallLocation); wallRemoveAction.SetFlags(GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY); wallRemoveAction.Execute(); } From a8e1c750eb1a3cefaa62d5c6b3ca892d3dfdda18 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Mon, 14 May 2018 15:47:35 +0200 Subject: [PATCH 8/8] Bump network version --- 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 35802c7ac2..3a00efad39 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -34,7 +34,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 "9" +#define NETWORK_STREAM_VERSION "10" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static rct_peep* _pickup_peep = nullptr;