From 181eaf768d3c2cfd71fc62c4aa80d0166c9cd58d Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Sat, 29 Feb 2020 00:30:50 -0300 Subject: [PATCH] Receive CoordsXYZ by const ref instead of copy --- src/openrct2/actions/FootpathPlaceAction.hpp | 2 +- .../actions/FootpathPlaceFromTrackAction.hpp | 2 +- src/openrct2/actions/FootpathRemoveAction.hpp | 2 +- .../actions/FootpathSceneryPlaceAction.hpp | 2 +- .../actions/FootpathSceneryRemoveAction.hpp | 2 +- src/openrct2/actions/MazePlaceTrackAction.hpp | 2 +- .../actions/ParkEntranceRemoveAction.hpp | 4 +- src/openrct2/actions/PeepPickupAction.hpp | 2 +- .../actions/RideEntranceExitPlaceAction.hpp | 2 +- .../actions/SmallSceneryRemoveAction.hpp | 2 +- .../actions/SmallScenerySetColourAction.hpp | 2 +- .../actions/TrackSetBrakeSpeedAction.hpp | 2 +- src/openrct2/actions/WallPlaceAction.hpp | 3 +- src/openrct2/network/Network.cpp | 4 +- src/openrct2/network/network.h | 2 +- src/openrct2/paint/Paint.cpp | 41 ++++++++++--------- src/openrct2/peep/Peep.cpp | 2 +- src/openrct2/peep/Peep.h | 2 +- src/openrct2/ride/Ride.cpp | 3 +- src/openrct2/ride/Ride.h | 3 +- src/openrct2/ride/TrackDesignSave.cpp | 4 +- src/openrct2/ride/thrill/MagicCarpet.cpp | 30 +++++++------- src/openrct2/world/Footpath.cpp | 6 +-- src/openrct2/world/Footpath.h | 6 +-- src/openrct2/world/Fountain.cpp | 14 +++---- src/openrct2/world/Fountain.h | 14 +++---- src/openrct2/world/MapAnimation.cpp | 32 +++++++-------- src/openrct2/world/MapAnimation.h | 2 +- src/openrct2/world/MoneyEffect.cpp | 9 ++-- src/openrct2/world/Sprite.h | 2 +- 30 files changed, 107 insertions(+), 98 deletions(-) diff --git a/src/openrct2/actions/FootpathPlaceAction.hpp b/src/openrct2/actions/FootpathPlaceAction.hpp index e486e0386e..475cf1d947 100644 --- a/src/openrct2/actions/FootpathPlaceAction.hpp +++ b/src/openrct2/actions/FootpathPlaceAction.hpp @@ -32,7 +32,7 @@ private: public: FootpathPlaceAction() = default; - FootpathPlaceAction(CoordsXYZ loc, uint8_t slope, uint8_t type, Direction direction = INVALID_DIRECTION) + FootpathPlaceAction(const CoordsXYZ& loc, uint8_t slope, uint8_t type, Direction direction = INVALID_DIRECTION) : _loc(loc) , _slope(slope) , _type(type) diff --git a/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp b/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp index 44212d68b0..6c6f05a755 100644 --- a/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp +++ b/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp @@ -32,7 +32,7 @@ private: public: FootpathPlaceFromTrackAction() = default; - FootpathPlaceFromTrackAction(CoordsXYZ loc, uint8_t slope, uint8_t type, uint8_t edges) + FootpathPlaceFromTrackAction(const CoordsXYZ& loc, uint8_t slope, uint8_t type, uint8_t edges) : _loc(loc) , _slope(slope) , _type(type) diff --git a/src/openrct2/actions/FootpathRemoveAction.hpp b/src/openrct2/actions/FootpathRemoveAction.hpp index 70001ddf7f..5a98e6ac8b 100644 --- a/src/openrct2/actions/FootpathRemoveAction.hpp +++ b/src/openrct2/actions/FootpathRemoveAction.hpp @@ -29,7 +29,7 @@ private: public: FootpathRemoveAction() = default; - FootpathRemoveAction(CoordsXYZ location) + FootpathRemoveAction(const CoordsXYZ& location) : _loc(location) { } diff --git a/src/openrct2/actions/FootpathSceneryPlaceAction.hpp b/src/openrct2/actions/FootpathSceneryPlaceAction.hpp index f14158c00f..5bf04a09d8 100644 --- a/src/openrct2/actions/FootpathSceneryPlaceAction.hpp +++ b/src/openrct2/actions/FootpathSceneryPlaceAction.hpp @@ -30,7 +30,7 @@ private: public: FootpathSceneryPlaceAction() = default; - FootpathSceneryPlaceAction(CoordsXYZ loc, uint8_t pathItemType) + FootpathSceneryPlaceAction(const CoordsXYZ& loc, uint8_t pathItemType) : _loc(loc) , _pathItemType(pathItemType) { diff --git a/src/openrct2/actions/FootpathSceneryRemoveAction.hpp b/src/openrct2/actions/FootpathSceneryRemoveAction.hpp index 92190a1aaa..5aab82f873 100644 --- a/src/openrct2/actions/FootpathSceneryRemoveAction.hpp +++ b/src/openrct2/actions/FootpathSceneryRemoveAction.hpp @@ -28,7 +28,7 @@ private: public: FootpathSceneryRemoveAction() = default; - FootpathSceneryRemoveAction(CoordsXYZ loc) + FootpathSceneryRemoveAction(const CoordsXYZ& loc) : _loc(loc) { } diff --git a/src/openrct2/actions/MazePlaceTrackAction.hpp b/src/openrct2/actions/MazePlaceTrackAction.hpp index 14160e2ea6..de3ef706fa 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.hpp +++ b/src/openrct2/actions/MazePlaceTrackAction.hpp @@ -23,7 +23,7 @@ private: public: MazePlaceTrackAction() = default; - MazePlaceTrackAction(CoordsXYZ location, NetworkRideId_t rideIndex, uint16_t mazeEntry) + MazePlaceTrackAction(const CoordsXYZ& location, NetworkRideId_t rideIndex, uint16_t mazeEntry) : _loc(location) , _rideIndex(rideIndex) , _mazeEntry(mazeEntry) diff --git a/src/openrct2/actions/ParkEntranceRemoveAction.hpp b/src/openrct2/actions/ParkEntranceRemoveAction.hpp index 341e9fec27..fbedfddbd5 100644 --- a/src/openrct2/actions/ParkEntranceRemoveAction.hpp +++ b/src/openrct2/actions/ParkEntranceRemoveAction.hpp @@ -23,7 +23,7 @@ private: public: ParkEntranceRemoveAction() = default; - ParkEntranceRemoveAction(CoordsXYZ loc) + ParkEntranceRemoveAction(const CoordsXYZ& loc) : _loc(loc) { } @@ -93,7 +93,7 @@ public: } private: - void ParkEntranceRemoveSegment(CoordsXYZ loc) const + void ParkEntranceRemoveSegment(const CoordsXYZ& loc) const { auto entranceElement = map_get_park_entrance_element_at(loc, true); if (entranceElement == nullptr) diff --git a/src/openrct2/actions/PeepPickupAction.hpp b/src/openrct2/actions/PeepPickupAction.hpp index dcabc0784b..b67e333135 100644 --- a/src/openrct2/actions/PeepPickupAction.hpp +++ b/src/openrct2/actions/PeepPickupAction.hpp @@ -32,7 +32,7 @@ private: public: PeepPickupAction() = default; - PeepPickupAction(PeepPickupType type, uint32_t spriteId, CoordsXYZ loc, NetworkPlayerId_t owner) + PeepPickupAction(PeepPickupType type, uint32_t spriteId, const CoordsXYZ& loc, NetworkPlayerId_t owner) : _type(static_cast(type)) , _spriteId(spriteId) , _loc(loc) diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp index 9b99369959..669fe12b1e 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp @@ -230,7 +230,7 @@ public: return res; } - static GameActionResult::Ptr TrackPlaceQuery(const CoordsXYZ loc, const bool isExit) + static GameActionResult::Ptr TrackPlaceQuery(const CoordsXYZ& loc, const bool isExit) { auto errorTitle = isExit ? STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION : STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION; diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.hpp b/src/openrct2/actions/SmallSceneryRemoveAction.hpp index 372f8d0d8a..43b6550e89 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.hpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.hpp @@ -33,7 +33,7 @@ private: public: SmallSceneryRemoveAction() = default; - SmallSceneryRemoveAction(CoordsXYZ location, uint8_t quadrant, uint8_t sceneryType) + SmallSceneryRemoveAction(const CoordsXYZ& location, uint8_t quadrant, uint8_t sceneryType) : _loc(location) , _quadrant(quadrant) , _sceneryType(sceneryType) diff --git a/src/openrct2/actions/SmallScenerySetColourAction.hpp b/src/openrct2/actions/SmallScenerySetColourAction.hpp index 5614d45dc4..bdabda65ed 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.hpp +++ b/src/openrct2/actions/SmallScenerySetColourAction.hpp @@ -40,7 +40,7 @@ public: SmallScenerySetColourAction() = default; SmallScenerySetColourAction( - CoordsXYZ loc, uint8_t quadrant, uint8_t sceneryType, uint8_t primaryColour, uint8_t secondaryColour) + const CoordsXYZ& loc, uint8_t quadrant, uint8_t sceneryType, uint8_t primaryColour, uint8_t secondaryColour) : _loc(loc) , _quadrant(quadrant) , _sceneryType(sceneryType) diff --git a/src/openrct2/actions/TrackSetBrakeSpeedAction.hpp b/src/openrct2/actions/TrackSetBrakeSpeedAction.hpp index 6009fde418..4764542fd6 100644 --- a/src/openrct2/actions/TrackSetBrakeSpeedAction.hpp +++ b/src/openrct2/actions/TrackSetBrakeSpeedAction.hpp @@ -21,7 +21,7 @@ private: public: TrackSetBrakeSpeedAction() = default; - TrackSetBrakeSpeedAction(CoordsXYZ loc, track_type_t trackType, uint8_t brakeSpeed) + TrackSetBrakeSpeedAction(const CoordsXYZ& loc, track_type_t trackType, uint8_t brakeSpeed) : _loc(loc) , _trackType(trackType) , _brakeSpeed(brakeSpeed) diff --git a/src/openrct2/actions/WallPlaceAction.hpp b/src/openrct2/actions/WallPlaceAction.hpp index eff0870d45..2128777a7a 100644 --- a/src/openrct2/actions/WallPlaceAction.hpp +++ b/src/openrct2/actions/WallPlaceAction.hpp @@ -64,7 +64,8 @@ public: WallPlaceAction() = default; WallPlaceAction( - int32_t wallType, CoordsXYZ loc, uint8_t edge, int32_t primaryColour, int32_t secondaryColour, int32_t tertiaryColour) + int32_t wallType, const CoordsXYZ& loc, uint8_t edge, int32_t primaryColour, int32_t secondaryColour, + int32_t tertiaryColour) : _wallType(wallType) , _loc(loc) , _edge(edge) diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 9cf4673c80..ccd484643d 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -3293,7 +3293,7 @@ CoordsXYZ network_get_player_last_action_coord(uint32_t index) return gNetwork.player_list[index]->LastActionCoord; } -void network_set_player_last_action_coord(uint32_t index, CoordsXYZ coord) +void network_set_player_last_action_coord(uint32_t index, const CoordsXYZ& coord) { if (index < gNetwork.player_list.size()) { @@ -3951,7 +3951,7 @@ CoordsXYZ network_get_player_last_action_coord(uint32_t index) { return { 0, 0, 0 }; } -void network_set_player_last_action_coord(uint32_t index, CoordsXYZ coord) +void network_set_player_last_action_coord(uint32_t index, const CoordsXYZ& coord) { } uint32_t network_get_player_commands_ran(uint32_t index) diff --git a/src/openrct2/network/network.h b/src/openrct2/network/network.h index b62919eeb3..1b3d079445 100644 --- a/src/openrct2/network/network.h +++ b/src/openrct2/network/network.h @@ -65,7 +65,7 @@ void network_add_player_money_spent(uint32_t index, money32 cost); int32_t network_get_player_last_action(uint32_t index, int32_t time); void network_set_player_last_action(uint32_t index, int32_t command); CoordsXYZ network_get_player_last_action_coord(uint32_t index); -void network_set_player_last_action_coord(uint32_t index, CoordsXYZ coord); +void network_set_player_last_action_coord(uint32_t index, const CoordsXYZ& coord); uint32_t network_get_player_commands_ran(uint32_t index); int32_t network_get_player_index(uint32_t id); uint8_t network_get_player_group(uint32_t index); diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index d761c44876..ba3870f3fb 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -71,7 +71,8 @@ static void paint_session_add_ps_to_quadrant(paint_session* session, paint_struc * Extracted from 0x0098196c, 0x0098197c, 0x0098198c, 0x0098199c */ static paint_struct* sub_9819_c( - paint_session* session, uint32_t image_id, const CoordsXYZ& offset, CoordsXYZ boundBoxSize, CoordsXYZ boundBoxOffset) + paint_session* session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, + const CoordsXYZ& boundBoxOffset) { if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) return nullptr; @@ -112,38 +113,40 @@ static paint_struct* sub_9819_c( if (bottom >= dpi->y + dpi->height) return nullptr; + auto rotatedBoundBoxSize = boundBoxSize; + auto rotatedBoundBoxOffset = boundBoxOffset; // This probably rotates the variables so they're relative to rotation 0. switch (session->CurrentRotation) { case 0: - boundBoxSize.x--; - boundBoxSize.y--; - boundBoxOffset = { boundBoxOffset.Rotate(0), boundBoxOffset.z }; - boundBoxSize = { boundBoxSize.Rotate(0), boundBoxSize.z }; + rotatedBoundBoxSize.x--; + rotatedBoundBoxSize.y--; + rotatedBoundBoxOffset = { rotatedBoundBoxOffset.Rotate(0), rotatedBoundBoxOffset.z }; + rotatedBoundBoxSize = { boundBoxSize.Rotate(0), rotatedBoundBoxSize.z }; break; case 1: - boundBoxSize.x--; - boundBoxOffset = { boundBoxOffset.Rotate(3), boundBoxOffset.z }; - boundBoxSize = { boundBoxSize.Rotate(3), boundBoxSize.z }; + rotatedBoundBoxSize.x--; + rotatedBoundBoxOffset = { rotatedBoundBoxOffset.Rotate(3), rotatedBoundBoxOffset.z }; + rotatedBoundBoxSize = { boundBoxSize.Rotate(3), rotatedBoundBoxSize.z }; break; case 2: - boundBoxSize = { boundBoxSize.Rotate(2), boundBoxSize.z }; - boundBoxOffset = { boundBoxOffset.Rotate(2), boundBoxOffset.z }; + rotatedBoundBoxSize = { boundBoxSize.Rotate(2), rotatedBoundBoxSize.z }; + rotatedBoundBoxOffset = { rotatedBoundBoxOffset.Rotate(2), rotatedBoundBoxOffset.z }; break; case 3: - boundBoxSize.y--; - boundBoxSize = { boundBoxSize.Rotate(1), boundBoxSize.z }; - boundBoxOffset = { boundBoxOffset.Rotate(1), boundBoxOffset.z }; + rotatedBoundBoxSize.y--; + rotatedBoundBoxSize = { boundBoxSize.Rotate(1), rotatedBoundBoxSize.z }; + rotatedBoundBoxOffset = { rotatedBoundBoxOffset.Rotate(1), rotatedBoundBoxOffset.z }; break; } - ps->bounds.x_end = boundBoxSize.x + boundBoxOffset.x + session->SpritePosition.x; - ps->bounds.z = boundBoxOffset.z; - ps->bounds.z_end = boundBoxOffset.z + boundBoxSize.z; - ps->bounds.y_end = boundBoxSize.y + boundBoxOffset.y + session->SpritePosition.y; + ps->bounds.x_end = rotatedBoundBoxSize.x + rotatedBoundBoxOffset.x + session->SpritePosition.x; + ps->bounds.z = rotatedBoundBoxOffset.z; + ps->bounds.z_end = rotatedBoundBoxOffset.z + rotatedBoundBoxSize.z; + ps->bounds.y_end = rotatedBoundBoxSize.y + rotatedBoundBoxOffset.y + session->SpritePosition.y; ps->flags = 0; - ps->bounds.x = boundBoxOffset.x + session->SpritePosition.x; - ps->bounds.y = boundBoxOffset.y + session->SpritePosition.y; + ps->bounds.x = rotatedBoundBoxOffset.x + session->SpritePosition.x; + ps->bounds.y = rotatedBoundBoxOffset.y + session->SpritePosition.y; ps->attached_ps = nullptr; ps->children = nullptr; ps->sprite_type = session->InteractionType; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 08f7495d52..8f33618b02 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -1610,7 +1610,7 @@ void Peep::InsertNewThought(PeepThoughtType thoughtType, uint8_t thoughtArgument * * rct2: 0x0069A05D */ -Peep* Peep::Generate(const CoordsXYZ coords) +Peep* Peep::Generate(const CoordsXYZ& coords) { if (gSpriteListCount[SPRITE_LIST_FREE] < 400) return nullptr; diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 5b739a78f9..d9d9002647 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -716,7 +716,7 @@ public: // Peep void Pickup(); void PickupAbort(int32_t old_x); bool Place(TileCoordsXYZ location, bool apply); - static Peep* Generate(const CoordsXYZ coords); + static Peep* Generate(const CoordsXYZ& coords); void RemoveFromQueue(); void RemoveFromRide(); void InsertNewThought(PeepThoughtType thought_type, uint8_t thought_arguments); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 6b05427b6e..25d4ab0a82 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -3540,7 +3540,8 @@ static int32_t ride_music_params_update_label_58(uint32_t position, uint8_t* tun * @param tuneId (bh) * @returns new position (ebp) */ -int32_t ride_music_params_update(CoordsXYZ rideCoords, Ride* ride, uint16_t sampleRate, uint32_t position, uint8_t* tuneId) +int32_t ride_music_params_update( + const CoordsXYZ& rideCoords, Ride* ride, uint16_t sampleRate, uint32_t position, uint8_t* tuneId) { if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gGameSoundsOff && g_music_tracking_viewport != nullptr) { diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index b22f04f11f..af0591349c 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -1168,7 +1168,8 @@ int32_t sub_6C683D( int32_t* x, int32_t* y, int32_t* z, int32_t direction, int32_t type, uint16_t extra_params, TileElement** output_element, uint16_t flags); void ride_set_map_tooltip(TileElement* tileElement); -int32_t ride_music_params_update(CoordsXYZ rideCoords, Ride* ride, uint16_t sampleRate, uint32_t position, uint8_t* tuneId); +int32_t ride_music_params_update( + const CoordsXYZ& rideCoords, Ride* ride, uint16_t sampleRate, uint32_t position, uint8_t* tuneId); void ride_music_update_final(); void ride_prepare_breakdown(Ride* ride, int32_t breakdownReason); TileElement* ride_get_station_start_track_element(Ride* ride, int32_t stationIndex); diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index d3d7906e9a..500c2aab47 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -190,7 +190,7 @@ static void track_design_save_push_tile_element(CoordsXY loc, TileElement* tileE * rct2: 0x006D2FA7 */ static void track_design_save_push_tile_element_desc( - const rct_object_entry* entry, CoordsXYZ loc, uint8_t flags, uint8_t primaryColour, uint8_t secondaryColour) + const rct_object_entry* entry, const CoordsXYZ& loc, uint8_t flags, uint8_t primaryColour, uint8_t secondaryColour) { TrackDesignSceneryElement item{}; item.scenery_object = *entry; @@ -358,7 +358,7 @@ static void track_design_save_pop_tile_element(CoordsXY loc, TileElement* tileEl * * rct2: 0x006D2FDD */ -static void track_design_save_pop_tile_element_desc(const rct_object_entry* entry, CoordsXYZ loc, uint8_t flags) +static void track_design_save_pop_tile_element_desc(const rct_object_entry* entry, const CoordsXYZ& loc, uint8_t flags) { size_t removeIndex = SIZE_MAX; for (size_t i = 0; i < _trackSavedTileElementsDesc.size(); i++) diff --git a/src/openrct2/ride/thrill/MagicCarpet.cpp b/src/openrct2/ride/thrill/MagicCarpet.cpp index e8d3a6451c..953ca2a385 100644 --- a/src/openrct2/ride/thrill/MagicCarpet.cpp +++ b/src/openrct2/ride/thrill/MagicCarpet.cpp @@ -68,7 +68,8 @@ static Vehicle* get_first_vehicle(Ride* ride) } static void paint_magic_carpet_frame( - paint_session* session, uint8_t plane, uint8_t direction, CoordsXYZ offset, CoordsXYZ bbOffset, CoordsXYZ bbSize) + paint_session* session, uint8_t plane, uint8_t direction, const CoordsXYZ& offset, const CoordsXYZ& bbOffset, + const CoordsXYZ& bbSize) { uint32_t imageId; if (direction & 1) @@ -95,8 +96,8 @@ static void paint_magic_carpet_frame( } static void paint_magic_carpet_pendulum( - paint_session* session, uint8_t plane, uint32_t swingImageId, uint8_t direction, CoordsXYZ offset, CoordsXYZ bbOffset, - CoordsXYZ bbSize) + paint_session* session, uint8_t plane, uint32_t swingImageId, uint8_t direction, const CoordsXYZ& offset, + const CoordsXYZ& bbOffset, const CoordsXYZ& bbSize) { uint32_t imageId = swingImageId; if (direction & 2) @@ -118,8 +119,8 @@ static void paint_magic_carpet_pendulum( } static void paint_magic_carpet_vehicle( - paint_session* session, Ride* ride, uint8_t direction, uint32_t swingImageId, CoordsXYZ offset, CoordsXYZ bbOffset, - CoordsXYZ bbSize) + paint_session* session, Ride* ride, uint8_t direction, uint32_t swingImageId, const CoordsXYZ& offset, + const CoordsXYZ& bbOffset, const CoordsXYZ& bbSize) { rct_ride_entry* rideEntry = ride->GetRideEntry(); uint32_t vehicleImageId = rideEntry->vehicles[0].base_image_id + direction; @@ -132,26 +133,27 @@ static void paint_magic_carpet_vehicle( } int8_t directionalOffset = MagicCarpetOscillationXY[swingImageId]; + auto directedOffset = offset; switch (direction) { case 0: - offset.x -= directionalOffset; + directedOffset.x -= directionalOffset; break; case 1: - offset.y += directionalOffset; + directedOffset.y += directionalOffset; break; case 2: - offset.x += directionalOffset; + directedOffset.x += directionalOffset; break; case 3: - offset.y -= directionalOffset; + directedOffset.y -= directionalOffset; break; } - offset.z += MagicCarpetOscillationZ[swingImageId]; + directedOffset.z += MagicCarpetOscillationZ[swingImageId]; sub_98199C( - session, vehicleImageId | imageColourFlags, (int8_t)offset.x, (int8_t)offset.y, bbSize.x, bbSize.y, 127, offset.z, - bbOffset.x, bbOffset.y, bbOffset.z); + session, vehicleImageId | imageColourFlags, (int8_t)directedOffset.x, (int8_t)directedOffset.y, bbSize.x, bbSize.y, 127, + directedOffset.z, bbOffset.x, bbOffset.y, bbOffset.z); // Riders rct_drawpixelinfo* dpi = &session->DPI; @@ -167,8 +169,8 @@ static void paint_magic_carpet_vehicle( imageId |= (vehicle->peep_tshirt_colours[peepIndex + 0] << 19); imageId |= (vehicle->peep_tshirt_colours[peepIndex + 1] << 24); sub_98199C( - session, imageId, (int8_t)offset.x, (int8_t)offset.y, bbSize.x, bbSize.y, 127, offset.z, bbOffset.x, - bbOffset.y, bbOffset.z); + session, imageId, (int8_t)directedOffset.x, (int8_t)directedOffset.y, bbSize.x, bbSize.y, 127, + directedOffset.z, bbOffset.x, bbOffset.y, bbOffset.z); } } } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 3efbc91132..06a4c14f37 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -111,7 +111,7 @@ static bool entrance_has_direction(TileElement* tileElement, int32_t direction) return entrance_get_directions(tileElement) & (1 << (direction & 3)); } -TileElement* map_get_footpath_element(CoordsXYZ coords) +TileElement* map_get_footpath_element(const CoordsXYZ& coords) { TileElement* tileElement = map_get_first_element_at(coords); do @@ -125,7 +125,7 @@ TileElement* map_get_footpath_element(CoordsXYZ coords) return nullptr; } -money32 footpath_remove(CoordsXYZ footpathLoc, int32_t flags) +money32 footpath_remove(const CoordsXYZ& footpathLoc, int32_t flags) { auto action = FootpathRemoveAction(footpathLoc); action.SetFlags(flags); @@ -143,7 +143,7 @@ money32 footpath_remove(CoordsXYZ footpathLoc, int32_t flags) * * rct2: 0x006A76FF */ -money32 footpath_provisional_set(int32_t type, CoordsXYZ footpathLoc, int32_t slope) +money32 footpath_provisional_set(int32_t type, const CoordsXYZ& footpathLoc, int32_t slope) { money32 cost; diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index 2122e78c13..97f2121099 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -175,12 +175,12 @@ extern const CoordsXY DirectionOffsets[NumOrthogonalDirections]; extern const CoordsXY BinUseOffsets[NumOrthogonalDirections]; extern const CoordsXY BenchUseOffsets[NumOrthogonalDirections * 2]; -TileElement* map_get_footpath_element(CoordsXYZ coords); +TileElement* map_get_footpath_element(const CoordsXYZ& coords); struct PathElement; PathElement* map_get_footpath_element_slope(const CoordsXYZ& footpathPos, int32_t slope); void footpath_interrupt_peeps(const CoordsXYZ& footpathPos); -money32 footpath_remove(CoordsXYZ footpathLoc, int32_t flags); -money32 footpath_provisional_set(int32_t type, CoordsXYZ footpathLoc, int32_t slope); +money32 footpath_remove(const CoordsXYZ& footpathLoc, int32_t flags); +money32 footpath_provisional_set(int32_t type, const CoordsXYZ& footpathLoc, int32_t slope); void footpath_provisional_remove(); void footpath_provisional_update(); CoordsXY footpath_get_coordinates_from_pos(ScreenCoordsXY screenCoords, int32_t* direction, TileElement** tileElement); diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index 3a2487680a..74b020a344 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -130,7 +130,7 @@ void JumpingFountain::StartAnimation(const int32_t newType, const CoordsXY newLo } void JumpingFountain::Create( - const int32_t newType, const CoordsXYZ newLoc, const int32_t direction, const int32_t newFlags, const int32_t iteration) + const int32_t newType, const CoordsXYZ& newLoc, const int32_t direction, const int32_t newFlags, const int32_t iteration) { auto* jumpingFountain = reinterpret_cast(create_sprite(SPRITE_IDENTIFIER_MISC)); if (jumpingFountain != nullptr) @@ -244,7 +244,7 @@ void JumpingFountain::AdvanceAnimation() Random({ newLoc, z }, availableDirections); } -bool JumpingFountain::IsJumpingFountain(const int32_t newType, const CoordsXYZ newLoc) +bool JumpingFountain::IsJumpingFountain(const int32_t newType, const CoordsXYZ& newLoc) { const int32_t pathBitFlagMask = newType == JUMPING_FOUNTAIN_TYPE_SNOW ? PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW : PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER; @@ -274,7 +274,7 @@ bool JumpingFountain::IsJumpingFountain(const int32_t newType, const CoordsXYZ n return false; } -void JumpingFountain::GoToEdge(const CoordsXYZ newLoc, const int32_t availableDirections) const +void JumpingFountain::GoToEdge(const CoordsXYZ& newLoc, const int32_t availableDirections) const { int32_t direction = (sprite_direction >> 3) << 1; if (availableDirections & (1 << direction)) @@ -311,7 +311,7 @@ void JumpingFountain::GoToEdge(const CoordsXYZ newLoc, const int32_t availableDi CreateNext(newLoc, direction); } -void JumpingFountain::Bounce(const CoordsXYZ newLoc, const int32_t availableDirections) +void JumpingFountain::Bounce(const CoordsXYZ& newLoc, const int32_t availableDirections) { Iteration++; if (Iteration < 8) @@ -332,7 +332,7 @@ void JumpingFountain::Bounce(const CoordsXYZ newLoc, const int32_t availableDire } } -void JumpingFountain::Split(const CoordsXYZ newLoc, int32_t availableDirections) const +void JumpingFountain::Split(const CoordsXYZ& newLoc, int32_t availableDirections) const { if (Iteration < 3) { @@ -358,7 +358,7 @@ void JumpingFountain::Split(const CoordsXYZ newLoc, int32_t availableDirections) } } -void JumpingFountain::Random(const CoordsXYZ newLoc, int32_t availableDirections) const +void JumpingFountain::Random(const CoordsXYZ& newLoc, int32_t availableDirections) const { const uint32_t randomIndex = scenario_rand(); if ((randomIndex & 0xFFFF) >= _FountainChanceOfStoppingRandomMode) @@ -372,7 +372,7 @@ void JumpingFountain::Random(const CoordsXYZ newLoc, int32_t availableDirections } } -void JumpingFountain::CreateNext(const CoordsXYZ newLoc, int32_t direction) const +void JumpingFountain::CreateNext(const CoordsXYZ& newLoc, int32_t direction) const { const int32_t newType = GetType(); int32_t newFlags = FountainFlags & ~FOUNTAIN_FLAG::DIRECTION; diff --git a/src/openrct2/world/Fountain.h b/src/openrct2/world/Fountain.h index fa9771dafa..7956c6edeb 100644 --- a/src/openrct2/world/Fountain.h +++ b/src/openrct2/world/Fountain.h @@ -27,13 +27,13 @@ struct JumpingFountain : SpriteGeneric private: int32_t GetType() const; void AdvanceAnimation(); - void GoToEdge(CoordsXYZ newLoc, int32_t availableDirections) const; - void Bounce(CoordsXYZ newLoc, int32_t availableDirections); - void Split(CoordsXYZ newLoc, int32_t availableDirections) const; - void Random(CoordsXYZ newLoc, int32_t availableDirections) const; - void CreateNext(CoordsXYZ newLoc, int32_t direction) const; - static void Create(int32_t newType, CoordsXYZ newLoc, int32_t direction, int32_t newFlags, int32_t iteration); - static bool IsJumpingFountain(int32_t newType, CoordsXYZ newLoc); + void GoToEdge(const CoordsXYZ& newLoc, int32_t availableDirections) const; + void Bounce(const CoordsXYZ& newLoc, int32_t availableDirections); + void Split(const CoordsXYZ& newLoc, int32_t availableDirections) const; + void Random(const CoordsXYZ& newLoc, int32_t availableDirections) const; + void CreateNext(const CoordsXYZ& newLoc, int32_t direction) const; + static void Create(int32_t newType, const CoordsXYZ& newLoc, int32_t direction, int32_t newFlags, int32_t iteration); + static bool IsJumpingFountain(int32_t newType, const CoordsXYZ& newLoc); }; enum diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index be3649bde7..5152d2bbfd 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -25,7 +25,7 @@ #include "SmallScenery.h" #include "Sprite.h" -using map_animation_invalidate_event_handler = bool (*)(CoordsXYZ loc); +using map_animation_invalidate_event_handler = bool (*)(const CoordsXYZ& loc); static std::vector _mapAnimations; @@ -46,7 +46,7 @@ static bool DoesAnimationExist(int32_t type, const CoordsXYZ& location) return false; } -void map_animation_create(int32_t type, const CoordsXYZ loc) +void map_animation_create(int32_t type, const CoordsXYZ& loc) { if (!DoesAnimationExist(type, loc)) { @@ -87,7 +87,7 @@ void map_animation_invalidate_all() * * rct2: 0x00666670 */ -static bool map_animation_invalidate_ride_entrance(CoordsXYZ loc) +static bool map_animation_invalidate_ride_entrance(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; auto tileElement = map_get_first_element_at(loc); @@ -122,7 +122,7 @@ static bool map_animation_invalidate_ride_entrance(CoordsXYZ loc) * * rct2: 0x006A7BD4 */ -static bool map_animation_invalidate_queue_banner(CoordsXYZ loc) +static bool map_animation_invalidate_queue_banner(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -156,7 +156,7 @@ static bool map_animation_invalidate_queue_banner(CoordsXYZ loc) * * rct2: 0x006E32C9 */ -static bool map_animation_invalidate_small_scenery(CoordsXYZ loc) +static bool map_animation_invalidate_small_scenery(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -233,7 +233,7 @@ static bool map_animation_invalidate_small_scenery(CoordsXYZ loc) * * rct2: 0x00666C63 */ -static bool map_animation_invalidate_park_entrance(CoordsXYZ loc) +static bool map_animation_invalidate_park_entrance(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -263,7 +263,7 @@ static bool map_animation_invalidate_park_entrance(CoordsXYZ loc) * * rct2: 0x006CE29E */ -static bool map_animation_invalidate_track_waterfall(CoordsXYZ loc) +static bool map_animation_invalidate_track_waterfall(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -292,7 +292,7 @@ static bool map_animation_invalidate_track_waterfall(CoordsXYZ loc) * * rct2: 0x006CE2F3 */ -static bool map_animation_invalidate_track_rapids(CoordsXYZ loc) +static bool map_animation_invalidate_track_rapids(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -321,7 +321,7 @@ static bool map_animation_invalidate_track_rapids(CoordsXYZ loc) * * rct2: 0x006CE39D */ -static bool map_animation_invalidate_track_onridephoto(CoordsXYZ loc) +static bool map_animation_invalidate_track_onridephoto(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -362,7 +362,7 @@ static bool map_animation_invalidate_track_onridephoto(CoordsXYZ loc) * * rct2: 0x006CE348 */ -static bool map_animation_invalidate_track_whirlpool(CoordsXYZ loc) +static bool map_animation_invalidate_track_whirlpool(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -391,7 +391,7 @@ static bool map_animation_invalidate_track_whirlpool(CoordsXYZ loc) * * rct2: 0x006CE3FA */ -static bool map_animation_invalidate_track_spinningtunnel(CoordsXYZ loc) +static bool map_animation_invalidate_track_spinningtunnel(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -420,7 +420,7 @@ static bool map_animation_invalidate_track_spinningtunnel(CoordsXYZ loc) * * rct2: 0x0068DF8F */ -static bool map_animation_invalidate_remove([[maybe_unused]] CoordsXYZ loc) +static bool map_animation_invalidate_remove([[maybe_unused]] const CoordsXYZ& loc) { return true; } @@ -429,7 +429,7 @@ static bool map_animation_invalidate_remove([[maybe_unused]] CoordsXYZ loc) * * rct2: 0x006BA2BB */ -static bool map_animation_invalidate_banner(CoordsXYZ loc) +static bool map_animation_invalidate_banner(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -454,7 +454,7 @@ static bool map_animation_invalidate_banner(CoordsXYZ loc) * * rct2: 0x006B94EB */ -static bool map_animation_invalidate_large_scenery(CoordsXYZ loc) +static bool map_animation_invalidate_large_scenery(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -486,7 +486,7 @@ static bool map_animation_invalidate_large_scenery(CoordsXYZ loc) * * rct2: 0x006E5B50 */ -static bool map_animation_invalidate_wall_door(CoordsXYZ loc) +static bool map_animation_invalidate_wall_door(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; @@ -551,7 +551,7 @@ static bool map_animation_invalidate_wall_door(CoordsXYZ loc) * * rct2: 0x006E5EE4 */ -static bool map_animation_invalidate_wall(CoordsXYZ loc) +static bool map_animation_invalidate_wall(const CoordsXYZ& loc) { TileCoordsXYZ tileLoc{ loc }; TileElement* tileElement; diff --git a/src/openrct2/world/MapAnimation.h b/src/openrct2/world/MapAnimation.h index 43c2a815dd..0617820422 100644 --- a/src/openrct2/world/MapAnimation.h +++ b/src/openrct2/world/MapAnimation.h @@ -39,7 +39,7 @@ enum MAP_ANIMATION_TYPE_COUNT }; -void map_animation_create(int32_t type, const CoordsXYZ loc); +void map_animation_create(int32_t type, const CoordsXYZ& loc); void map_animation_invalidate_all(); const std::vector& GetMapAnimations(); void AutoCreateMapAnimations(); diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index 5425c7e2c0..def6f1f330 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -75,8 +75,9 @@ void MoneyEffect::CreateAt(money32 value, int32_t x, int32_t y, int32_t z, bool * * rct2: 0x0069C5D0 */ -void MoneyEffect::Create(money32 value, CoordsXYZ loc) +void MoneyEffect::Create(money32 value, const CoordsXYZ& loc) { + auto validLoc = loc; if (loc.isNull()) { // If game actions return no valid location of the action we can not use the screen @@ -97,10 +98,10 @@ void MoneyEffect::Create(money32 value, CoordsXYZ loc) if (!mapPositionXY) return; - loc = { *mapPositionXY, tile_element_height(*mapPositionXY) }; + validLoc = { *mapPositionXY, tile_element_height(*mapPositionXY) }; } - loc.z += 10; - CreateAt(-value, loc.x, loc.y, loc.z, false); + validLoc.z += 10; + CreateAt(-value, validLoc.x, validLoc.y, validLoc.z, false); } /** diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index b803eff9c0..fcb48fe8ed 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -82,7 +82,7 @@ struct MoneyEffect : SpriteBase uint16_t wiggle; static void CreateAt(money32 value, int32_t x, int32_t y, int32_t z, bool vertical); - static void Create(money32 value, CoordsXYZ loc); + static void Create(money32 value, const CoordsXYZ& loc); void Update(); std::pair GetStringId() const; };