From 571bf0dab1d840f2a5ea95fa495c3f67eb758684 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 20 Feb 2021 13:49:50 +0200 Subject: [PATCH] Apply review suggestions --- src/openrct2/peep/GuestPathfinding.cpp | 8 ++++---- src/openrct2/peep/Peep.cpp | 14 +++++++------- src/openrct2/peep/Staff.cpp | 8 +++----- src/openrct2/world/Park.cpp | 1 - 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 0c3f238c37..8100fdba08 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -155,15 +155,15 @@ static int32_t peep_move_one_tile(Direction direction, Peep* peep) if (direction == 0 || direction == 2) { // Peep is moving along X, so apply the offset to the X position of the destination and clamp their current Y - const int32_t centerLine = (peep->y & 0xFFE0) + COORDS_XY_HALF_TILE; + const int32_t centreLine = (peep->y & 0xFFE0) + COORDS_XY_HALF_TILE; newTile.x += offset; - newTile.y = std::clamp(peep->y, centerLine - 3, centerLine + 3); + newTile.y = std::clamp(peep->y, centreLine - 3, centreLine + 3); } else { // Peep is moving along Y, so apply the offset to the Y position of the destination and clamp their current X - const int32_t centerLine = (peep->x & 0xFFE0) + COORDS_XY_HALF_TILE; - newTile.x = std::clamp(peep->x, centerLine - 3, centerLine + 3); + const int32_t centreLine = (peep->x & 0xFFE0) + COORDS_XY_HALF_TILE; + newTile.x = std::clamp(peep->x, centreLine - 3, centreLine + 3); newTile.y += offset; } } diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 8e46b4c5bb..27dbb52413 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -606,11 +606,11 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) Action = PeepActionType::None2; } - CoordsXY diffrenceLoc = GetLocation(); - diffrenceLoc -= GetDestination(); + CoordsXY differenceLoc = GetLocation(); + differenceLoc -= GetDestination(); - int32_t x_delta = abs(diffrenceLoc.x); - int32_t y_delta = abs(diffrenceLoc.y); + int32_t x_delta = abs(differenceLoc.x); + int32_t y_delta = abs(differenceLoc.y); xy_distance = x_delta + y_delta; @@ -624,7 +624,7 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) if (x_delta < y_delta) { nextDirection = 8; - if (diffrenceLoc.y >= 0) + if (differenceLoc.y >= 0) { nextDirection = 24; } @@ -632,7 +632,7 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) else { nextDirection = 16; - if (diffrenceLoc.x >= 0) + if (differenceLoc.x >= 0) { nextDirection = 0; } @@ -3390,5 +3390,5 @@ void Peep::SetDestination(const CoordsXY& coords, int32_t tolerance) CoordsXY Peep::GetDestination() const { - return CoordsXY{ static_cast(DestinationX), static_cast(DestinationY) }; + return CoordsXY{ DestinationX, DestinationY }; } diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index a01b91fc21..ab0ba37458 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -1442,10 +1442,8 @@ void Staff::UpdateHeadingToInspect() PeepDirection = rideEntranceExitElement->GetDirection(); - int32_t destX = NextLoc.x + 16 + DirectionOffsets[PeepDirection].x * 53; - int32_t destY = NextLoc.y + 16 + DirectionOffsets[PeepDirection].y * 53; - - SetDestination({ destX, destY }, 2); + auto newDestination = CoordsXY{ 16, 16 } + NextLoc + (DirectionOffsets[PeepDirection] * 53); + SetDestination(newDestination, 2); sprite_direction = PeepDirection << 3; z = rideEntranceExitElement->base_height * 4; @@ -1453,7 +1451,7 @@ void Staff::UpdateHeadingToInspect() // Falls through into SubState 4 } - int16_t delta_y = abs(y - GetDestination().y); + int16_t delta_y = abs(GetLocation().y - GetDestination().y); if (auto loc = UpdateAction()) { int32_t newZ = ride->stations[CurrentRideStation].GetBaseZ(); diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 6254f8e179..2868069edc 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -721,7 +721,6 @@ Peep* Park::GenerateGuest() { peep->sprite_direction = direction << 3; - // Get the centre point of the tile the peep is on auto destination = peep->GetLocation().ToTileCentre(); peep->SetDestination(destination, 5); peep->PeepDirection = direction;