forked from rosebudai/OpenRCT2-Web
Remove direct access to DirectionX and DirectionY
This commit is contained in:
9 files changed
+123
-158
No files matched your search
+58
-81
@@ -1021,8 +1021,8 @@ void Guest::TryGetUpFromSitting()
|
||||
SetState(PeepState::Walking);
|
||||
|
||||
// Set destination to the centre of the tile.
|
||||
DestinationX = (x & 0xFFE0) + 16;
|
||||
DestinationY = (y & 0xFFE0) + 16;
|
||||
auto destination = GetLocation().ToTileCentre();
|
||||
SetDestination(destination);
|
||||
DestinationTolerance = 5;
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
@@ -1076,8 +1076,8 @@ void Guest::UpdateSitting()
|
||||
SetState(PeepState::Walking);
|
||||
|
||||
// Set destination to the centre of the tile
|
||||
DestinationX = (x & 0xFFE0) + 16;
|
||||
DestinationY = (y & 0xFFE0) + 16;
|
||||
auto destination = GetLocation().ToTileCentre();
|
||||
SetDestination(destination);
|
||||
DestinationTolerance = 5;
|
||||
UpdateCurrentActionSpriteType();
|
||||
return;
|
||||
@@ -2294,8 +2294,7 @@ void Guest::GoToRideEntrance(Ride* ride)
|
||||
location.x += x_shift;
|
||||
location.y += y_shift;
|
||||
|
||||
DestinationX = location.x;
|
||||
DestinationY = location.y;
|
||||
SetDestination(location);
|
||||
DestinationTolerance = 2;
|
||||
|
||||
SetState(PeepState::EnteringRide);
|
||||
@@ -3123,8 +3122,9 @@ void Guest::UpdateBuying()
|
||||
window_invalidate_by_number(WC_PEEP, sprite_index);
|
||||
}
|
||||
sprite_direction ^= 0x10;
|
||||
DestinationX = NextLoc.x + 16;
|
||||
DestinationY = NextLoc.y + 16;
|
||||
|
||||
auto destination = CoordsXY{ 16, 16 } + NextLoc;
|
||||
SetDestination(destination);
|
||||
PeepDirection = direction_reverse(PeepDirection);
|
||||
|
||||
SetState(PeepState::Walking);
|
||||
@@ -3302,8 +3302,7 @@ static void peep_update_ride_leave_entrance_maze(Guest* peep, Ride* ride, Coords
|
||||
entrance_loc.x += _MazeEntranceStart[direction / 4].x;
|
||||
entrance_loc.y += _MazeEntranceStart[direction / 4].y;
|
||||
|
||||
peep->DestinationX = entrance_loc.x;
|
||||
peep->DestinationY = entrance_loc.y;
|
||||
peep->SetDestination(entrance_loc);
|
||||
peep->DestinationTolerance = 3;
|
||||
|
||||
ride->cur_num_customers++;
|
||||
@@ -3323,8 +3322,7 @@ static void peep_update_ride_leave_entrance_spiral_slide(Guest* peep, Ride* ride
|
||||
|
||||
entrance_loc += SpiralSlideWalkingPath[peep->Var37];
|
||||
|
||||
peep->DestinationX = entrance_loc.x;
|
||||
peep->DestinationY = entrance_loc.y;
|
||||
peep->SetDestination(entrance_loc);
|
||||
peep->CurrentCar = 0;
|
||||
|
||||
ride->cur_num_customers++;
|
||||
@@ -3391,8 +3389,7 @@ static void peep_update_ride_leave_entrance_waypoints(Peep* peep, Ride* ride)
|
||||
waypoint.x += vehicle_type->peep_loading_waypoints[peep->Var37 / 4][0].x;
|
||||
waypoint.y += vehicle_type->peep_loading_waypoints[peep->Var37 / 4][0].y;
|
||||
|
||||
peep->DestinationX = waypoint.x;
|
||||
peep->DestinationY = waypoint.y;
|
||||
peep->SetDestination(waypoint);
|
||||
peep->RideSubState = PeepRideSubState::ApproachVehicleWaypoints;
|
||||
}
|
||||
|
||||
@@ -3501,8 +3498,7 @@ void Guest::UpdateRideAdvanceThroughEntrance()
|
||||
|
||||
if (vehicle_type->flags & VEHICLE_ENTRY_FLAG_DODGEM_CAR_PLACEMENT)
|
||||
{
|
||||
DestinationX = vehicle->x;
|
||||
DestinationY = vehicle->y;
|
||||
SetDestination(vehicle->GetLocation());
|
||||
DestinationTolerance = 15;
|
||||
RideSubState = PeepRideSubState::ApproachVehicle;
|
||||
return;
|
||||
@@ -3521,21 +3517,23 @@ void Guest::UpdateRideAdvanceThroughEntrance()
|
||||
load_position = vehicle_type->peep_loading_positions[loadPositionIndex];
|
||||
}
|
||||
|
||||
auto destination = GetDestination();
|
||||
switch (vehicle->sprite_direction / 8)
|
||||
{
|
||||
case 0:
|
||||
DestinationX = vehicle->x - load_position;
|
||||
destination.x = vehicle->x - load_position;
|
||||
break;
|
||||
case 1:
|
||||
DestinationY = vehicle->y + load_position;
|
||||
destination.y = vehicle->y + load_position;
|
||||
break;
|
||||
case 2:
|
||||
DestinationX = vehicle->x + load_position;
|
||||
destination.x = vehicle->x + load_position;
|
||||
break;
|
||||
case 3:
|
||||
DestinationY = vehicle->y - load_position;
|
||||
destination.y = vehicle->y - load_position;
|
||||
break;
|
||||
}
|
||||
SetDestination(destination);
|
||||
|
||||
RideSubState = PeepRideSubState::ApproachVehicle;
|
||||
}
|
||||
@@ -3582,8 +3580,7 @@ static void peep_go_to_ride_exit(Peep* peep, Ride* ride, int16_t x, int16_t y, i
|
||||
x -= x_shift;
|
||||
y -= y_shift;
|
||||
|
||||
peep->DestinationX = x;
|
||||
peep->DestinationY = y;
|
||||
peep->SetDestination({ x, y });
|
||||
peep->DestinationTolerance = 2;
|
||||
|
||||
peep->sprite_direction = exit_direction * 8;
|
||||
@@ -3663,8 +3660,7 @@ static void peep_update_ride_no_free_vehicle_rejoin_queue(Peep* peep, Ride* ride
|
||||
x += 16 - DirectionOffsets[entranceLocation.direction].x * 20;
|
||||
y += 16 - DirectionOffsets[entranceLocation.direction].y * 20;
|
||||
|
||||
peep->DestinationX = x;
|
||||
peep->DestinationY = y;
|
||||
peep->SetDestination({ x, y });
|
||||
peep->DestinationTolerance = 2;
|
||||
|
||||
peep->SetState(PeepState::QueuingFront);
|
||||
@@ -4058,8 +4054,7 @@ void Guest::UpdateRideLeaveVehicle()
|
||||
waypointLoc.x += vehicleEntry->peep_loading_waypoints[Var37 / 4][1].x;
|
||||
waypointLoc.y += vehicleEntry->peep_loading_waypoints[Var37 / 4][1].y;
|
||||
|
||||
DestinationX = waypointLoc.x;
|
||||
DestinationY = waypointLoc.y;
|
||||
SetDestination(waypointLoc);
|
||||
DestinationTolerance = 2;
|
||||
RideSubState = PeepRideSubState::ApproachExitWaypoints;
|
||||
}
|
||||
@@ -4105,8 +4100,7 @@ static void peep_update_ride_prepare_for_exit(Peep* peep)
|
||||
x -= x_shift;
|
||||
y -= y_shift;
|
||||
|
||||
peep->DestinationX = x;
|
||||
peep->DestinationY = y;
|
||||
peep->SetDestination({ x, y });
|
||||
peep->DestinationTolerance = 2;
|
||||
peep->RideSubState = PeepRideSubState::InExit;
|
||||
}
|
||||
@@ -4240,8 +4234,7 @@ void Guest::UpdateRideApproachVehicleWaypoints()
|
||||
targetLoc.x += vehicle_type->peep_loading_waypoints[Var37 / 4][waypoint].x;
|
||||
targetLoc.y += vehicle_type->peep_loading_waypoints[Var37 / 4][waypoint].y;
|
||||
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4308,8 +4301,7 @@ void Guest::UpdateRideApproachExitWaypoints()
|
||||
targetLoc.x += vehicleEntry->peep_loading_waypoints[Var37 / 4][Var37 & 3].x;
|
||||
targetLoc.y += vehicleEntry->peep_loading_waypoints[Var37 / 4][Var37 & 3].y;
|
||||
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4339,8 +4331,7 @@ void Guest::UpdateRideApproachExitWaypoints()
|
||||
targetLoc.x -= x_shift;
|
||||
targetLoc.y -= y_shift;
|
||||
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4364,8 +4355,7 @@ void Guest::UpdateRideApproachSpiralSlide()
|
||||
if (waypoint == 3)
|
||||
{
|
||||
SubState = 15;
|
||||
DestinationX = 0;
|
||||
DestinationY = 0;
|
||||
SetDestination({ 0, 0 });
|
||||
Var37 = (Var37 / 4) & 0xC;
|
||||
MoveTo({ LOCATION_NULL, y, z });
|
||||
return;
|
||||
@@ -4393,8 +4383,7 @@ void Guest::UpdateRideApproachSpiralSlide()
|
||||
assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE);
|
||||
targetLoc += SpiralSlideWalkingPath[Var37];
|
||||
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
RideSubState = PeepRideSubState::LeaveSpiralSlide;
|
||||
return;
|
||||
}
|
||||
@@ -4408,8 +4397,7 @@ void Guest::UpdateRideApproachSpiralSlide()
|
||||
assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE);
|
||||
targetLoc += SpiralSlideWalkingPath[Var37];
|
||||
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
}
|
||||
|
||||
/** rct2: 0x00981F0C, 0x00981F0E */
|
||||
@@ -4438,14 +4426,17 @@ void Guest::UpdateRideOnSpiralSlide()
|
||||
if (ride == nullptr || ride->type != RIDE_TYPE_SPIRAL_SLIDE)
|
||||
return;
|
||||
|
||||
auto destination = GetDestination();
|
||||
if ((Var37 & 3) == 0)
|
||||
{
|
||||
switch (DestinationX)
|
||||
switch (destination.x)
|
||||
{
|
||||
case 0:
|
||||
DestinationY++;
|
||||
if (DestinationY >= 30)
|
||||
DestinationX++;
|
||||
destination.y++;
|
||||
if (destination.y >= 30)
|
||||
destination.x++;
|
||||
|
||||
SetDestination(destination);
|
||||
return;
|
||||
case 1:
|
||||
if (ride->slide_in_use != 0)
|
||||
@@ -4455,7 +4446,9 @@ void Guest::UpdateRideOnSpiralSlide()
|
||||
ride->slide_peep = sprite_index;
|
||||
ride->slide_peep_t_shirt_colour = TshirtColour;
|
||||
ride->spiral_slide_progress = 0;
|
||||
DestinationX++;
|
||||
destination.x++;
|
||||
|
||||
SetDestination(destination);
|
||||
return;
|
||||
case 2:
|
||||
return;
|
||||
@@ -4465,8 +4458,8 @@ void Guest::UpdateRideOnSpiralSlide()
|
||||
uint8_t dir = (Var37 / 4) & 3;
|
||||
|
||||
// Set the location that the peep walks to go on slide again
|
||||
DestinationX = newLocation.x + _SpiralSlideEndWaypoint[dir].x;
|
||||
DestinationY = newLocation.y + _SpiralSlideEndWaypoint[dir].y;
|
||||
destination = newLocation + _SpiralSlideEndWaypoint[dir];
|
||||
SetDestination(destination);
|
||||
|
||||
// Move the peep sprite to just at the end of the slide
|
||||
newLocation.x += _SpiralSlideEnd[dir].x;
|
||||
@@ -4498,8 +4491,7 @@ void Guest::UpdateRideOnSpiralSlide()
|
||||
assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE);
|
||||
targetLoc += SpiralSlideWalkingPath[Var37];
|
||||
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
RideSubState = PeepRideSubState::ApproachSpiralSlide;
|
||||
}
|
||||
|
||||
@@ -4539,8 +4531,7 @@ void Guest::UpdateRideLeaveSpiralSlide()
|
||||
assert(ride->type == RIDE_TYPE_SPIRAL_SLIDE);
|
||||
targetLoc += SpiralSlideWalkingPath[Var37];
|
||||
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
return;
|
||||
}
|
||||
waypoint = 3;
|
||||
@@ -4560,8 +4551,7 @@ void Guest::UpdateRideLeaveSpiralSlide()
|
||||
targetLoc.x -= xShift;
|
||||
targetLoc.y -= yShift;
|
||||
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
}
|
||||
|
||||
/** rct2: 0x00981FE4 */
|
||||
@@ -4613,7 +4603,7 @@ void Guest::UpdateRideMazePathfinding()
|
||||
}
|
||||
}
|
||||
|
||||
CoordsXY targetLoc = { DestinationX & 0xFFE0, DestinationY & 0xFFE0 };
|
||||
auto targetLoc = GetDestination().ToTileStart();
|
||||
|
||||
int16_t stationBaseZ = ride->stations[0].GetBaseZ();
|
||||
|
||||
@@ -4649,11 +4639,7 @@ void Guest::UpdateRideMazePathfinding()
|
||||
uint8_t chosenEdge = hedges[scenario_rand() % openCount];
|
||||
assert(chosenEdge != 0xFF);
|
||||
|
||||
targetLoc.x = CoordsDirectionDelta[chosenEdge].x / 2;
|
||||
targetLoc.y = CoordsDirectionDelta[chosenEdge].y / 2;
|
||||
|
||||
targetLoc.x += DestinationX;
|
||||
targetLoc.y += DestinationY;
|
||||
targetLoc = GetDestination() + CoordsDirectionDelta[chosenEdge] / 2;
|
||||
|
||||
enum class maze_type
|
||||
{
|
||||
@@ -4692,15 +4678,12 @@ void Guest::UpdateRideMazePathfinding()
|
||||
MazeLastEdge &= 3;
|
||||
return;
|
||||
case maze_type::hedge:
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
|
||||
SetDestination(targetLoc);
|
||||
Var37 = _MazeGetNewDirectionFromEdge[Var37 / 4][chosenEdge];
|
||||
MazeLastEdge = chosenEdge;
|
||||
break;
|
||||
case maze_type::entrance_or_exit:
|
||||
targetLoc.x = DestinationX;
|
||||
targetLoc.y = DestinationY;
|
||||
targetLoc = GetDestination();
|
||||
if (chosenEdge & 1)
|
||||
{
|
||||
targetLoc.x = targetLoc.ToTileCentre().x;
|
||||
@@ -4709,8 +4692,7 @@ void Guest::UpdateRideMazePathfinding()
|
||||
{
|
||||
targetLoc.y = targetLoc.ToTileCentre().y;
|
||||
}
|
||||
DestinationX = targetLoc.x;
|
||||
DestinationY = targetLoc.y;
|
||||
SetDestination(targetLoc);
|
||||
Var37 = 16;
|
||||
MazeLastEdge = chosenEdge;
|
||||
break;
|
||||
@@ -4807,8 +4789,7 @@ void Guest::UpdateRideShopInteract()
|
||||
{
|
||||
RideSubState = PeepRideSubState::LeaveShop;
|
||||
|
||||
DestinationX = tileCenterX;
|
||||
DestinationY = tileCenterY;
|
||||
SetDestination({ tileCenterX, tileCenterY });
|
||||
DestinationTolerance = 3;
|
||||
HappinessTarget = std::min(HappinessTarget + 30, PEEP_MAX_HAPPINESS);
|
||||
Happiness = HappinessTarget;
|
||||
@@ -4835,8 +4816,7 @@ void Guest::UpdateRideShopInteract()
|
||||
|
||||
RideSubState = PeepRideSubState::LeaveShop;
|
||||
|
||||
DestinationX = tileCenterX;
|
||||
DestinationY = tileCenterY;
|
||||
SetDestination({ tileCenterX, tileCenterY });
|
||||
DestinationTolerance = 3;
|
||||
|
||||
HappinessTarget = std::min(HappinessTarget + 30, PEEP_MAX_HAPPINESS);
|
||||
@@ -5099,7 +5079,7 @@ void Guest::UpdateWalking()
|
||||
|
||||
// Check if vehicle is blocking the destination tile
|
||||
auto curPos = TileCoordsXYZ(CoordsXYZ{ x, y, z });
|
||||
auto dstPos = TileCoordsXYZ(CoordsXYZ{ DestinationX, DestinationY, NextLoc.z });
|
||||
auto dstPos = TileCoordsXYZ(CoordsXYZ{ GetDestination(), NextLoc.z });
|
||||
if (curPos.x != dstPos.x || curPos.y != dstPos.y)
|
||||
{
|
||||
if (footpath_is_blocked_by_vehicle(dstPos))
|
||||
@@ -5245,8 +5225,7 @@ void Guest::UpdateWalking()
|
||||
int32_t destX = (x & 0xFFE0) + _WatchingPositionOffsets[Var37 & 0x1F].x;
|
||||
int32_t destY = (y & 0xFFE0) + _WatchingPositionOffsets[Var37 & 0x1F].y;
|
||||
|
||||
DestinationX = destX;
|
||||
DestinationY = destY;
|
||||
SetDestination({ destX, destY });
|
||||
DestinationTolerance = 3;
|
||||
|
||||
if (CurrentSeat & 1)
|
||||
@@ -5468,8 +5447,7 @@ void Guest::UpdateWatching()
|
||||
if (!(pathingResult & PATHING_DESTINATION_REACHED))
|
||||
return;
|
||||
|
||||
DestinationX = x;
|
||||
DestinationY = y;
|
||||
SetDestination(GetLocation());
|
||||
|
||||
sprite_direction = (Var37 & 3) * 8;
|
||||
|
||||
@@ -5541,8 +5519,9 @@ void Guest::UpdateWatching()
|
||||
SetState(PeepState::Walking);
|
||||
UpdateSpriteType();
|
||||
// Send peep to the centre of current tile.
|
||||
DestinationX = (x & 0xFFE0) + 16;
|
||||
DestinationY = (y & 0xFFE0) + 16;
|
||||
|
||||
auto destination = GetLocation().ToTileCentre();
|
||||
SetDestination(destination);
|
||||
DestinationTolerance = 5;
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
@@ -5773,8 +5752,7 @@ bool Guest::UpdateWalkingFindBench()
|
||||
int32_t benchX = (x & 0xFFE0) + BenchUseOffsets[Var37 & 0x7].x;
|
||||
int32_t benchY = (y & 0xFFE0) + BenchUseOffsets[Var37 & 0x7].y;
|
||||
|
||||
DestinationX = benchX;
|
||||
DestinationY = benchY;
|
||||
SetDestination({ benchX, benchY });
|
||||
DestinationTolerance = 3;
|
||||
|
||||
return true;
|
||||
@@ -5853,8 +5831,7 @@ bool Guest::UpdateWalkingFindBin()
|
||||
int32_t binX = (peep->x & 0xFFE0) + BinUseOffsets[peep->Var37 & 0x3].x;
|
||||
int32_t binY = (peep->y & 0xFFE0) + BinUseOffsets[peep->Var37 & 0x3].y;
|
||||
|
||||
peep->DestinationX = binX;
|
||||
peep->DestinationY = binY;
|
||||
peep->SetDestination({ binX, binY });
|
||||
peep->DestinationTolerance = 3;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -132,9 +132,6 @@ static int32_t peep_move_one_tile(Direction direction, Peep* peep)
|
||||
}
|
||||
|
||||
peep->PeepDirection = direction;
|
||||
peep->DestinationX = newTile.x;
|
||||
peep->DestinationY = newTile.y;
|
||||
peep->DestinationTolerance = 2;
|
||||
if (peep->State != PeepState::Queuing)
|
||||
{
|
||||
// When peeps are walking along a path, we would like them to be spread out across the width of the path,
|
||||
@@ -154,24 +151,25 @@ static int32_t peep_move_one_tile(Direction direction, Peep* peep)
|
||||
// coordinate constant, but instead clamp it to an acceptable range. This brings in 'outlier' guests from
|
||||
// the edges of the path, while allowing guests who are already in an acceptable position to stay there.
|
||||
|
||||
int8_t offset = (scenario_rand() & 7) - 3;
|
||||
const int8_t offset = (scenario_rand() & 7) - 3;
|
||||
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
|
||||
peep->DestinationX += offset;
|
||||
const uint16_t centerLine = (peep->y & 0xFFE0) + COORDS_XY_HALF_TILE;
|
||||
peep->DestinationY = std::clamp(
|
||||
peep->y, static_cast<int16_t>(centerLine - 3), static_cast<int16_t>(centerLine + 3));
|
||||
const int32_t centerLine = (peep->y & 0xFFE0) + COORDS_XY_HALF_TILE;
|
||||
newTile.x += offset;
|
||||
newTile.y = std::clamp<int32_t>(peep->y, centerLine - 3, centerLine + 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Peep is moving along Y, so apply the offset to the Y position of the destination and clamp their current X
|
||||
const uint16_t centerLine = (peep->x & 0xFFE0) + COORDS_XY_HALF_TILE;
|
||||
peep->DestinationX = std::clamp(
|
||||
peep->x, static_cast<int16_t>(centerLine - 3), static_cast<int16_t>(centerLine + 3));
|
||||
peep->DestinationY += offset;
|
||||
const int32_t centerLine = (peep->x & 0xFFE0) + COORDS_XY_HALF_TILE;
|
||||
newTile.x = std::clamp<int32_t>(peep->x, centerLine - 3, centerLine + 3);
|
||||
newTile.y += offset;
|
||||
}
|
||||
}
|
||||
peep->SetDestination(newTile);
|
||||
peep->DestinationTolerance = 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -606,7 +606,8 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
|
||||
Action = PeepActionType::None2;
|
||||
}
|
||||
|
||||
CoordsXY diffrenceLoc = { x - DestinationX, y - DestinationY };
|
||||
CoordsXY diffrenceLoc = GetLocation();
|
||||
diffrenceLoc -= GetDestination();
|
||||
|
||||
int32_t x_delta = abs(diffrenceLoc.x);
|
||||
int32_t y_delta = abs(diffrenceLoc.y);
|
||||
@@ -1028,8 +1029,7 @@ void Peep::Update1()
|
||||
SetState(PeepState::Patrolling);
|
||||
}
|
||||
|
||||
DestinationX = x;
|
||||
DestinationY = y;
|
||||
SetDestination(GetLocation());
|
||||
DestinationTolerance = 10;
|
||||
PeepDirection = sprite_direction >> 3;
|
||||
}
|
||||
@@ -2287,8 +2287,8 @@ static bool peep_update_queue_position(Peep* peep, PeepActionType previous_actio
|
||||
static void peep_return_to_centre_of_tile(Peep* peep)
|
||||
{
|
||||
peep->PeepDirection = direction_reverse(peep->PeepDirection);
|
||||
peep->DestinationX = (peep->x & 0xFFE0) + 16;
|
||||
peep->DestinationY = (peep->y & 0xFFE0) + 16;
|
||||
auto destination = peep->GetLocation().ToTileCentre();
|
||||
peep->SetDestination(destination);
|
||||
peep->DestinationTolerance = 5;
|
||||
}
|
||||
|
||||
@@ -2454,8 +2454,8 @@ static bool peep_interact_with_entrance(Peep* peep, const CoordsXYE& coords, uin
|
||||
}
|
||||
}
|
||||
|
||||
peep->DestinationX += CoordsDirectionDelta[peep->PeepDirection].x;
|
||||
peep->DestinationY += CoordsDirectionDelta[peep->PeepDirection].y;
|
||||
auto destination = peep->GetDestination() + CoordsDirectionDelta[peep->PeepDirection];
|
||||
peep->SetDestination(destination);
|
||||
peep->DestinationTolerance = 9;
|
||||
peep->MoveTo({ coords, peep->z });
|
||||
peep->SetState(PeepState::LeavingPark);
|
||||
@@ -2592,8 +2592,9 @@ static bool peep_interact_with_entrance(Peep* peep, const CoordsXYE& coords, uin
|
||||
window_invalidate_by_number(WC_PARK_INFORMATION, 0);
|
||||
|
||||
peep->Var37 = 1;
|
||||
peep->DestinationX += CoordsDirectionDelta[peep->PeepDirection].x;
|
||||
peep->DestinationY += CoordsDirectionDelta[peep->PeepDirection].y;
|
||||
auto destination = peep->GetDestination();
|
||||
destination += CoordsDirectionDelta[peep->PeepDirection];
|
||||
peep->SetDestination(destination);
|
||||
peep->DestinationTolerance = 7;
|
||||
peep->MoveTo({ coords, peep->z });
|
||||
}
|
||||
@@ -2934,8 +2935,7 @@ static bool peep_interact_with_shop(Peep* peep, const CoordsXYE& coords)
|
||||
}
|
||||
|
||||
auto coordsCentre = coords.ToTileCentre();
|
||||
peep->DestinationX = coordsCentre.x;
|
||||
peep->DestinationY = coordsCentre.y;
|
||||
peep->SetDestination(coordsCentre);
|
||||
peep->DestinationTolerance = 3;
|
||||
|
||||
peep->CurrentRide = rideIndex;
|
||||
|
||||
+31
-42
@@ -653,8 +653,7 @@ bool Staff::DoHandymanPathFinding()
|
||||
}
|
||||
|
||||
PeepDirection = newDirection;
|
||||
DestinationX = chosenTile.x + 16;
|
||||
DestinationY = chosenTile.y + 16;
|
||||
SetDestination(chosenTile + CoordsXY{ 16, 16 });
|
||||
DestinationTolerance = 3;
|
||||
if (State == PeepState::Queuing)
|
||||
{
|
||||
@@ -872,8 +871,7 @@ bool Staff::DoMechanicPathFinding()
|
||||
}
|
||||
|
||||
PeepDirection = newDirection;
|
||||
DestinationX = chosenTile.x + 16;
|
||||
DestinationY = chosenTile.y + 16;
|
||||
SetDestination(chosenTile + CoordsXY{ 16, 16 });
|
||||
DestinationTolerance = (scenario_rand() & 7) + 2;
|
||||
|
||||
return false;
|
||||
@@ -951,8 +949,7 @@ bool Staff::DoMiscPathFinding()
|
||||
}
|
||||
|
||||
PeepDirection = newDirection;
|
||||
DestinationX = chosenTile.x + 16;
|
||||
DestinationY = chosenTile.y + 16;
|
||||
SetDestination(chosenTile + CoordsXY{ 16, 16 });
|
||||
DestinationTolerance = (scenario_rand() & 7) + 2;
|
||||
|
||||
return false;
|
||||
@@ -1173,8 +1170,8 @@ void Staff::UpdateMowing()
|
||||
return;
|
||||
}
|
||||
|
||||
DestinationX = _MowingWaypoints[Var37].x + NextLoc.x;
|
||||
DestinationY = _MowingWaypoints[Var37].y + NextLoc.y;
|
||||
auto destination = _MowingWaypoints[Var37] + NextLoc;
|
||||
SetDestination(destination);
|
||||
|
||||
if (Var37 != 7)
|
||||
continue;
|
||||
@@ -1449,8 +1446,7 @@ void Staff::UpdateHeadingToInspect()
|
||||
int32_t destX = NextLoc.x + 16 + DirectionOffsets[PeepDirection].x * 53;
|
||||
int32_t destY = NextLoc.y + 16 + DirectionOffsets[PeepDirection].y * 53;
|
||||
|
||||
DestinationX = destX;
|
||||
DestinationY = destY;
|
||||
SetDestination({ destX, destY });
|
||||
DestinationTolerance = 2;
|
||||
sprite_direction = PeepDirection << 3;
|
||||
|
||||
@@ -1459,7 +1455,7 @@ void Staff::UpdateHeadingToInspect()
|
||||
// Falls through into SubState 4
|
||||
}
|
||||
|
||||
int16_t delta_y = abs(y - DestinationY);
|
||||
int16_t delta_y = abs(y - GetDestination().y);
|
||||
if (auto loc = UpdateAction())
|
||||
{
|
||||
int32_t newZ = ride->stations[CurrentRideStation].GetBaseZ();
|
||||
@@ -1560,8 +1556,7 @@ void Staff::UpdateAnswering()
|
||||
int32_t destX = NextLoc.x + 16 + DirectionOffsets[PeepDirection].x * 53;
|
||||
int32_t destY = NextLoc.y + 16 + DirectionOffsets[PeepDirection].y * 53;
|
||||
|
||||
DestinationX = destX;
|
||||
DestinationY = destY;
|
||||
SetDestination({ destX, destY });
|
||||
DestinationTolerance = 2;
|
||||
sprite_direction = PeepDirection << 3;
|
||||
|
||||
@@ -1570,7 +1565,7 @@ void Staff::UpdateAnswering()
|
||||
// Falls through into SubState 4
|
||||
}
|
||||
|
||||
int16_t delta_y = abs(y - DestinationY);
|
||||
int16_t delta_y = abs(y - GetDestination().y);
|
||||
if (auto loc = UpdateAction())
|
||||
{
|
||||
int32_t newZ = ride->stations[CurrentRideStation].GetBaseZ();
|
||||
@@ -1655,8 +1650,8 @@ bool Staff::UpdatePatrollingFindWatering()
|
||||
Var37 = chosen_position;
|
||||
|
||||
SubState = 0;
|
||||
DestinationX = (x & 0xFFE0) + _WateringUseOffsets[chosen_position].x;
|
||||
DestinationY = (y & 0xFFE0) + _WateringUseOffsets[chosen_position].y;
|
||||
auto destination = _WateringUseOffsets[chosen_position] + GetLocation().ToTileStart();
|
||||
SetDestination(destination);
|
||||
DestinationTolerance = 3;
|
||||
|
||||
return true;
|
||||
@@ -1724,8 +1719,8 @@ bool Staff::UpdatePatrollingFindBin()
|
||||
SetState(PeepState::EmptyingBin);
|
||||
|
||||
SubState = 0;
|
||||
DestinationX = (x & 0xFFE0) + BinUseOffsets[chosen_position].x;
|
||||
DestinationY = (y & 0xFFE0) + BinUseOffsets[chosen_position].y;
|
||||
auto destination = BinUseOffsets[chosen_position] + GetLocation().ToTileStart();
|
||||
SetDestination(destination);
|
||||
DestinationTolerance = 3;
|
||||
return true;
|
||||
}
|
||||
@@ -1753,8 +1748,9 @@ bool Staff::UpdatePatrollingFindGrass()
|
||||
SetState(PeepState::Mowing);
|
||||
Var37 = 0;
|
||||
// Original code used .y for both x and y. Changed to .x to make more sense (both x and y are 28)
|
||||
DestinationX = NextLoc.x + _MowingWaypoints[0].x;
|
||||
DestinationY = NextLoc.y + _MowingWaypoints[0].y;
|
||||
|
||||
auto destination = _MowingWaypoints[0] + NextLoc;
|
||||
SetDestination(destination);
|
||||
DestinationTolerance = 3;
|
||||
return true;
|
||||
}
|
||||
@@ -1781,8 +1777,7 @@ bool Staff::UpdatePatrollingFindSweeping()
|
||||
SetState(PeepState::Sweeping);
|
||||
|
||||
Var37 = 0;
|
||||
DestinationX = litter->x;
|
||||
DestinationY = litter->y;
|
||||
SetDestination(litter->GetLocation());
|
||||
DestinationTolerance = 5;
|
||||
return true;
|
||||
}
|
||||
@@ -2166,8 +2161,8 @@ bool Staff::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, const Ride* ride)
|
||||
}
|
||||
|
||||
CoordsXY offset = DirectionOffsets[PeepDirection];
|
||||
DestinationX = (offset.x * -12) + vehicle->x;
|
||||
DestinationY = (offset.y * -12) + vehicle->y;
|
||||
auto destination = (offset * -12) + vehicle->GetLocation();
|
||||
SetDestination(destination);
|
||||
DestinationTolerance = 2;
|
||||
}
|
||||
|
||||
@@ -2309,17 +2304,16 @@ bool Staff::UpdateFixingMoveToStationEnd(bool firstRun, const Ride* ride)
|
||||
stationPos.x += 16 + offset.x;
|
||||
if (offset.x == 0)
|
||||
{
|
||||
stationPos.x = DestinationX;
|
||||
stationPos.x = GetDestination().x;
|
||||
}
|
||||
|
||||
stationPos.y += 16 + offset.y;
|
||||
if (offset.y == 0)
|
||||
{
|
||||
stationPos.y = DestinationY;
|
||||
stationPos.y = GetDestination().y;
|
||||
}
|
||||
|
||||
DestinationX = stationPos.x;
|
||||
DestinationY = stationPos.y;
|
||||
SetDestination(stationPos);
|
||||
DestinationTolerance = 2;
|
||||
}
|
||||
|
||||
@@ -2411,25 +2405,22 @@ bool Staff::UpdateFixingMoveToStationStart(bool firstRun, const Ride* ride)
|
||||
}
|
||||
|
||||
// loc_6C12ED:
|
||||
uint16_t destinationX = input.x + 16;
|
||||
uint16_t destinationY = input.y + 16;
|
||||
auto destination = CoordsXY{ input.x + 16, input.y + 16 };
|
||||
auto offset = _StationFixingOffsets[stationDirection];
|
||||
|
||||
CoordsXY offset = _StationFixingOffsets[stationDirection];
|
||||
|
||||
destinationX -= offset.x;
|
||||
destination.x -= offset.x;
|
||||
if (offset.x == 0)
|
||||
{
|
||||
destinationX = DestinationX;
|
||||
destination.x = GetDestination().x;
|
||||
}
|
||||
|
||||
destinationY -= offset.y;
|
||||
destination.y -= offset.y;
|
||||
if (offset.y == 0)
|
||||
{
|
||||
destinationY = DestinationY;
|
||||
destination.y = GetDestination().y;
|
||||
}
|
||||
|
||||
DestinationX = destinationX;
|
||||
DestinationY = destinationY;
|
||||
SetDestination(destination);
|
||||
DestinationTolerance = 2;
|
||||
}
|
||||
|
||||
@@ -2543,8 +2534,7 @@ bool Staff::UpdateFixingMoveToStationExit(bool firstRun, const Ride* ride)
|
||||
stationPosition.x += stationPlatformDirection.x * 20;
|
||||
stationPosition.y += stationPlatformDirection.y * 20;
|
||||
|
||||
DestinationX = stationPosition.x;
|
||||
DestinationY = stationPosition.y;
|
||||
SetDestination(stationPosition);
|
||||
DestinationTolerance = 2;
|
||||
}
|
||||
|
||||
@@ -2628,8 +2618,7 @@ bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, const Ride* ride)
|
||||
exitPosition.x -= ebx_direction.x * 19;
|
||||
exitPosition.y -= ebx_direction.y * 19;
|
||||
|
||||
DestinationX = exitPosition.x;
|
||||
DestinationY = exitPosition.y;
|
||||
SetDestination(exitPosition);
|
||||
DestinationTolerance = 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -2210,7 +2210,9 @@ void Ride::UpdateSpiralSlide()
|
||||
auto* peep = GetEntity<Guest>(slide_peep);
|
||||
if (peep != nullptr)
|
||||
{
|
||||
peep->DestinationX++;
|
||||
auto destination = peep->GetDestination();
|
||||
destination.x++;
|
||||
peep->SetDestination(destination);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -743,7 +743,7 @@ namespace OpenRCT2::Scripting
|
||||
auto peep = GetPeep();
|
||||
if (peep != nullptr)
|
||||
{
|
||||
return ToDuk(ctx, CoordsXY(peep->DestinationX, peep->DestinationY));
|
||||
return ToDuk(ctx, peep->GetDestination());
|
||||
}
|
||||
return ToDuk(ctx, nullptr);
|
||||
}
|
||||
@@ -755,8 +755,7 @@ namespace OpenRCT2::Scripting
|
||||
if (peep != nullptr)
|
||||
{
|
||||
auto pos = FromDuk<CoordsXY>(value);
|
||||
peep->DestinationX = pos.x;
|
||||
peep->DestinationY = pos.y;
|
||||
peep->SetDestination(pos);
|
||||
peep->Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,11 +424,12 @@ void footpath_interrupt_peeps(const CoordsXYZ& footpathPos)
|
||||
{
|
||||
if (peep->State == PeepState::Sitting || peep->State == PeepState::Watching)
|
||||
{
|
||||
if (peep->z == footpathPos.z)
|
||||
auto location = peep->GetLocation();
|
||||
if (location.z == footpathPos.z)
|
||||
{
|
||||
auto destination = location.ToTileCentre();
|
||||
peep->SetState(PeepState::Walking);
|
||||
peep->DestinationX = (peep->x & 0xFFE0) + 16;
|
||||
peep->DestinationY = (peep->y & 0xFFE0) + 16;
|
||||
peep->SetDestination(destination);
|
||||
peep->DestinationTolerance = 5;
|
||||
peep->UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
@@ -722,9 +722,8 @@ Peep* Park::GenerateGuest()
|
||||
peep->sprite_direction = direction << 3;
|
||||
|
||||
// Get the centre point of the tile the peep is on
|
||||
peep->DestinationX = (peep->x & 0xFFE0) + 16;
|
||||
peep->DestinationY = (peep->y & 0xFFE0) + 16;
|
||||
|
||||
auto destination = peep->GetLocation().ToTileCentre();
|
||||
peep->SetDestination(destination);
|
||||
peep->DestinationTolerance = 5;
|
||||
peep->PeepDirection = direction;
|
||||
peep->Var37 = 0;
|
||||
|
||||
@@ -96,8 +96,8 @@ protected:
|
||||
// tile away. Stepping the peep will move them towards their destination, and once they reach it, a new
|
||||
// destination will be picked, to try and get the peep towards the overall pathfinding goal.
|
||||
peep->PeepDirection = moveDir;
|
||||
peep->DestinationX = peep->x + CoordsDirectionDelta[moveDir].x;
|
||||
peep->DestinationY = peep->y + CoordsDirectionDelta[moveDir].y;
|
||||
auto destination = CoordsDirectionDelta[moveDir] + peep->GetLocation();
|
||||
peep->SetDestination(destination);
|
||||
peep->DestinationTolerance = 2;
|
||||
|
||||
// Repeatedly step the peep, until they reach the target position or until the expected number of steps have
|
||||
|
||||
Reference in new issue
Block a user