Merge pull request #9877 from ZehMatt/peep-cleanup

Cleanup some Peep/Guest/Staff code
This commit is contained in:
Duncan 2019-08-21 19:12:47 +01:00 committed by GitHub
commit 066e6cc619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 166 deletions

View File

@ -439,7 +439,7 @@ void Guest::GivePassingPeepsPurpleClothes(Guest* passingPeep)
{ {
passingPeep->tshirt_colour = COLOUR_BRIGHT_PURPLE; passingPeep->tshirt_colour = COLOUR_BRIGHT_PURPLE;
passingPeep->trousers_colour = COLOUR_BRIGHT_PURPLE; passingPeep->trousers_colour = COLOUR_BRIGHT_PURPLE;
invalidate_sprite_2((rct_sprite*)passingPeep); passingPeep->Invalidate();
} }
void Guest::GivePassingPeepsPizza(Guest* passingPeep) void Guest::GivePassingPeepsPizza(Guest* passingPeep)
@ -455,15 +455,12 @@ void Guest::GivePassingPeepsPizza(Guest* passingPeep)
{ {
if (passingPeep->action == PEEP_ACTION_NONE_1 || passingPeep->action == PEEP_ACTION_NONE_2) if (passingPeep->action == PEEP_ACTION_NONE_1 || passingPeep->action == PEEP_ACTION_NONE_2)
{ {
Invalidate();
passingPeep->action = PEEP_ACTION_WAVE_2; passingPeep->action = PEEP_ACTION_WAVE_2;
passingPeep->action_frame = 0; passingPeep->action_frame = 0;
passingPeep->action_sprite_image_offset = 0; passingPeep->action_sprite_image_offset = 0;
passingPeep->UpdateCurrentActionSpriteType(); passingPeep->UpdateCurrentActionSpriteType();
invalidate_sprite_2((rct_sprite*)passingPeep);
} }
} }
invalidate_sprite_2((rct_sprite*)passingPeep);
} }
void Guest::MakePassingPeepsSick(Guest* passingPeep) void Guest::MakePassingPeepsSick(Guest* passingPeep)
@ -479,7 +476,6 @@ void Guest::MakePassingPeepsSick(Guest* passingPeep)
passingPeep->action_frame = 0; passingPeep->action_frame = 0;
passingPeep->action_sprite_image_offset = 0; passingPeep->action_sprite_image_offset = 0;
passingPeep->UpdateCurrentActionSpriteType(); passingPeep->UpdateCurrentActionSpriteType();
invalidate_sprite_2((rct_sprite*)passingPeep);
} }
} }
@ -525,7 +521,6 @@ void Guest::UpdateEasterEggInteractions()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
} }
} }
@ -1053,7 +1048,6 @@ void Guest::Tick128UpdateGuest(int32_t index)
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
invalidate_sprite_2((rct_sprite*)this);
} }
} }
} }
@ -1236,11 +1230,9 @@ void Guest::UpdateSitting()
z, z,
}; };
Invalidate();
MoveTo(loc.x, loc.y, loc.z); MoveTo(loc.x, loc.y, loc.z);
sprite_direction = ((var_37 + 2) & 3) * 8; sprite_direction = ((var_37 + 2) & 3) * 8;
Invalidate();
action = PEEP_ACTION_NONE_1; action = PEEP_ACTION_NONE_1;
next_action_sprite_type = PEEP_ACTION_SPRITE_TYPE_SITTING_IDLE; next_action_sprite_type = PEEP_ACTION_SPRITE_TYPE_SITTING_IDLE;
SwitchNextActionSpriteType(); SwitchNextActionSpriteType();
@ -1292,7 +1284,6 @@ void Guest::UpdateSitting()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
return; return;
} }
@ -1321,7 +1312,6 @@ void Guest::UpdateSitting()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
return; return;
} }
} }
@ -2416,7 +2406,6 @@ void Guest::ReadMap()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
} }
@ -3380,6 +3369,7 @@ void Guest::UpdateBuying()
if (action != PEEP_ACTION_NONE_2) if (action != PEEP_ACTION_NONE_2)
{ {
UpdateAction(); UpdateAction();
Invalidate();
return; return;
} }
@ -3419,7 +3409,6 @@ void Guest::UpdateBuying()
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
ride->no_primary_items_sold++; ride->no_primary_items_sold++;
} }
@ -3486,8 +3475,6 @@ void Guest::UpdateRideAtEntrance()
// this is the state it will return to. // this is the state it will return to.
if (destination_tolerance != 0) if (destination_tolerance != 0)
{ {
Invalidate();
int16_t xy_distance; int16_t xy_distance;
if (auto loc = UpdateAction(xy_distance)) if (auto loc = UpdateAction(xy_distance))
{ {
@ -3498,12 +3485,12 @@ void Guest::UpdateRideAtEntrance()
actionZ = entrance.z * 8 + 2; actionZ = entrance.z * 8 + 2;
} }
MoveTo((*loc).x, (*loc).y, actionZ); MoveTo((*loc).x, (*loc).y, actionZ);
Invalidate();
} }
else else
{ {
destination_tolerance = 0; destination_tolerance = 0;
sprite_direction ^= (1 << 4); sprite_direction ^= (1 << 4);
Invalidate();
} }
} }
@ -3703,8 +3690,6 @@ void Guest::UpdateRideAdvanceThroughEntrance()
sub_state = PEEP_RIDE_FREE_VEHICLE_CHECK; sub_state = PEEP_RIDE_FREE_VEHICLE_CHECK;
} }
Invalidate();
actionZ = ride->stations[current_ride_station].Height * 8; actionZ = ride->stations[current_ride_station].Height * 8;
distanceThreshold += 4; distanceThreshold += 4;
@ -3714,7 +3699,6 @@ void Guest::UpdateRideAdvanceThroughEntrance()
} }
MoveTo((*loc).x, (*loc).y, actionZ); MoveTo((*loc).x, (*loc).y, actionZ);
Invalidate();
return; return;
} }
@ -3823,8 +3807,7 @@ static void peep_go_to_ride_exit(Peep* peep, Ride* ride, int16_t x, int16_t y, i
{ {
z += RideData5[ride->type].z; z += RideData5[ride->type].z;
sprite_move(x, y, z, (rct_sprite*)peep); peep->MoveTo(x, y, z);
peep->Invalidate();
Guard::Assert(peep->current_ride_station < MAX_STATIONS); Guard::Assert(peep->current_ride_station < MAX_STATIONS);
auto exit = ride_get_exit_location(ride, peep->current_ride_station); auto exit = ride_get_exit_location(ride, peep->current_ride_station);
@ -4058,9 +4041,7 @@ void Guest::UpdateRideApproachVehicle()
{ {
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
sub_state = PEEP_RIDE_ENTER_VEHICLE; sub_state = PEEP_RIDE_ENTER_VEHICLE;
@ -4098,9 +4079,7 @@ void Guest::UpdateRideEnterVehicle()
ride->cur_num_customers++; ride->cur_num_customers++;
vehicle->mass += seatedPeepAsGuest->mass; vehicle->mass += seatedPeepAsGuest->mass;
seatedPeepAsGuest->Invalidate(); seatedPeepAsGuest->MoveTo(LOCATION_NULL, 0, 0);
sprite_move(LOCATION_NULL, 0, 0, reinterpret_cast<rct_sprite*>(seatedPeepAsGuest));
seatedPeepAsGuest->SetState(PEEP_STATE_ON_RIDE); seatedPeepAsGuest->SetState(PEEP_STATE_ON_RIDE);
seatedPeepAsGuest->time_on_ride = 0; seatedPeepAsGuest->time_on_ride = 0;
seatedPeepAsGuest->sub_state = PEEP_RIDE_ON_RIDE; seatedPeepAsGuest->sub_state = PEEP_RIDE_ON_RIDE;
@ -4114,7 +4093,6 @@ void Guest::UpdateRideEnterVehicle()
vehicle->mass += mass; vehicle->mass += mass;
invalidate_sprite_2(reinterpret_cast<rct_sprite*>(vehicle)); invalidate_sprite_2(reinterpret_cast<rct_sprite*>(vehicle));
Invalidate();
MoveTo(LOCATION_NULL, 0, 0); MoveTo(LOCATION_NULL, 0, 0);
SetState(PEEP_STATE_ON_RIDE); SetState(PEEP_STATE_ON_RIDE);
@ -4321,7 +4299,6 @@ void Guest::UpdateRideLeaveVehicle()
exitWaypointLoc.z += 15; exitWaypointLoc.z += 15;
MoveTo(exitWaypointLoc.x, exitWaypointLoc.y, exitWaypointLoc.z); MoveTo(exitWaypointLoc.x, exitWaypointLoc.y, exitWaypointLoc.z);
Invalidate();
waypointLoc.x += vehicleEntry->peep_loading_waypoints[var_37 / 4][1].x; waypointLoc.x += vehicleEntry->peep_loading_waypoints[var_37 / 4][1].x;
waypointLoc.y += vehicleEntry->peep_loading_waypoints[var_37 / 4][1].y; waypointLoc.y += vehicleEntry->peep_loading_waypoints[var_37 / 4][1].y;
@ -4387,9 +4364,7 @@ void Guest::UpdateRideApproachExit()
{ {
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
@ -4410,21 +4385,17 @@ void Guest::UpdateRideInExit()
if (auto loc = UpdateAction(xy_distance)) if (auto loc = UpdateAction(xy_distance))
{ {
Invalidate();
if (xy_distance >= 16) if (xy_distance >= 16)
{ {
int16_t actionZ = ride->stations[current_ride_station].Height * 8; int16_t actionZ = ride->stations[current_ride_station].Height * 8;
actionZ += RideData5[ride->type].z; actionZ += RideData5[ride->type].z;
MoveTo((*loc).x, (*loc).y, actionZ); MoveTo((*loc).x, (*loc).y, actionZ);
Invalidate();
return; return;
} }
SwitchToSpecialSprite(0); SwitchToSpecialSprite(0);
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
} }
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO)
@ -4475,9 +4446,7 @@ void Guest::UpdateRideApproachVehicleWaypoints()
{ {
actionZ = z; actionZ = z;
} }
Invalidate();
MoveTo((*loc).x, (*loc).y, actionZ); MoveTo((*loc).x, (*loc).y, actionZ);
Invalidate();
return; return;
} }
@ -4549,9 +4518,7 @@ void Guest::UpdateRideApproachExitWaypoints()
{ {
actionZ = z; actionZ = z;
} }
Invalidate();
MoveTo((*loc).x, (*loc).y, actionZ); MoveTo((*loc).x, (*loc).y, actionZ);
Invalidate();
return; return;
} }
@ -4630,9 +4597,7 @@ void Guest::UpdateRideApproachSpiralSlide()
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
@ -4761,7 +4726,6 @@ void Guest::UpdateRideOnSpiralSlide()
MoveTo(newX, newY, z); MoveTo(newX, newY, z);
sprite_direction = (var_37 & 0xC) * 2; sprite_direction = (var_37 & 0xC) * 2;
Invalidate();
var_37++; var_37++;
return; return;
@ -4773,11 +4737,10 @@ void Guest::UpdateRideOnSpiralSlide()
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
uint8_t waypoint = 2; uint8_t waypoint = 2;
var_37 = (var_37 * 4 & 0x30) + waypoint; var_37 = (var_37 * 4 & 0x30) + waypoint;
@ -4805,9 +4768,7 @@ void Guest::UpdateRideLeaveSpiralSlide()
// waypoint 0. Then it readies to leave the ride by the entrance. // waypoint 0. Then it readies to leave the ride by the entrance.
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
@ -4887,9 +4848,7 @@ void Guest::UpdateRideMazePathfinding()
{ {
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
@ -4911,7 +4870,6 @@ void Guest::UpdateRideMazePathfinding()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
} }
@ -5033,9 +4991,7 @@ void Guest::UpdateRideMazePathfinding()
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
} }
@ -5052,9 +5008,7 @@ void Guest::UpdateRideLeaveExit()
{ {
if (ride != nullptr) if (ride != nullptr)
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, ride->stations[current_ride_station].Height * 8); MoveTo((*loc).x, (*loc).y, ride->stations[current_ride_station].Height * 8);
Invalidate();
} }
return; return;
} }
@ -5093,7 +5047,6 @@ void Guest::UpdateRideLeaveExit()
continue; continue;
MoveTo(x, y, height); MoveTo(x, y, height);
Invalidate();
return; return;
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
} }
@ -5106,9 +5059,7 @@ void Guest::UpdateRideShopApproach()
{ {
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
@ -5178,9 +5129,7 @@ void Guest::UpdateRideShopLeave()
{ {
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
if ((x & 0xFFE0) != next_x) if ((x & 0xFFE0) != next_x)
return; return;
@ -5338,14 +5287,11 @@ void Guest::UpdateWalking()
{ {
if ((0xFFFF & scenario_rand()) < 936) if ((0xFFFF & scenario_rand()) < 936)
{ {
Invalidate();
action = PEEP_ACTION_WAVE_2; action = PEEP_ACTION_WAVE_2;
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
} }
} }
@ -5356,14 +5302,11 @@ void Guest::UpdateWalking()
{ {
if ((0xFFFF & scenario_rand()) < 936) if ((0xFFFF & scenario_rand()) < 936)
{ {
Invalidate();
action = PEEP_ACTION_TAKE_PHOTO; action = PEEP_ACTION_TAKE_PHOTO;
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
} }
} }
@ -5374,14 +5317,11 @@ void Guest::UpdateWalking()
{ {
if ((0xFFFF & scenario_rand()) < 936) if ((0xFFFF & scenario_rand()) < 936)
{ {
Invalidate();
action = PEEP_ACTION_DRAW_PICTURE; action = PEEP_ACTION_DRAW_PICTURE;
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
} }
} }
@ -5469,11 +5409,8 @@ void Guest::UpdateWalking()
int32_t water_height = surfaceElement->GetWaterHeight(); int32_t water_height = surfaceElement->GetWaterHeight();
if (water_height) if (water_height)
{ {
Invalidate();
water_height *= 16; water_height *= 16;
MoveTo(x, y, water_height); MoveTo(x, y, water_height);
Invalidate();
SetState(PEEP_STATE_FALLING); SetState(PEEP_STATE_FALLING);
return; return;
} }
@ -5678,7 +5615,6 @@ void Guest::UpdateQueuing()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
if (time_in_queue >= 3500 && (0xFFFF & scenario_rand()) <= 93) if (time_in_queue >= 3500 && (0xFFFF & scenario_rand()) <= 93)
{ {
@ -5719,7 +5655,6 @@ void Guest::UpdateQueuing()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
break; break;
default: default:
break; break;
@ -5757,9 +5692,7 @@ void Guest::UpdateEnteringPark()
} }
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
SetState(PEEP_STATE_FALLING); SetState(PEEP_STATE_FALLING);
@ -5790,9 +5723,7 @@ void Guest::UpdateLeavingPark()
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
Invalidate();
MoveTo((*loc).x, (*loc).y, z); MoveTo((*loc).x, (*loc).y, z);
Invalidate();
return; return;
} }
@ -5808,7 +5739,7 @@ void Guest::UpdateLeavingPark()
PerformNextAction(pathingResult); PerformNextAction(pathingResult);
if (!(pathingResult & PATHING_OUTSIDE_PARK)) if (!(pathingResult & PATHING_OUTSIDE_PARK))
return; return;
peep_sprite_remove(this); Remove();
} }
/** /**
@ -5830,7 +5761,6 @@ void Guest::UpdateWatching()
destination_y = y; destination_y = y;
sprite_direction = (var_37 & 3) * 8; sprite_direction = (var_37 & 3) * 8;
Invalidate();
action = PEEP_ACTION_NONE_1; action = PEEP_ACTION_NONE_1;
next_action_sprite_type = PEEP_ACTION_SPRITE_TYPE_WATCH_RIDE; next_action_sprite_type = PEEP_ACTION_SPRITE_TYPE_WATCH_RIDE;
@ -5848,7 +5778,7 @@ void Guest::UpdateWatching()
{ {
// 6917F6 // 6917F6
UpdateAction(); UpdateAction();
Invalidate();
if (action != PEEP_ACTION_NONE_2) if (action != PEEP_ACTION_NONE_2)
return; return;
action = PEEP_ACTION_NONE_1; action = PEEP_ACTION_NONE_1;
@ -5863,7 +5793,6 @@ void Guest::UpdateWatching()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
return; return;
} }
} }
@ -5874,7 +5803,6 @@ void Guest::UpdateWatching()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
return; return;
} }
@ -5886,7 +5814,6 @@ void Guest::UpdateWatching()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
return; return;
} }
} }
@ -5936,6 +5863,7 @@ void Guest::UpdateUsingBin()
if (action != PEEP_ACTION_NONE_2) if (action != PEEP_ACTION_NONE_2)
{ {
UpdateAction(); UpdateAction();
Invalidate();
return; return;
} }

View File

@ -347,7 +347,9 @@ void Peep::Invalidate()
void Peep::MoveTo(int16_t destX, int16_t destY, int16_t destZ) void Peep::MoveTo(int16_t destX, int16_t destY, int16_t destZ)
{ {
Invalidate(); // Invalidate current position.
sprite_move(destX, destY, destZ, (rct_sprite*)this); sprite_move(destX, destY, destZ, (rct_sprite*)this);
Invalidate(); // Invalidate new position.
} }
uint8_t Peep::GetNextDirection() const uint8_t Peep::GetNextDirection() const
@ -641,7 +643,6 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
action = PEEP_ACTION_NONE_2; action = PEEP_ACTION_NONE_2;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
return { { x, y } }; return { { x, y } };
} }
action_sprite_image_offset = peepAnimation[action_sprite_type].frame_offsets[action_frame]; action_sprite_image_offset = peepAnimation[action_sprite_type].frame_offsets[action_frame];
@ -649,7 +650,6 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
// If not throwing up and not at the frame where sick appears. // If not throwing up and not at the frame where sick appears.
if (action != PEEP_ACTION_THROW_UP || action_frame != 15) if (action != PEEP_ACTION_THROW_UP || action_frame != 15)
{ {
Invalidate();
return { { x, y } }; return { { x, y } };
} }
@ -671,7 +671,6 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
auto soundId = coughs[scenario_rand() & 3]; auto soundId = coughs[scenario_rand() & 3];
audio_play_sound_at_location(soundId, { x, y, z }); audio_play_sound_at_location(soundId, { x, y, z });
Invalidate();
return { { x, y } }; return { { x, y } };
} }
@ -732,9 +731,7 @@ void Peep::Pickup()
{ {
guest->RemoveFromRide(); guest->RemoveFromRide();
} }
Invalidate(); MoveTo(LOCATION_NULL, y, z);
sprite_move(LOCATION_NULL, y, z, (rct_sprite*)this);
SetState(PEEP_STATE_PICKED); SetState(PEEP_STATE_PICKED);
sub_state = 0; sub_state = 0;
} }
@ -744,8 +741,7 @@ void Peep::PickupAbort(int32_t old_x)
if (state != PEEP_STATE_PICKED) if (state != PEEP_STATE_PICKED)
return; return;
sprite_move(old_x, y, z + 8, (rct_sprite*)this); MoveTo(old_x, y, z + 8);
Invalidate();
if (x != (int16_t)LOCATION_NULL) if (x != (int16_t)LOCATION_NULL)
{ {
@ -797,8 +793,7 @@ bool Peep::Place(TileCoordsXYZ location, bool apply)
if (apply) if (apply)
{ {
sprite_move(destination.x, destination.y, destination.z, (rct_sprite*)this); MoveTo(destination.x, destination.y, destination.z);
Invalidate();
SetState(PEEP_STATE_FALLING); SetState(PEEP_STATE_FALLING);
action = PEEP_ACTION_NONE_2; action = PEEP_ACTION_NONE_2;
special_sprite = 0; special_sprite = 0;
@ -886,6 +881,7 @@ void Peep::UpdateFalling()
{ {
// Check to see if we are ready to drown. // Check to see if we are ready to drown.
UpdateAction(); UpdateAction();
Invalidate();
if (action == PEEP_ACTION_DROWNING) if (action == PEEP_ACTION_DROWNING)
return; return;
@ -933,7 +929,6 @@ void Peep::UpdateFalling()
if (height - 4 >= z && height < z + 20) if (height - 4 >= z && height < z + 20)
{ {
// Looks like we are drowning! // Looks like we are drowning!
Invalidate();
MoveTo(x, y, height); MoveTo(x, y, height);
auto guest = AsGuest(); auto guest = AsGuest();
@ -950,7 +945,6 @@ void Peep::UpdateFalling()
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
peep_window_state_update(this); peep_window_state_update(this);
return; return;
} }
@ -969,7 +963,6 @@ void Peep::UpdateFalling()
// This will be null if peep is falling // This will be null if peep is falling
if (saved_map == nullptr) if (saved_map == nullptr)
{ {
Invalidate();
if (z <= 1) if (z <= 1)
{ {
// Remove peep if it has gone to the void // Remove peep if it has gone to the void
@ -977,13 +970,10 @@ void Peep::UpdateFalling()
return; return;
} }
MoveTo(x, y, z - 2); MoveTo(x, y, z - 2);
Invalidate();
return; return;
} }
Invalidate();
MoveTo(x, y, saved_height); MoveTo(x, y, saved_height);
Invalidate();
next_x = x & 0xFFE0; next_x = x & 0xFFE0;
next_y = y & 0xFFE0; next_y = y & 0xFFE0;
@ -1466,7 +1456,6 @@ void peep_applause()
peep->action_frame = 0; peep->action_frame = 0;
peep->action_sprite_image_offset = 0; peep->action_sprite_image_offset = 0;
peep->UpdateCurrentActionSpriteType(); peep->UpdateCurrentActionSpriteType();
peep->Invalidate();
} }
} }
@ -1587,7 +1576,6 @@ void Peep::InsertNewThought(PeepThoughtType thoughtType, uint8_t thoughtArgument
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; ++i) for (int32_t i = 0; i < PEEP_MAX_THOUGHTS; ++i)
@ -1648,11 +1636,8 @@ Peep* Peep::Generate(const CoordsXYZ coords)
peep->sprite_height_negative = spriteBounds[peep->action_sprite_type].sprite_height_negative; peep->sprite_height_negative = spriteBounds[peep->action_sprite_type].sprite_height_negative;
peep->sprite_height_positive = spriteBounds[peep->action_sprite_type].sprite_height_positive; peep->sprite_height_positive = spriteBounds[peep->action_sprite_type].sprite_height_positive;
peep->MoveTo(coords.x, coords.y, coords.z);
peep->sprite_direction = 0; peep->sprite_direction = 0;
sprite_move(coords.x, coords.y, coords.z, (rct_sprite*)peep);
peep->Invalidate();
peep->mass = (scenario_rand() & 0x1F) + 45; peep->mass = (scenario_rand() & 0x1F) + 45;
peep->path_check_optimisation = 0; peep->path_check_optimisation = 0;
peep->interaction_ride_index = RIDE_ID_NULL; peep->interaction_ride_index = RIDE_ID_NULL;
@ -2507,10 +2492,7 @@ static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileEl
peep->destination_x += CoordsDirectionDelta[peep->direction].x; peep->destination_x += CoordsDirectionDelta[peep->direction].x;
peep->destination_y += CoordsDirectionDelta[peep->direction].y; peep->destination_y += CoordsDirectionDelta[peep->direction].y;
peep->destination_tolerance = 9; peep->destination_tolerance = 9;
peep->Invalidate(); peep->MoveTo(x, y, peep->z);
sprite_move(x, y, peep->z, (rct_sprite*)peep);
peep->Invalidate();
peep->SetState(PEEP_STATE_LEAVING_PARK); peep->SetState(PEEP_STATE_LEAVING_PARK);
peep->var_37 = 0; peep->var_37 = 0;
@ -2649,10 +2631,7 @@ static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileEl
peep->destination_x += CoordsDirectionDelta[peep->direction].x; peep->destination_x += CoordsDirectionDelta[peep->direction].x;
peep->destination_y += CoordsDirectionDelta[peep->direction].y; peep->destination_y += CoordsDirectionDelta[peep->direction].y;
peep->destination_tolerance = 7; peep->destination_tolerance = 7;
peep->MoveTo(x, y, peep->z);
peep->Invalidate();
sprite_move(x, y, peep->z, (rct_sprite*)peep);
peep->Invalidate();
} }
} }
@ -2671,9 +2650,7 @@ static void peep_footpath_move_forward(Peep* peep, int16_t x, int16_t y, TileEle
if (peep->type == PEEP_TYPE_STAFF) if (peep->type == PEEP_TYPE_STAFF)
{ {
peep->Invalidate(); peep->MoveTo(x, y, z);
sprite_move(x, y, z, (rct_sprite*)peep);
peep->Invalidate();
return; return;
} }
@ -2797,9 +2774,7 @@ static void peep_footpath_move_forward(Peep* peep, int16_t x, int16_t y, TileEle
} }
} }
peep->Invalidate(); peep->MoveTo(x, y, z);
sprite_move(x, y, z, (rct_sprite*)peep);
peep->Invalidate();
} }
/** /**
@ -3102,9 +3077,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
if ((newLoc.x & 0xFFE0) == next_x && (newLoc.y & 0xFFE0) == next_y) if ((newLoc.x & 0xFFE0) == next_x && (newLoc.y & 0xFFE0) == next_y)
{ {
int16_t height = GetZOnSlope(newLoc.x, newLoc.y); int16_t height = GetZOnSlope(newLoc.x, newLoc.y);
Invalidate();
MoveTo(newLoc.x, newLoc.y, height); MoveTo(newLoc.x, newLoc.y, height);
Invalidate();
return; return;
} }
@ -3202,9 +3175,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
SetNextFlags(0, false, true); SetNextFlags(0, false, true);
height = GetZOnSlope(newLoc.x, newLoc.y); height = GetZOnSlope(newLoc.x, newLoc.y);
Invalidate();
MoveTo(newLoc.x, newLoc.y, height); MoveTo(newLoc.x, newLoc.y, height);
Invalidate();
return; return;
} }
} }

View File

@ -1052,14 +1052,11 @@ static int32_t staff_path_finding_entertainer(Peep* peep)
{ {
if (((scenario_rand() & 0xFFFF) <= 0x4000) && (peep->action == PEEP_ACTION_NONE_1 || peep->action == PEEP_ACTION_NONE_2)) if (((scenario_rand() & 0xFFFF) <= 0x4000) && (peep->action == PEEP_ACTION_NONE_1 || peep->action == PEEP_ACTION_NONE_2))
{ {
peep->Invalidate();
peep->action = (scenario_rand() & 1) ? PEEP_ACTION_WAVE_2 : PEEP_ACTION_JOY; peep->action = (scenario_rand() & 1) ? PEEP_ACTION_WAVE_2 : PEEP_ACTION_JOY;
peep->action_frame = 0; peep->action_frame = 0;
peep->action_sprite_image_offset = 0; peep->action_sprite_image_offset = 0;
peep->UpdateCurrentActionSpriteType(); peep->UpdateCurrentActionSpriteType();
peep->Invalidate();
staff_entertainer_update_nearby_peeps(peep); staff_entertainer_update_nearby_peeps(peep);
} }
@ -1176,14 +1173,12 @@ void Staff::UpdateMowing()
if (!CheckForPath()) if (!CheckForPath())
return; return;
Invalidate();
while (true) while (true)
{ {
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
int16_t checkZ = tile_element_height(*loc); int16_t checkZ = tile_element_height(*loc);
MoveTo((*loc).x, (*loc).y, checkZ); MoveTo((*loc).x, (*loc).y, checkZ);
Invalidate();
return; return;
} }
@ -1239,7 +1234,6 @@ void Staff::UpdateWatering()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
sub_state = 1; sub_state = 1;
} }
@ -1248,6 +1242,7 @@ void Staff::UpdateWatering()
if (action != PEEP_ACTION_NONE_2) if (action != PEEP_ACTION_NONE_2)
{ {
UpdateAction(); UpdateAction();
Invalidate();
return; return;
} }
@ -1291,6 +1286,7 @@ void Staff::UpdateEmptyingBin()
{ {
if (!CheckForPath()) if (!CheckForPath())
return; return;
uint8_t pathingResult; uint8_t pathingResult;
PerformNextAction(pathingResult); PerformNextAction(pathingResult);
if (!(pathingResult & PATHING_DESTINATION_REACHED)) if (!(pathingResult & PATHING_DESTINATION_REACHED))
@ -1301,7 +1297,6 @@ void Staff::UpdateEmptyingBin()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
sub_state = 1; sub_state = 1;
} }
@ -1314,6 +1309,7 @@ void Staff::UpdateEmptyingBin()
} }
UpdateAction(); UpdateAction();
Invalidate();
if (action_frame != 11) if (action_frame != 11)
return; return;
@ -1368,8 +1364,6 @@ void Staff::UpdateSweeping()
if (!CheckForPath()) if (!CheckForPath())
return; return;
Invalidate();
if (action == PEEP_ACTION_STAFF_SWEEP && action_frame == 8) if (action == PEEP_ACTION_STAFF_SWEEP && action_frame == 8)
{ {
// Remove sick at this location // Remove sick at this location
@ -1381,7 +1375,6 @@ void Staff::UpdateSweeping()
{ {
int16_t actionZ = GetZOnSlope((*loc).x, (*loc).y); int16_t actionZ = GetZOnSlope((*loc).x, (*loc).y);
MoveTo((*loc).x, (*loc).y, actionZ); MoveTo((*loc).x, (*loc).y, actionZ);
Invalidate();
return; return;
} }
@ -1392,7 +1385,6 @@ void Staff::UpdateSweeping()
action_frame = 0; action_frame = 0;
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
return; return;
} }
StateReset(); StateReset();
@ -1487,8 +1479,6 @@ void Staff::UpdateHeadingToInspect()
// Falls through into sub_state 4 // Falls through into sub_state 4
} }
Invalidate();
int16_t delta_y = abs(y - destination_y); int16_t delta_y = abs(y - destination_y);
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
@ -1500,7 +1490,6 @@ void Staff::UpdateHeadingToInspect()
} }
MoveTo((*loc).x, (*loc).y, newZ); MoveTo((*loc).x, (*loc).y, newZ);
Invalidate();
return; return;
} }
@ -1528,7 +1517,6 @@ void Staff::UpdateAnswering()
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
sub_state = 1; sub_state = 1;
peep_window_state_update(this); peep_window_state_update(this);
@ -1545,6 +1533,7 @@ void Staff::UpdateAnswering()
return; return;
} }
UpdateAction(); UpdateAction();
Invalidate();
return; return;
} }
else if (sub_state <= 3) else if (sub_state <= 3)
@ -1601,8 +1590,6 @@ void Staff::UpdateAnswering()
// Falls through into sub_state 4 // Falls through into sub_state 4
} }
Invalidate();
int16_t delta_y = abs(y - destination_y); int16_t delta_y = abs(y - destination_y);
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
@ -1614,7 +1601,6 @@ void Staff::UpdateAnswering()
} }
MoveTo((*loc).x, (*loc).y, newZ); MoveTo((*loc).x, (*loc).y, newZ);
Invalidate();
return; return;
} }
@ -1923,11 +1909,8 @@ void Staff::UpdatePatrolling()
int32_t water_height = surfaceElement->GetWaterHeight(); int32_t water_height = surfaceElement->GetWaterHeight();
if (water_height) if (water_height)
{ {
Invalidate();
water_height *= 16; water_height *= 16;
MoveTo(x, y, water_height); MoveTo(x, y, water_height);
Invalidate();
SetState(PEEP_STATE_FALLING); SetState(PEEP_STATE_FALLING);
return; return;
} }
@ -2218,11 +2201,9 @@ bool Staff::UpdateFixingMoveToBrokenDownVehicle(bool firstRun, Ride* ride)
destination_tolerance = 2; destination_tolerance = 2;
} }
Invalidate();
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
sprite_move((*loc).x, (*loc).y, z, (rct_sprite*)this); MoveTo(loc->x, loc->y, z);
Invalidate();
return false; return false;
} }
@ -2248,7 +2229,6 @@ bool Staff::UpdateFixingFixVehicle(bool firstRun, Ride* ride)
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
action_frame = 0; action_frame = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
if (action == PEEP_ACTION_NONE_2) if (action == PEEP_ACTION_NONE_2)
@ -2257,6 +2237,7 @@ bool Staff::UpdateFixingFixVehicle(bool firstRun, Ride* ride)
} }
UpdateAction(); UpdateAction();
Invalidate();
uint8_t actionFrame = (action == PEEP_ACTION_STAFF_FIX) ? 0x25 : 0x50; uint8_t actionFrame = (action == PEEP_ACTION_STAFF_FIX) ? 0x25 : 0x50;
if (action_frame != actionFrame) if (action_frame != actionFrame)
@ -2290,7 +2271,6 @@ bool Staff::UpdateFixingFixVehicleMalfunction(bool firstRun, Ride* ride)
action_frame = 0; action_frame = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
if (action == PEEP_ACTION_NONE_2) if (action == PEEP_ACTION_NONE_2)
@ -2299,6 +2279,8 @@ bool Staff::UpdateFixingFixVehicleMalfunction(bool firstRun, Ride* ride)
} }
UpdateAction(); UpdateAction();
Invalidate();
if (action_frame != 0x65) if (action_frame != 0x65)
{ {
return false; return false;
@ -2375,12 +2357,9 @@ bool Staff::UpdateFixingMoveToStationEnd(bool firstRun, Ride* ride)
destination_tolerance = 2; destination_tolerance = 2;
} }
Invalidate();
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
sprite_move((*loc).x, (*loc).y, z, (rct_sprite*)this); MoveTo(loc->x, loc->y, z);
Invalidate();
return false; return false;
} }
@ -2403,7 +2382,6 @@ bool Staff::UpdateFixingFixStationEnd(bool firstRun)
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
if (action == PEEP_ACTION_NONE_2) if (action == PEEP_ACTION_NONE_2)
@ -2412,6 +2390,7 @@ bool Staff::UpdateFixingFixStationEnd(bool firstRun)
} }
UpdateAction(); UpdateAction();
Invalidate();
return false; return false;
} }
@ -2490,12 +2469,9 @@ bool Staff::UpdateFixingMoveToStationStart(bool firstRun, Ride* ride)
destination_tolerance = 2; destination_tolerance = 2;
} }
Invalidate();
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
sprite_move((*loc).x, (*loc).y, z, (rct_sprite*)this); MoveTo(loc->x, loc->y, z);
Invalidate();
return false; return false;
} }
@ -2525,7 +2501,6 @@ bool Staff::UpdateFixingFixStationStart(bool firstRun, Ride* ride)
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
if (action == PEEP_ACTION_NONE_2) if (action == PEEP_ACTION_NONE_2)
@ -2554,7 +2529,6 @@ bool Staff::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride)
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
if (action == PEEP_ACTION_NONE_2) if (action == PEEP_ACTION_NONE_2)
@ -2563,6 +2537,8 @@ bool Staff::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride)
} }
UpdateAction(); UpdateAction();
Invalidate();
if (action_frame == 0x28) if (action_frame == 0x28)
{ {
ride->mechanic_status = RIDE_MECHANIC_STATUS_HAS_FIXED_STATION_BRAKES; ride->mechanic_status = RIDE_MECHANIC_STATUS_HAS_FIXED_STATION_BRAKES;
@ -2612,11 +2588,9 @@ bool Staff::UpdateFixingMoveToStationExit(bool firstRun, Ride* ride)
destination_tolerance = 2; destination_tolerance = 2;
} }
Invalidate();
if (auto loc = UpdateAction()) if (auto loc = UpdateAction())
{ {
sprite_move((*loc).x, (*loc).y, z, (rct_sprite*)this); MoveTo(loc->x, loc->y, z);
Invalidate();
return false; return false;
} }
else else
@ -2655,12 +2629,12 @@ bool Staff::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride* r
action_sprite_image_offset = 0; action_sprite_image_offset = 0;
UpdateCurrentActionSpriteType(); UpdateCurrentActionSpriteType();
Invalidate();
} }
if (action != PEEP_ACTION_NONE_2) if (action != PEEP_ACTION_NONE_2)
{ {
UpdateAction(); UpdateAction();
Invalidate();
return false; return false;
} }
@ -2705,7 +2679,6 @@ bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride)
destination_tolerance = 2; destination_tolerance = 2;
} }
Invalidate();
int16_t xy_distance; int16_t xy_distance;
if (auto loc = UpdateAction(xy_distance)) if (auto loc = UpdateAction(xy_distance))
{ {
@ -2716,9 +2689,7 @@ bool Staff::UpdateFixingLeaveByEntranceExit(bool firstRun, Ride* ride)
stationHeight += RideData5[ride->type].z; stationHeight += RideData5[ride->type].z;
} }
sprite_move((*loc).x, (*loc).y, stationHeight, (rct_sprite*)this); MoveTo(loc->x, loc->y, stationHeight);
Invalidate();
return false; return false;
} }
SetState(PEEP_STATE_FALLING); SetState(PEEP_STATE_FALLING);