From b4e0df2e5f7f85b1258e04cffaeef15b40d1b5b5 Mon Sep 17 00:00:00 2001 From: 0cufox0 Date: Sun, 7 Jul 2019 04:53:59 +0300 Subject: [PATCH] Fix review issues and formatting --- .../interface/ViewportInteraction.cpp | 9 +++--- src/openrct2-ui/windows/Ride.cpp | 4 +-- src/openrct2-ui/windows/Sign.cpp | 5 ++- src/openrct2/actions/ClearAction.hpp | 9 +++--- src/openrct2/actions/FootpathRemoveAction.hpp | 31 +++++++++---------- src/openrct2/actions/GameActionCompat.cpp | 6 ++-- .../actions/LargeSceneryRemoveAction.hpp | 18 +++++------ src/openrct2/actions/MazeSetTrackAction.hpp | 24 ++++++-------- .../actions/PlaceParkEntranceAction.hpp | 12 +++---- src/openrct2/actions/RideDemolishAction.hpp | 2 +- src/openrct2/actions/RideSetColourScheme.hpp | 2 +- .../actions/SmallSceneryRemoveAction.hpp | 2 +- src/openrct2/actions/WallRemoveAction.hpp | 11 +++---- src/openrct2/ride/TrackDesign.cpp | 8 ++--- src/openrct2/world/Footpath.cpp | 2 +- src/openrct2/world/Map.cpp | 17 +++++----- src/openrct2/world/Scenery.cpp | 6 ++-- 17 files changed, 78 insertions(+), 90 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index eb7e1b1b4a..ab2b561784 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -496,8 +496,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 = SmallSceneryRemoveAction( - {x, y, tileElement->base_height * 8}, - tileElement->AsSmallScenery()->GetSceneryQuadrant(), + { x, y, tileElement->base_height * 8 }, tileElement->AsSmallScenery()->GetSceneryQuadrant(), tileElement->AsSmallScenery()->GetEntryIndex()); GameActions::Execute(&removeSceneryAction); @@ -575,7 +574,7 @@ static void viewport_interaction_remove_park_wall(TileElement* tileElement, int3 } else { - CoordsXYZD wallLocation = { x, y, tileElement->base_height << 3, tileElement->GetDirection() }; + CoordsXYZD wallLocation = { x, y, tileElement->base_height * 8, tileElement->GetDirection() }; auto wallRemoveAction = WallRemoveAction(wallLocation); GameActions::Execute(&wallRemoveAction); } @@ -597,8 +596,8 @@ static void viewport_interaction_remove_large_scenery(TileElement* tileElement, else { auto removeSceneryAction = LargeSceneryRemoveAction( - {x, y, tileElement->base_height << 3, tileElement->GetDirection()} - , tileElement->AsLargeScenery()->GetSequenceIndex()); + { x, y, tileElement->base_height * 8, tileElement->GetDirection() }, + tileElement->AsLargeScenery()->GetSequenceIndex()); GameActions::Execute(&removeSceneryAction); } } diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 9419b0181c..23c9a6bccc 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -4349,8 +4349,8 @@ static void window_ride_set_track_colour_scheme(rct_window* w, int32_t x, int32_ z = tileElement->base_height * 8; direction = tileElement->GetDirection(); - auto gameAction = RideSetColourSchemeAction( { x, y, z, (Direction)direction} - , tileElement->AsTrack()->GetTrackType(), newColourScheme); + auto gameAction = RideSetColourSchemeAction( + CoordsXYZD{ x, y, z, static_cast(direction) }, tileElement->AsTrack()->GetTrackType(), newColourScheme); GameActions::Execute(&gameAction); } diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 33bef00123..5ebb84db46 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -232,10 +232,9 @@ static void window_sign_mouseup(rct_window* w, rct_widgetindex widgetIndex) } auto sceneryRemoveAction = LargeSceneryRemoveAction( - {x, y, tile_element->base_height * 8, tile_element->GetDirection()}, + { x, y, tile_element->base_height * 8, tile_element->GetDirection() }, tile_element->AsLargeScenery()->GetSequenceIndex()); GameActions::Execute(&sceneryRemoveAction); - break; } case WIDX_SIGN_TEXT: @@ -474,7 +473,7 @@ static void window_sign_small_mouseup(rct_window* w, rct_widgetindex widgetIndex } tile_element++; } - CoordsXYZD wallLocation = { x , y , tile_element->base_height << 3, tile_element->GetDirection() }; + CoordsXYZD wallLocation = { x, y, tile_element->base_height * 8, tile_element->GetDirection() }; auto wallRemoveAction = WallRemoveAction(wallLocation); GameActions::Execute(&wallRemoveAction); break; diff --git a/src/openrct2/actions/ClearAction.hpp b/src/openrct2/actions/ClearAction.hpp index 7bda66f4a2..d45bc7908e 100644 --- a/src/openrct2/actions/ClearAction.hpp +++ b/src/openrct2/actions/ClearAction.hpp @@ -152,7 +152,7 @@ private: case TILE_ELEMENT_TYPE_PATH: if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_FOOTPATH) { - auto footpathRemoveAction = FootpathRemoveAction(x * 32, y * 32, tileElement->base_height); + auto footpathRemoveAction = FootpathRemoveAction({ x * 32, y * 32, tileElement->base_height * 8 }); footpathRemoveAction.SetFlags(GetFlags()); auto res = executing ? GameActions::ExecuteNested(&footpathRemoveAction) @@ -169,7 +169,7 @@ private: if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_SMALL) { auto removeSceneryAction = SmallSceneryRemoveAction( - {x * 32, y * 32, tileElement->base_height * 8}, + { x * 32, y * 32, tileElement->base_height * 8 }, tileElement->AsSmallScenery()->GetSceneryQuadrant(), tileElement->AsSmallScenery()->GetEntryIndex()); removeSceneryAction.SetFlags(GetFlags()); @@ -187,7 +187,8 @@ private: case TILE_ELEMENT_TYPE_WALL: if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_SMALL) { - CoordsXYZD wallLocation = { x<<5, y<<5, tileElement->base_height << 3, tileElement->GetDirection() }; + CoordsXYZD wallLocation = { x * 32, y * 32, tileElement->base_height * 8, + tileElement->GetDirection() }; auto wallRemoveAction = WallRemoveAction(wallLocation); wallRemoveAction.SetFlags(GetFlags()); @@ -205,7 +206,7 @@ private: if (_itemsToClear & CLEARABLE_ITEMS::SCENERY_LARGE) { auto removeSceneryAction = LargeSceneryRemoveAction( - {x * 32, y * 32, tileElement->base_height * 8, tileElement->GetDirection()}, + { x * 32, y * 32, tileElement->base_height * 8, tileElement->GetDirection() }, tileElement->AsLargeScenery()->GetSequenceIndex()); removeSceneryAction.SetFlags(GetFlags() | GAME_COMMAND_FLAG_PATH_SCENERY); diff --git a/src/openrct2/actions/FootpathRemoveAction.hpp b/src/openrct2/actions/FootpathRemoveAction.hpp index 7f7adb7858..76014a508d 100644 --- a/src/openrct2/actions/FootpathRemoveAction.hpp +++ b/src/openrct2/actions/FootpathRemoveAction.hpp @@ -25,16 +25,12 @@ DEFINE_GAME_ACTION(FootpathRemoveAction, GAME_COMMAND_REMOVE_PATH, GameActionResult) { private: - int32_t _x; - int32_t _y; - int32_t _z; + CoordsXYZ _loc; public: FootpathRemoveAction() = default; - FootpathRemoveAction(int32_t x, int32_t y, int32_t z) - : _x(x) - , _y(y) - , _z(z) + FootpathRemoveAction(CoordsXYZ location) + : _loc(location) { } @@ -47,7 +43,7 @@ public: { GameAction::Serialise(stream); - stream << DS_TAG(_x) << DS_TAG(_y) << DS_TAG(_z); + stream << DS_TAG(_loc); } GameActionResult::Ptr Query() const override @@ -55,9 +51,10 @@ public: GameActionResult::Ptr res = std::make_unique(); res->Cost = 0; res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - res->Position = { _x + 16, _y + 16, _z * 8 }; + res->Position = { _loc.x + 16, _loc.y + 16, _loc.z }; - if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_x, _y, _z * 8)) + if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) + && !map_is_location_owned(_loc.x, _loc.y, _loc.z)) { return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK); } @@ -78,25 +75,25 @@ public: GameActionResult::Ptr res = std::make_unique(); res->Cost = 0; res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - res->Position = { _x + 16, _y + 16, _z * 8 }; + res->Position = { _loc.x + 16, _loc.y + 16, _loc.z }; if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST)) { - footpath_interrupt_peeps(_x, _y, _z * 8); - footpath_remove_litter(_x, _y, _z * 8); + footpath_interrupt_peeps(_loc.x, _loc.y, _loc.z); + footpath_remove_litter(_loc.x, _loc.y, _loc.z); } TileElement* footpathElement = GetFootpathElement(); if (footpathElement != nullptr) { footpath_queue_chain_reset(); - auto bannerRes = RemoveBannersAtElement(_x, _y, footpathElement); + auto bannerRes = RemoveBannersAtElement(_loc.x, _loc.y, footpathElement); if (bannerRes->Error == GA_ERROR::OK) { res->Cost += bannerRes->Cost; } - footpath_remove_edges_at(_x, _y, footpathElement); - map_invalidate_tile_full(_x, _y); + footpath_remove_edges_at(_loc.x, _loc.y, footpathElement); + map_invalidate_tile_full(_loc.x, _loc.y); tile_element_remove(footpathElement); footpath_update_queue_chains(); } @@ -115,7 +112,7 @@ private: { bool getGhostPath = GetFlags() & GAME_COMMAND_FLAG_GHOST; - TileElement* tileElement = map_get_footpath_element(_x / 32, _y / 32, _z); + TileElement* tileElement = map_get_footpath_element(_loc.x / 32, _loc.y / 32, _loc.z / 32); TileElement* footpathElement = nullptr; if (tileElement != nullptr) { diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index 9e3ef76cc1..5815160294 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -23,7 +23,7 @@ #pragma region PlaceParkEntranceAction money32 place_park_entrance(int16_t x, int16_t y, int16_t z, uint8_t direction) { - auto gameAction = PlaceParkEntranceAction({x, y, z << 4, direction}); + auto gameAction = PlaceParkEntranceAction({ x, y, z * 16, direction }); auto result = GameActions::Execute(&gameAction); if (result->Error == GA_ERROR::OK) { @@ -43,7 +43,7 @@ money32 park_entrance_place_ghost(int32_t x, int32_t y, int32_t z, int32_t direc { park_entrance_remove_ghost(); - auto gameAction = PlaceParkEntranceAction({x, y, z << 4, (Direction)direction}); + auto gameAction = PlaceParkEntranceAction({ x, y, z * 16, (Direction)direction }); gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST); auto result = GameActions::Execute(&gameAction); @@ -178,7 +178,7 @@ money32 maze_set_track( uint16_t x, uint16_t y, uint16_t z, uint8_t flags, bool initialPlacement, uint8_t direction, ride_id_t rideIndex, uint8_t mode) { - auto gameAction = MazeSetTrackAction({x, y, z, direction}, initialPlacement, rideIndex, mode); + auto gameAction = MazeSetTrackAction({ x, y, z, direction }, initialPlacement, rideIndex, mode); gameAction.SetFlags(flags); GameActionResult::Ptr res; diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.hpp b/src/openrct2/actions/LargeSceneryRemoveAction.hpp index 7fe2b8ca15..3915c03952 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.hpp +++ b/src/openrct2/actions/LargeSceneryRemoveAction.hpp @@ -59,7 +59,7 @@ public: int32_t z = tile_element_height(_loc.x, _loc.x); res->Position.x = _loc.x + 16; res->Position.y = _loc.y + 16; - res->Position.z = z ; + res->Position.z = z; res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; res->Cost = 0; @@ -72,10 +72,9 @@ public: 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((_loc.z) - scenery_entry->large_scenery.tiles[_tileIndex].z_offset) - }; + LocationXYZ16 firstTile = { scenery_entry->large_scenery.tiles[_tileIndex].x_offset, + scenery_entry->large_scenery.tiles[_tileIndex].y_offset, + static_cast((_loc.z) - scenery_entry->large_scenery.tiles[_tileIndex].z_offset) }; rotate_map_coordinates(&firstTile.x, &firstTile.y, _loc.direction); @@ -145,10 +144,9 @@ public: 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((_loc.z) - scenery_entry->large_scenery.tiles[_tileIndex].z_offset) - }; + LocationXYZ16 firstTile = { scenery_entry->large_scenery.tiles[_tileIndex].x_offset, + scenery_entry->large_scenery.tiles[_tileIndex].y_offset, + static_cast((_loc.z) - scenery_entry->large_scenery.tiles[_tileIndex].z_offset) }; rotate_map_coordinates(&firstTile.x, &firstTile.y, _loc.direction); @@ -225,7 +223,7 @@ private: if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY) continue; - if (tileElement->base_height != _loc.z >> 3) + if (tileElement->base_height != _loc.z / 8) continue; if (tileElement->AsLargeScenery()->GetSequenceIndex() != _tileIndex) diff --git a/src/openrct2/actions/MazeSetTrackAction.hpp b/src/openrct2/actions/MazeSetTrackAction.hpp index 8bf16a0eb7..0ced878c7d 100644 --- a/src/openrct2/actions/MazeSetTrackAction.hpp +++ b/src/openrct2/actions/MazeSetTrackAction.hpp @@ -6,7 +6,6 @@ * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ - #pragma once #include "../Cheats.h" @@ -20,7 +19,6 @@ #include "../world/Footpath.h" #include "../world/Park.h" #include "GameAction.h" - // clang-format off /** rct2: 0x00993CE9 */ static constexpr const uint8_t byte_993CE9[] = { @@ -60,8 +58,7 @@ public: MazeSetTrackAction() { } - MazeSetTrackAction( - CoordsXYZD location, bool initialPlacement, NetworkRideId_t rideIndex, uint8_t mode) + MazeSetTrackAction(CoordsXYZD location, bool initialPlacement, NetworkRideId_t rideIndex, uint8_t mode) : _loc(location) , _initialPlacement(initialPlacement) , _rideIndex(rideIndex) @@ -72,8 +69,7 @@ public: void Serialise(DataSerialiser & stream) override { GameAction::Serialise(stream); - - stream << DS_TAG(_loc) << DS_TAG(_initialPlacement) << DS_TAG(_rideIndex) << DS_TAG(_mode); + stream << DS_TAG(_loc) << DS_TAG(_loc.direction) << DS_TAG(_initialPlacement) << DS_TAG(_rideIndex) << DS_TAG(_mode); } GameActionResult::Ptr Query() const override @@ -85,14 +81,12 @@ public: res->Position.z = _loc.z; res->ExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; res->ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; - if (!map_check_free_elements_and_reorganise(1)) { res->Error = GA_ERROR::NO_FREE_ELEMENTS; res->ErrorMessage = STR_TILE_ELEMENT_LIMIT_REACHED; return res; } - if ((_loc.z & 0xF) != 0) { res->Error = GA_ERROR::UNKNOWN; @@ -115,8 +109,8 @@ public: return res; } - uint8_t baseHeight = _loc.z >> 3; - uint8_t clearanceHeight = (_loc.z + 32) >> 3; + uint8_t baseHeight = _loc.z / 8; + uint8_t clearanceHeight = (_loc.z + 32) / 8; int8_t heightDifference = baseHeight - tileElement->base_height; if (heightDifference >= 0 && !gCheatsDisableSupportLimits) @@ -201,10 +195,11 @@ public: wall_remove_at(floor2(_loc.x, 32), floor2(_loc.y, 32), _loc.z, _loc.z + 32); } - uint8_t baseHeight = _loc.z >> 3; - uint8_t clearanceHeight = (_loc.z + 32) >> 3; + uint8_t baseHeight = _loc.z / 8; + uint8_t clearanceHeight = (_loc.z + 32) / 8; - TileElement* tileElement = map_get_track_element_at_of_type_from_ride(_loc.x, _loc.y, baseHeight, TRACK_ELEM_MAZE, _rideIndex); + TileElement* tileElement = map_get_track_element_at_of_type_from_ride( + _loc.x, _loc.y, baseHeight, TRACK_ELEM_MAZE, _rideIndex); if (tileElement == nullptr) { Ride* ride = get_ride(_rideIndex); @@ -333,7 +328,8 @@ public: break; } - map_invalidate_tile(floor2(_loc.x, 32), floor2(_loc.y, 32), tileElement->base_height * 8, tileElement->clearance_height * 8); + map_invalidate_tile( + floor2(_loc.x, 32), floor2(_loc.y, 32), tileElement->base_height * 8, tileElement->clearance_height * 8); if ((tileElement->AsTrack()->GetMazeEntry() & 0x8888) == 0x8888) { diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index 8f26b92819..e6306cf91f 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -58,7 +58,7 @@ public: auto res = std::make_unique(); res->ExpenditureType = RCT_EXPENDITURE_TYPE_LAND_PURCHASE; - res->Position = {_loc.x, _loc.y, _loc.z}; + res->Position = { _loc.x, _loc.y, _loc.z }; if (!map_check_free_elements_and_reorganise(3)) { @@ -77,7 +77,7 @@ public: GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES); } - int8_t zLow = _loc.z >> 3; + int8_t zLow = _loc.z / 8; int8_t zHigh = zLow + 12; LocationXY16 entranceLoc = { (int16_t)_loc.x, (int16_t)_loc.y }; for (uint8_t index = 0; index < 3; index++) @@ -85,11 +85,11 @@ public: if (index == 1) { entranceLoc.x += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].x; - entranceLoc.y += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].y; + entranceLoc.y += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].y; } else if (index == 2) { - entranceLoc.x += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].x * 2; + entranceLoc.x += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].x * 2; entranceLoc.y += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].y * 2; } @@ -121,10 +121,10 @@ public: CoordsXYZD parkEntrance; parkEntrance = _loc; - + gParkEntrances.push_back(parkEntrance); - int8_t zLow = _loc.z >> 3; + int8_t zLow = _loc.z / 8; int8_t zHigh = zLow + 12; CoordsXY entranceLoc = { _loc.x, _loc.y }; for (uint8_t index = 0; index < 3; index++) diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index d2d46d9e3b..15a1316acb 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -268,7 +268,7 @@ private: money32 MazeRemoveTrack(uint16_t x, uint16_t y, uint16_t z, uint8_t direction) const { - auto setMazeTrack = MazeSetTrackAction({x, y, z, direction}, false, _rideIndex, GC_SET_MAZE_TRACK_FILL); + auto setMazeTrack = MazeSetTrackAction(CoordsXYZD{ x, y, z, direction }, false, _rideIndex, GC_SET_MAZE_TRACK_FILL); setMazeTrack.SetFlags(GetFlags()); auto execRes = GameActions::ExecuteNested(&setMazeTrack); diff --git a/src/openrct2/actions/RideSetColourScheme.hpp b/src/openrct2/actions/RideSetColourScheme.hpp index b7026670ee..7f4bf91b80 100644 --- a/src/openrct2/actions/RideSetColourScheme.hpp +++ b/src/openrct2/actions/RideSetColourScheme.hpp @@ -24,7 +24,7 @@ DEFINE_GAME_ACTION(RideSetColourSchemeAction, GAME_COMMAND_SET_COLOUR_SCHEME, GameActionResult) { private: - CoordsXYZD _loc{0,0,0,0}; + CoordsXYZD _loc{ 0, 0, 0, 0 }; int32_t _trackType = 0; uint16_t _newColourScheme = 0; diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.hpp b/src/openrct2/actions/SmallSceneryRemoveAction.hpp index 13bfe8415d..ee0f6a161d 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.hpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.hpp @@ -145,7 +145,7 @@ private: continue; if ((tileElement->AsSmallScenery()->GetSceneryQuadrant()) != _quadrant) continue; - if (tileElement->base_height != _loc.z >> 3) + if (tileElement->base_height != _loc.z / 8) continue; if (tileElement->AsSmallScenery()->GetEntryIndex() != _sceneryType) continue; diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index 19adae0bb3..7b6fe984bc 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -44,7 +44,7 @@ public: res->Cost = 0; res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - if (!map_is_location_valid({ _loc.x , _loc.y })) + if (!map_is_location_valid({ _loc.x, _loc.y })) { return std::make_unique( GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); @@ -52,7 +52,7 @@ public: const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST; if (!isGhost && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode - && !map_is_location_owned(_loc.x , _loc.y , _loc.z )) + && !map_is_location_owned(_loc.x, _loc.y, _loc.z)) { return std::make_unique(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } @@ -88,8 +88,7 @@ public: res->Position.z = tile_element_height(res->Position.x, res->Position.y); tile_element_remove_banner_entry(wallElement); - map_invalidate_tile_zoom1( - _loc.x, _loc.y , wallElement->base_height , wallElement->base_height + 72); + map_invalidate_tile_zoom1(_loc.x, _loc.y, wallElement->base_height * 8, (wallElement->base_height * 8) + 72); tile_element_remove(wallElement); return res; @@ -98,7 +97,7 @@ public: private: TileElement* GetFirstWallElementAt(const CoordsXYZD& location, bool isGhost) const { - TileElement* tileElement = map_get_first_element_at(location.x >> 5 , location.y >> 5 ); + TileElement* tileElement = map_get_first_element_at(location.x / 32, location.y / 32); if (!tileElement) return nullptr; @@ -106,7 +105,7 @@ private: { if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) continue; - if (tileElement->base_height != location.z >> 3) + if (tileElement->base_height != location.z / 8) continue; if (tileElement->GetDirection() != location.direction) continue; diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index e236579473..9ea74c8507 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -776,17 +776,17 @@ static bool TrackDesignPlaceSceneryElementRemoveGhost( quadrant = 0; } - ga = std::make_unique(CoordsXYZ{mapCoord.x, mapCoord.y, z * 8}, quadrant, entry_index); + ga = std::make_unique(CoordsXYZ{ mapCoord.x, mapCoord.y, z * 8 }, quadrant, entry_index); break; } case OBJECT_TYPE_LARGE_SCENERY: - ga = std::make_unique(CoordsXYZD{mapCoord.x, mapCoord.y, z * 8, sceneryRotation}, 0); + ga = std::make_unique(CoordsXYZD{ mapCoord.x, mapCoord.y, z * 8, sceneryRotation }, 0); break; case OBJECT_TYPE_WALLS: - ga = std::make_unique(CoordsXYZD{ mapCoord.x , mapCoord.y , z * 8, sceneryRotation }); + ga = std::make_unique(CoordsXYZD{ mapCoord.x, mapCoord.y, z * 8, sceneryRotation }); break; case OBJECT_TYPE_PATHS: - ga = std::make_unique(mapCoord.x, mapCoord.y, z); + ga = std::make_unique(CoordsXYZ{ mapCoord.x, mapCoord.y, z * 8 }); break; default: return true; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index e7b61a181d..2b128dc580 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -127,7 +127,7 @@ TileElement* map_get_footpath_element(int32_t x, int32_t y, int32_t z) money32 footpath_remove(int32_t x, int32_t y, int32_t z, int32_t flags) { - auto action = FootpathRemoveAction(x, y, z); + auto action = FootpathRemoveAction({ x, y, z * 8 }); action.SetFlags(flags); if (flags & GAME_COMMAND_FLAG_APPLY) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index d1ed202930..74cc0775d3 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1755,7 +1755,7 @@ static void clear_element_at(int32_t x, int32_t y, TileElement** elementPtr) } case TILE_ELEMENT_TYPE_WALL: { - CoordsXYZD wallLocation = { x, y, element->base_height << 3, element->GetDirection() }; + CoordsXYZD wallLocation = { x, y, element->base_height * 8, element->GetDirection() }; auto wallRemoveAction = WallRemoveAction(wallLocation); GameActions::Execute(&wallRemoveAction); } @@ -1763,8 +1763,7 @@ static void clear_element_at(int32_t x, int32_t y, TileElement** elementPtr) case TILE_ELEMENT_TYPE_LARGE_SCENERY: { auto removeSceneryAction = LargeSceneryRemoveAction( - {x, y, element->base_height << 3, element->GetDirection()} - , element->AsLargeScenery()->GetSequenceIndex()); + { x, y, element->base_height * 8, element->GetDirection() }, element->AsLargeScenery()->GetSequenceIndex()); GameActions::Execute(&removeSceneryAction); } break; @@ -1794,7 +1793,7 @@ static void clear_elements_at(int32_t x, int32_t y) [x, y](const auto& spawn) { return floor2(spawn.x, 32) == x && floor2(spawn.y, 32) == y; }), gPeepSpawns.end()); - TileElement* tileElement = map_get_first_element_at(x >> 5, y >> 5); + TileElement* tileElement = map_get_first_element_at(x / 32, y / 32); // Remove all elements except the last one while (!tileElement->IsLastForTile()) @@ -1827,7 +1826,7 @@ int32_t map_get_highest_z(int32_t tileX, int32_t tileY) LargeSceneryElement* map_get_large_scenery_segment(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t sequence) { - TileElement* tileElement = map_get_first_element_at(x >> 5, y >> 5); + TileElement* tileElement = map_get_first_element_at(x / 32, y / 32); if (tileElement == nullptr) { return nullptr; @@ -1850,7 +1849,7 @@ LargeSceneryElement* map_get_large_scenery_segment(int32_t x, int32_t y, int32_t EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost) { - TileElement* tileElement = map_get_first_element_at(x >> 5, y >> 5); + TileElement* tileElement = map_get_first_element_at(x / 32, y / 32); if (tileElement != nullptr) { do @@ -1875,7 +1874,7 @@ EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t EntranceElement* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost) { - TileElement* tileElement = map_get_first_element_at(x >> 5, y >> 5); + TileElement* tileElement = map_get_first_element_at(x / 32, y / 32); if (tileElement != nullptr) { do @@ -1900,7 +1899,7 @@ EntranceElement* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t EntranceElement* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z, bool ghost) { - TileElement* tileElement = map_get_first_element_at(x >> 5, y >> 5); + TileElement* tileElement = map_get_first_element_at(x / 32, y / 32); if (tileElement != nullptr) { do @@ -1925,7 +1924,7 @@ EntranceElement* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z, b SmallSceneryElement* map_get_small_scenery_element_at(int32_t x, int32_t y, int32_t z, int32_t type, uint8_t quadrant) { - TileElement* tileElement = map_get_first_element_at(x >> 5, y >> 5); + TileElement* tileElement = map_get_first_element_at(x / 32, y / 32); if (tileElement != nullptr) { do diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index cf08968ac5..049ac78ecd 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -186,7 +186,7 @@ void scenery_remove_ghost_tool_placement() { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_0; - auto removeSceneryAction = SmallSceneryRemoveAction({x, y, z * 8}, gSceneryQuadrant, gSceneryPlaceObject); + auto removeSceneryAction = SmallSceneryRemoveAction({ x, y, z * 8 }, gSceneryQuadrant, gSceneryPlaceObject); removeSceneryAction.SetFlags( GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); removeSceneryAction.Execute(); @@ -216,7 +216,7 @@ void scenery_remove_ghost_tool_placement() { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_2; - CoordsXYZD wallLocation = { x , y , z * 8, gSceneryGhostWallRotation }; + CoordsXYZD wallLocation = { x, y, z * 8, gSceneryGhostWallRotation }; auto wallRemoveAction = WallRemoveAction(wallLocation); wallRemoveAction.SetFlags(GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY); wallRemoveAction.Execute(); @@ -226,7 +226,7 @@ void scenery_remove_ghost_tool_placement() { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_3; - auto removeSceneryAction = LargeSceneryRemoveAction({x, y, z << 3, gSceneryPlaceRotation}, 0); + auto removeSceneryAction = LargeSceneryRemoveAction({ x, y, z * 8, gSceneryPlaceRotation }, 0); removeSceneryAction.SetFlags( GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND);