From 2da96e8cfc60d218fe2b3d04896733ea063b126d Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Sun, 1 Mar 2020 01:14:15 -0300 Subject: [PATCH] Revert to copy instead of const-ref for functions that edit content --- .../interface/ViewportInteraction.cpp | 12 +-- src/openrct2-ui/windows/TrackDesignPlace.cpp | 45 ++++---- src/openrct2/paint/Paint.cpp | 41 ++++--- src/openrct2/peep/GuestPathfinding.cpp | 100 ++++++++---------- src/openrct2/ride/thrill/MagicCarpet.cpp | 23 ++-- src/openrct2/world/MoneyEffect.cpp | 9 +- src/openrct2/world/Sprite.h | 2 +- 7 files changed, 106 insertions(+), 126 deletions(-) diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index ecbb59b012..c48292bc7e 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -44,7 +44,7 @@ static void viewport_interaction_remove_footpath(TileElement* tileElement, const static void viewport_interaction_remove_footpath_item(TileElement* tileElement, const CoordsXY& mapCoords); static void viewport_interaction_remove_park_wall(TileElement* tileElement, const CoordsXY& mapCoords); static void viewport_interaction_remove_large_scenery(TileElement* tileElement, const CoordsXY& mapCoords); -static void viewport_interaction_remove_park_entrance(TileElement* tileElement, const CoordsXY& mapCoords); +static void viewport_interaction_remove_park_entrance(TileElement* tileElement, CoordsXY mapCoords); static Peep* viewport_interaction_get_closest_peep(ScreenCoordsXY screenCoords, int32_t maxDistance); /** @@ -554,21 +554,19 @@ static void viewport_interaction_remove_footpath_item(TileElement* tileElement, * * rct2: 0x00666C0E */ -void viewport_interaction_remove_park_entrance(TileElement* tileElement, const CoordsXY& mapCoords) +void viewport_interaction_remove_park_entrance(TileElement* tileElement, CoordsXY mapCoords) { int32_t rotation = tileElement->GetDirectionWithOffset(1); - auto directedMapCoords = mapCoords; switch (tileElement->AsEntrance()->GetSequenceIndex()) { case 1: - directedMapCoords += CoordsDirectionDelta[rotation]; + mapCoords += CoordsDirectionDelta[rotation]; break; case 2: - directedMapCoords -= CoordsDirectionDelta[rotation]; + mapCoords -= CoordsDirectionDelta[rotation]; break; } - auto parkEntranceRemoveAction = ParkEntranceRemoveAction( - { directedMapCoords.x, directedMapCoords.y, tileElement->GetBaseZ() }); + auto parkEntranceRemoveAction = ParkEntranceRemoveAction({ mapCoords.x, mapCoords.y, tileElement->GetBaseZ() }); GameActions::Execute(&parkEntranceRemoveAction); } diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index c4be171847..5b7593da66 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -124,9 +124,9 @@ static int32_t window_track_place_get_base_z(int32_t x, int32_t y); static void window_track_place_clear_mini_preview(); static void window_track_place_draw_mini_preview(TrackDesign* td6); static void window_track_place_draw_mini_preview_track( - TrackDesign* td6, int32_t pass, const CoordsXY& origin, const CoordsXY& min, const CoordsXY& max); + TrackDesign* td6, int32_t pass, CoordsXY origin, CoordsXY min, CoordsXY max); static void window_track_place_draw_mini_preview_maze( - TrackDesign* td6, int32_t pass, const CoordsXY& origin, const CoordsXY& min, const CoordsXY& max); + TrackDesign* td6, int32_t pass, const CoordsXY& origin, CoordsXY min, CoordsXY max); static LocationXY16 draw_mini_preview_get_pixel_position(int16_t x, int16_t y); static bool draw_mini_preview_is_pixel_in_bounds(LocationXY16 pixel); static uint8_t* draw_mini_preview_get_pixel_ptr(LocationXY16 pixel); @@ -557,15 +557,12 @@ static void window_track_place_draw_mini_preview(TrackDesign* td6) } static void window_track_place_draw_mini_preview_track( - TrackDesign* td6, int32_t pass, const CoordsXY& origin, const CoordsXY& min, const CoordsXY& max) + TrackDesign* td6, int32_t pass, CoordsXY origin, CoordsXY min, CoordsXY max) { uint8_t rotation = (_currentTrackPieceDirection + get_current_rotation()) & 3; const rct_preview_track** trackBlockArray = (ride_type_has_flag(td6->type, RIDE_TYPE_FLAG_HAS_TRACK)) ? TrackBlocks : FlatRideTrackBlocks; - auto mutableOrigin = origin; - auto mutableMin = min; - auto mutableMax = max; for (const auto& trackElement : td6->track_elements) { int32_t trackType = trackElement.type; @@ -578,14 +575,14 @@ static void window_track_place_draw_mini_preview_track( const rct_preview_track* trackBlock = trackBlockArray[trackType]; while (trackBlock->index != 255) { - auto rotatedAndOffsetTrackBlock = mutableOrigin + CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(rotation); + auto rotatedAndOffsetTrackBlock = origin + CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(rotation); if (pass == 0) { - mutableMin.x = std::min(mutableMin.x, rotatedAndOffsetTrackBlock.x); - mutableMax.x = std::max(mutableMax.x, rotatedAndOffsetTrackBlock.x); - mutableMin.y = std::min(mutableMin.y, rotatedAndOffsetTrackBlock.y); - mutableMax.y = std::max(mutableMax.y, rotatedAndOffsetTrackBlock.y); + min.x = std::min(min.x, rotatedAndOffsetTrackBlock.x); + max.x = std::max(max.x, rotatedAndOffsetTrackBlock.x); + min.y = std::min(min.y, rotatedAndOffsetTrackBlock.y); + max.y = std::max(max.y, rotatedAndOffsetTrackBlock.y); } else { @@ -623,7 +620,7 @@ static void window_track_place_draw_mini_preview_track( const rct_track_coordinates* track_coordinate = &TrackCoordinates[trackType]; trackType *= 10; - auto rotatedAndOfffsetTrack = mutableOrigin + CoordsXY{ track_coordinate->x, track_coordinate->y }.Rotate(rotation); + auto rotatedAndOfffsetTrack = origin + CoordsXY{ track_coordinate->x, track_coordinate->y }.Rotate(rotation); rotation += track_coordinate->rotation_end - track_coordinate->rotation_begin; rotation &= 3; if (track_coordinate->rotation_end & 4) @@ -632,21 +629,21 @@ static void window_track_place_draw_mini_preview_track( } if (!(rotation & 4)) { - mutableOrigin = rotatedAndOfffsetTrack + CoordsDirectionDelta[rotation]; + origin = rotatedAndOfffsetTrack + CoordsDirectionDelta[rotation]; } } // Draw entrance and exit preview. for (const auto& entrance : td6->entrance_elements) { - auto rotatedAndOffsetEntrance = mutableOrigin + CoordsXY{ entrance.x, entrance.y }.Rotate(rotation); + auto rotatedAndOffsetEntrance = origin + CoordsXY{ entrance.x, entrance.y }.Rotate(rotation); if (pass == 0) { - mutableMin.x = std::min(mutableMin.x, rotatedAndOffsetEntrance.x); - mutableMax.x = std::max(mutableMax.x, rotatedAndOffsetEntrance.x); - mutableMin.y = std::min(mutableMin.y, rotatedAndOffsetEntrance.y); - mutableMax.y = std::max(mutableMax.y, rotatedAndOffsetEntrance.y); + min.x = std::min(min.x, rotatedAndOffsetEntrance.x); + max.x = std::max(max.x, rotatedAndOffsetEntrance.x); + min.y = std::min(min.y, rotatedAndOffsetEntrance.y); + max.y = std::max(max.y, rotatedAndOffsetEntrance.y); } else { @@ -669,21 +666,19 @@ static void window_track_place_draw_mini_preview_track( } static void window_track_place_draw_mini_preview_maze( - TrackDesign* td6, int32_t pass, const CoordsXY& origin, const CoordsXY& min, const CoordsXY& max) + TrackDesign* td6, int32_t pass, const CoordsXY& origin, CoordsXY min, CoordsXY max) { uint8_t rotation = (_currentTrackPieceDirection + get_current_rotation()) & 3; - auto mutableMin = min; - auto mutableMax = max; for (const auto& mazeElement : td6->maze_elements) { auto rotatedMazeCoords = origin + CoordsXY{ mazeElement.x * 32, mazeElement.y * 32 }.Rotate(rotation); if (pass == 0) { - mutableMin.x = std::min(mutableMin.x, rotatedMazeCoords.x); - mutableMax.x = std::max(mutableMax.x, rotatedMazeCoords.x); - mutableMin.y = std::min(mutableMin.y, rotatedMazeCoords.y); - mutableMax.y = std::max(mutableMax.y, rotatedMazeCoords.y); + min.x = std::min(min.x, rotatedMazeCoords.x); + max.x = std::max(max.x, rotatedMazeCoords.x); + min.y = std::min(min.y, rotatedMazeCoords.y); + max.y = std::max(max.y, rotatedMazeCoords.y); } else { diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index ba3870f3fb..d761c44876 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -71,8 +71,7 @@ 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, const CoordsXYZ& boundBoxSize, - const CoordsXYZ& boundBoxOffset) + paint_session* session, uint32_t image_id, const CoordsXYZ& offset, CoordsXYZ boundBoxSize, CoordsXYZ boundBoxOffset) { if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) return nullptr; @@ -113,40 +112,38 @@ 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: - rotatedBoundBoxSize.x--; - rotatedBoundBoxSize.y--; - rotatedBoundBoxOffset = { rotatedBoundBoxOffset.Rotate(0), rotatedBoundBoxOffset.z }; - rotatedBoundBoxSize = { boundBoxSize.Rotate(0), rotatedBoundBoxSize.z }; + boundBoxSize.x--; + boundBoxSize.y--; + boundBoxOffset = { boundBoxOffset.Rotate(0), boundBoxOffset.z }; + boundBoxSize = { boundBoxSize.Rotate(0), boundBoxSize.z }; break; case 1: - rotatedBoundBoxSize.x--; - rotatedBoundBoxOffset = { rotatedBoundBoxOffset.Rotate(3), rotatedBoundBoxOffset.z }; - rotatedBoundBoxSize = { boundBoxSize.Rotate(3), rotatedBoundBoxSize.z }; + boundBoxSize.x--; + boundBoxOffset = { boundBoxOffset.Rotate(3), boundBoxOffset.z }; + boundBoxSize = { boundBoxSize.Rotate(3), boundBoxSize.z }; break; case 2: - rotatedBoundBoxSize = { boundBoxSize.Rotate(2), rotatedBoundBoxSize.z }; - rotatedBoundBoxOffset = { rotatedBoundBoxOffset.Rotate(2), rotatedBoundBoxOffset.z }; + boundBoxSize = { boundBoxSize.Rotate(2), boundBoxSize.z }; + boundBoxOffset = { boundBoxOffset.Rotate(2), boundBoxOffset.z }; break; case 3: - rotatedBoundBoxSize.y--; - rotatedBoundBoxSize = { boundBoxSize.Rotate(1), rotatedBoundBoxSize.z }; - rotatedBoundBoxOffset = { rotatedBoundBoxOffset.Rotate(1), rotatedBoundBoxOffset.z }; + boundBoxSize.y--; + boundBoxSize = { boundBoxSize.Rotate(1), boundBoxSize.z }; + boundBoxOffset = { boundBoxOffset.Rotate(1), boundBoxOffset.z }; break; } - 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->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->flags = 0; - ps->bounds.x = rotatedBoundBoxOffset.x + session->SpritePosition.x; - ps->bounds.y = rotatedBoundBoxOffset.y + session->SpritePosition.y; + ps->bounds.x = boundBoxOffset.x + session->SpritePosition.x; + ps->bounds.y = boundBoxOffset.y + session->SpritePosition.y; ps->attached_ps = nullptr; ps->children = nullptr; ps->sprite_type = session->InteractionType; diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index df5b78a2de..c3ecff6b07 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -219,21 +219,20 @@ static int32_t guest_surface_path_finding(Peep* peep) * Returns the type of the next footpath tile a peep can get to from x,y,z / * inputTileElement in the given direction. */ -static uint8_t footpath_element_next_in_direction(const TileCoordsXYZ& loc, PathElement* pathElement, Direction chosenDirection) +static uint8_t footpath_element_next_in_direction(TileCoordsXYZ loc, PathElement* pathElement, Direction chosenDirection) { TileElement* nextTileElement; - auto adjustedLoc = loc; if (pathElement->IsSloped()) { if (pathElement->GetSlopeDirection() == chosenDirection) { - adjustedLoc.z += 2; + loc.z += 2; } } - adjustedLoc += TileDirectionDelta[chosenDirection]; - nextTileElement = map_get_first_element_at(adjustedLoc.ToCoordsXY()); + loc += TileDirectionDelta[chosenDirection]; + nextTileElement = map_get_first_element_at(loc.ToCoordsXY()); do { if (nextTileElement == nullptr) @@ -242,7 +241,7 @@ static uint8_t footpath_element_next_in_direction(const TileCoordsXYZ& loc, Path continue; if (nextTileElement->GetType() != TILE_ELEMENT_TYPE_PATH) continue; - if (!is_valid_path_z_and_direction(nextTileElement, adjustedLoc.z, chosenDirection)) + if (!is_valid_path_z_and_direction(nextTileElement, loc.z, chosenDirection)) continue; if (nextTileElement->AsPath()->IsWide()) return PATH_SEARCH_WIDE; @@ -275,18 +274,16 @@ static uint8_t footpath_element_next_in_direction(const TileCoordsXYZ& loc, Path * This is the recursive portion of footpath_element_destination_in_direction(). */ static uint8_t footpath_element_dest_in_dir( - const TileCoordsXYZ& loc, Direction chosenDirection, ride_id_t* outRideIndex, int32_t level) + TileCoordsXYZ loc, Direction chosenDirection, ride_id_t* outRideIndex, int32_t level) { TileElement* tileElement; Direction direction; - auto adjustedLoc = loc; - if (level > 25) return PATH_SEARCH_LIMIT_REACHED; - adjustedLoc += TileDirectionDelta[chosenDirection]; - tileElement = map_get_first_element_at(adjustedLoc.ToCoordsXY()); + loc += TileDirectionDelta[chosenDirection]; + tileElement = map_get_first_element_at(loc.ToCoordsXY()); if (tileElement == nullptr) { return PATH_SEARCH_FAILED; @@ -300,7 +297,7 @@ static uint8_t footpath_element_dest_in_dir( { case TILE_ELEMENT_TYPE_TRACK: { - if (adjustedLoc.z != tileElement->base_height) + if (loc.z != tileElement->base_height) continue; ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); auto ride = get_ride(rideIndex); @@ -312,7 +309,7 @@ static uint8_t footpath_element_dest_in_dir( } break; case TILE_ELEMENT_TYPE_ENTRANCE: - if (adjustedLoc.z != tileElement->base_height) + if (loc.z != tileElement->base_height) continue; switch (tileElement->AsEntrance()->GetEntranceType()) { @@ -337,14 +334,14 @@ static uint8_t footpath_element_dest_in_dir( } break; case TILE_ELEMENT_TYPE_PATH: - if (!is_valid_path_z_and_direction(tileElement, adjustedLoc.z, chosenDirection)) + if (!is_valid_path_z_and_direction(tileElement, loc.z, chosenDirection)) continue; if (tileElement->AsPath()->IsWide()) return PATH_SEARCH_WIDE; uint8_t edges = path_get_permitted_edges(tileElement->AsPath()); edges &= ~(1 << direction_reverse(chosenDirection)); - adjustedLoc.z = tileElement->base_height; + loc.z = tileElement->base_height; for (Direction dir : ALL_DIRECTIONS) { @@ -359,10 +356,10 @@ static uint8_t footpath_element_dest_in_dir( { if (tileElement->AsPath()->GetSlopeDirection() == dir) { - adjustedLoc.z += 2; + loc.z += 2; } } - return footpath_element_dest_in_dir(adjustedLoc, dir, outRideIndex, level + 1); + return footpath_element_dest_in_dir(loc, dir, outRideIndex, level + 1); } return PATH_SEARCH_DEAD_END; } @@ -395,18 +392,17 @@ static uint8_t footpath_element_dest_in_dir( * width path, for example that leads from a ride exit back to the main path. */ static uint8_t footpath_element_destination_in_direction( - const TileCoordsXYZ& loc, PathElement* pathElement, Direction chosenDirection, ride_id_t* outRideIndex) + TileCoordsXYZ loc, PathElement* pathElement, Direction chosenDirection, ride_id_t* outRideIndex) { - auto adjustedLoc = loc; if (pathElement->IsSloped()) { if (pathElement->GetSlopeDirection() == chosenDirection) { - adjustedLoc.z += 2; + loc.z += 2; } } - return footpath_element_dest_in_dir(adjustedLoc, chosenDirection, outRideIndex, 0); + return footpath_element_dest_in_dir(loc, chosenDirection, outRideIndex, 0); } /** @@ -598,19 +594,17 @@ static int32_t CalculateHeuristicPathingScore(const TileCoordsXYZ& loc1, const T * rct2: 0x0069A997 */ static void peep_pathfind_heuristic_search( - const TileCoordsXYZ& loc, Peep* peep, TileElement* currentTileElement, bool inPatrolArea, uint8_t counter, - uint16_t* endScore, Direction test_edge, uint8_t* endJunctions, TileCoordsXYZ junctionList[16], uint8_t directionList[16], + TileCoordsXYZ loc, Peep* peep, TileElement* currentTileElement, bool inPatrolArea, uint8_t counter, uint16_t* endScore, + Direction test_edge, uint8_t* endJunctions, TileCoordsXYZ junctionList[16], uint8_t directionList[16], TileCoordsXYZ* endXYZ, uint8_t* endSteps) { uint8_t searchResult = PATH_SEARCH_FAILED; - auto adjustedLoc = loc; - bool currentElementIsWide = (currentTileElement->AsPath()->IsWide() - && !staff_can_ignore_wide_flag(peep, adjustedLoc.x * 32, adjustedLoc.y * 32, adjustedLoc.z, currentTileElement)); + && !staff_can_ignore_wide_flag(peep, loc.x * 32, loc.y * 32, loc.z, currentTileElement)); - adjustedLoc += TileDirectionDelta[test_edge]; + loc += TileDirectionDelta[test_edge]; ++counter; _peepPathFindTilesChecked--; @@ -618,9 +612,8 @@ static void peep_pathfind_heuristic_search( /* If this is where the search started this is a search loop and the * current search path ends here. * Return without updating the parameters (best result so far). */ - if ((_peepPathFindHistory[0].location.x == (uint8_t)adjustedLoc.x) - && (_peepPathFindHistory[0].location.y == (uint8_t)adjustedLoc.y) - && (_peepPathFindHistory[0].location.z == adjustedLoc.z)) + if ((_peepPathFindHistory[0].location.x == (uint8_t)loc.x) && (_peepPathFindHistory[0].location.y == (uint8_t)loc.y) + && (_peepPathFindHistory[0].location.z == loc.z)) { #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 if (gPathFindDebug) @@ -634,7 +627,7 @@ static void peep_pathfind_heuristic_search( bool nextInPatrolArea = inPatrolArea; if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_MECHANIC) { - nextInPatrolArea = staff_is_location_in_patrol(peep, adjustedLoc.x * 32, adjustedLoc.y * 32); + nextInPatrolArea = staff_is_location_in_patrol(peep, loc.x * 32, loc.y * 32); if (inPatrolArea && !nextInPatrolArea) { /* The mechanic will leave his patrol area by taking @@ -652,7 +645,7 @@ static void peep_pathfind_heuristic_search( /* Get the next map element of interest in the direction of test_edge. */ bool found = false; - TileElement* tileElement = map_get_first_element_at(adjustedLoc.ToCoordsXY()); + TileElement* tileElement = map_get_first_element_at(loc.ToCoordsXY()); if (tileElement == nullptr) { return; @@ -670,7 +663,7 @@ static void peep_pathfind_heuristic_search( { case TILE_ELEMENT_TYPE_TRACK: { - if (adjustedLoc.z != tileElement->base_height) + if (loc.z != tileElement->base_height) continue; /* For peeps heading for a shop, the goal is the shop * tile. */ @@ -684,7 +677,7 @@ static void peep_pathfind_heuristic_search( break; } case TILE_ELEMENT_TYPE_ENTRANCE: - if (adjustedLoc.z != tileElement->base_height) + if (loc.z != tileElement->base_height) continue; Direction direction; searchResult = PATH_SEARCH_OTHER; @@ -734,16 +727,16 @@ static void peep_pathfind_heuristic_search( * queue path. * Otherwise, peeps walk on path tiles to get to the goal. */ - if (!is_valid_path_z_and_direction(tileElement, adjustedLoc.z, test_edge)) + if (!is_valid_path_z_and_direction(tileElement, loc.z, test_edge)) continue; // Path may be sloped, so set z to path base height. - adjustedLoc.z = tileElement->base_height; + loc.z = tileElement->base_height; if (tileElement->AsPath()->IsWide()) { /* Check if staff can ignore this wide flag. */ - if (!staff_can_ignore_wide_flag(peep, adjustedLoc.x * 32, adjustedLoc.y * 32, adjustedLoc.z, tileElement)) + if (!staff_can_ignore_wide_flag(peep, loc.x * 32, loc.y * 32, loc.z, tileElement)) { searchResult = PATH_SEARCH_WIDE; found = true; @@ -803,7 +796,7 @@ static void peep_pathfind_heuristic_search( * Ignore for now. */ // Calculate the heuristic score of this map element. - uint16_t new_score = CalculateHeuristicPathingScore(adjustedLoc, gPeepPathFindGoalPosition); + uint16_t new_score = CalculateHeuristicPathingScore(loc, gPeepPathFindGoalPosition); /* If this map element is the search goal the current search path ends here. */ if (new_score == 0) @@ -816,7 +809,7 @@ static void peep_pathfind_heuristic_search( *endScore = new_score; *endSteps = counter; // Update the end x,y,z - *endXYZ = adjustedLoc; + *endXYZ = loc; // Update the telemetry *endJunctions = _peepPathFindMaxJunctions - _peepPathFindNumJunctions; for (uint8_t junctInd = 0; junctInd < *endJunctions; junctInd++) @@ -874,7 +867,7 @@ static void peep_pathfind_heuristic_search( *endScore = new_score; *endSteps = counter; // Update the end x,y,z - *endXYZ = adjustedLoc; + *endXYZ = loc; // Update the telemetry *endJunctions = _peepPathFindMaxJunctions - _peepPathFindNumJunctions; for (uint8_t junctInd = 0; junctInd < *endJunctions; junctInd++) @@ -942,7 +935,7 @@ static void peep_pathfind_heuristic_search( *endScore = new_score; *endSteps = counter; // Update the end x,y,z - *endXYZ = adjustedLoc; + *endXYZ = loc; // Update the telemetry *endJunctions = _peepPathFindMaxJunctions - _peepPathFindNumJunctions; for (uint8_t junctInd = 0; junctInd < *endJunctions; junctInd++) @@ -970,7 +963,7 @@ static void peep_pathfind_heuristic_search( { /* Check if this is a thin junction. And perform additional * necessary checks. */ - thin_junction = path_is_thin_junction(tileElement->AsPath(), adjustedLoc); + thin_junction = path_is_thin_junction(tileElement->AsPath(), loc); if (thin_junction) { @@ -990,8 +983,7 @@ static void peep_pathfind_heuristic_search( * already been visited by the peep while heading for this goal. */ for (auto& pathfindHistory : peep->pathfind_history) { - if (pathfindHistory.x == adjustedLoc.x && pathfindHistory.y == adjustedLoc.y - && pathfindHistory.z == adjustedLoc.z) + if (pathfindHistory.x == loc.x && pathfindHistory.y == loc.y && pathfindHistory.z == loc.z) { if (pathfindHistory.direction == 0) { @@ -1018,9 +1010,9 @@ static void peep_pathfind_heuristic_search( for (int32_t junctionNum = _peepPathFindNumJunctions + 1; junctionNum <= _peepPathFindMaxJunctions; junctionNum++) { - if ((_peepPathFindHistory[junctionNum].location.x == (uint8_t)adjustedLoc.x) - && (_peepPathFindHistory[junctionNum].location.y == (uint8_t)adjustedLoc.y) - && (_peepPathFindHistory[junctionNum].location.z == adjustedLoc.z)) + if ((_peepPathFindHistory[junctionNum].location.x == (uint8_t)loc.x) + && (_peepPathFindHistory[junctionNum].location.y == (uint8_t)loc.y) + && (_peepPathFindHistory[junctionNum].location.z == loc.z)) { pathLoop = true; break; @@ -1053,7 +1045,7 @@ static void peep_pathfind_heuristic_search( *endScore = new_score; *endSteps = counter; // Update the end x,y,z - *endXYZ = adjustedLoc; + *endXYZ = loc; // Update the telemetry *endJunctions = _peepPathFindMaxJunctions; // - _peepPathFindNumJunctions; for (uint8_t junctInd = 0; junctInd < *endJunctions; junctInd++) @@ -1078,9 +1070,9 @@ static void peep_pathfind_heuristic_search( /* This junction was NOT previously visited in the current * search path, so add the junction to the history. */ - _peepPathFindHistory[_peepPathFindNumJunctions].location.x = (uint8_t)adjustedLoc.x; - _peepPathFindHistory[_peepPathFindNumJunctions].location.y = (uint8_t)adjustedLoc.y; - _peepPathFindHistory[_peepPathFindNumJunctions].location.z = adjustedLoc.z; + _peepPathFindHistory[_peepPathFindNumJunctions].location.x = (uint8_t)loc.x; + _peepPathFindHistory[_peepPathFindNumJunctions].location.y = (uint8_t)loc.y; + _peepPathFindHistory[_peepPathFindNumJunctions].location.z = loc.z; // .direction take is added below. _peepPathFindNumJunctions--; @@ -1094,7 +1086,7 @@ static void peep_pathfind_heuristic_search( edges &= ~(1 << next_test_edge); uint8_t savedNumJunctions = _peepPathFindNumJunctions; - uint8_t height = adjustedLoc.z; + uint8_t height = loc.z; if (tileElement->AsPath()->IsSloped() && tileElement->AsPath()->GetSlopeDirection() == next_test_edge) { height += 2; @@ -1125,8 +1117,8 @@ static void peep_pathfind_heuristic_search( } peep_pathfind_heuristic_search( - { adjustedLoc.x, adjustedLoc.y, height }, peep, tileElement, nextInPatrolArea, counter, endScore, - next_test_edge, endJunctions, junctionList, directionList, endXYZ, endSteps); + { loc.x, loc.y, height }, peep, tileElement, nextInPatrolArea, counter, endScore, next_test_edge, endJunctions, + junctionList, directionList, endXYZ, endSteps); _peepPathFindNumJunctions = savedNumJunctions; #if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2 diff --git a/src/openrct2/ride/thrill/MagicCarpet.cpp b/src/openrct2/ride/thrill/MagicCarpet.cpp index 953ca2a385..5fdc65e84f 100644 --- a/src/openrct2/ride/thrill/MagicCarpet.cpp +++ b/src/openrct2/ride/thrill/MagicCarpet.cpp @@ -119,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, const CoordsXYZ& offset, - const CoordsXYZ& bbOffset, const CoordsXYZ& bbSize) + paint_session* session, Ride* ride, uint8_t direction, uint32_t swingImageId, CoordsXYZ offset, const CoordsXYZ& bbOffset, + const CoordsXYZ& bbSize) { rct_ride_entry* rideEntry = ride->GetRideEntry(); uint32_t vehicleImageId = rideEntry->vehicles[0].base_image_id + direction; @@ -133,27 +133,26 @@ static void paint_magic_carpet_vehicle( } int8_t directionalOffset = MagicCarpetOscillationXY[swingImageId]; - auto directedOffset = offset; switch (direction) { case 0: - directedOffset.x -= directionalOffset; + offset.x -= directionalOffset; break; case 1: - directedOffset.y += directionalOffset; + offset.y += directionalOffset; break; case 2: - directedOffset.x += directionalOffset; + offset.x += directionalOffset; break; case 3: - directedOffset.y -= directionalOffset; + offset.y -= directionalOffset; break; } - directedOffset.z += MagicCarpetOscillationZ[swingImageId]; + offset.z += MagicCarpetOscillationZ[swingImageId]; sub_98199C( - session, vehicleImageId | imageColourFlags, (int8_t)directedOffset.x, (int8_t)directedOffset.y, bbSize.x, bbSize.y, 127, - directedOffset.z, bbOffset.x, bbOffset.y, bbOffset.z); + session, vehicleImageId | imageColourFlags, (int8_t)offset.x, (int8_t)offset.y, bbSize.x, bbSize.y, 127, offset.z, + bbOffset.x, bbOffset.y, bbOffset.z); // Riders rct_drawpixelinfo* dpi = &session->DPI; @@ -169,8 +168,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)directedOffset.x, (int8_t)directedOffset.y, bbSize.x, bbSize.y, 127, - directedOffset.z, bbOffset.x, bbOffset.y, bbOffset.z); + session, imageId, (int8_t)offset.x, (int8_t)offset.y, bbSize.x, bbSize.y, 127, offset.z, bbOffset.x, + bbOffset.y, bbOffset.z); } } } diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index def6f1f330..5425c7e2c0 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -75,9 +75,8 @@ void MoneyEffect::CreateAt(money32 value, int32_t x, int32_t y, int32_t z, bool * * rct2: 0x0069C5D0 */ -void MoneyEffect::Create(money32 value, const CoordsXYZ& loc) +void MoneyEffect::Create(money32 value, CoordsXYZ loc) { - auto validLoc = loc; if (loc.isNull()) { // If game actions return no valid location of the action we can not use the screen @@ -98,10 +97,10 @@ void MoneyEffect::Create(money32 value, const CoordsXYZ& loc) if (!mapPositionXY) return; - validLoc = { *mapPositionXY, tile_element_height(*mapPositionXY) }; + loc = { *mapPositionXY, tile_element_height(*mapPositionXY) }; } - validLoc.z += 10; - CreateAt(-value, validLoc.x, validLoc.y, validLoc.z, false); + loc.z += 10; + CreateAt(-value, loc.x, loc.y, loc.z, false); } /** diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index fcb48fe8ed..b803eff9c0 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, const CoordsXYZ& loc); + static void Create(money32 value, CoordsXYZ loc); void Update(); std::pair GetStringId() const; };