From 95624c748e92ad0afd186d8ffe1c70cd6bb48c77 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Sun, 7 Jun 2020 10:46:18 -0300 Subject: [PATCH] Prefix Peep::NextInQueue with Guest --- src/openrct2/GameStateSnapshots.cpp | 2 +- src/openrct2/peep/Guest.cpp | 6 +++--- src/openrct2/peep/Peep.cpp | 16 ++++++++-------- src/openrct2/peep/Peep.h | 2 +- src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/rct2/S6Importer.cpp | 2 +- src/openrct2/ride/Ride.cpp | 8 ++++---- test/tests/S6ImportExportTests.cpp | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 397427bc9b..a8af3ac086 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -261,7 +261,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Peep, action); COMPARE_FIELD(Peep, action_frame); COMPARE_FIELD(Peep, step_progress); - COMPARE_FIELD(Peep, NextInQueue); + COMPARE_FIELD(Peep, GuestNextInQueue); COMPARE_FIELD(Peep, MazeLastEdge); COMPARE_FIELD(Peep, InteractionRideIndex); COMPARE_FIELD(Peep, TimeInQueue); diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index d07d620948..bd1185c3c7 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -5551,14 +5551,14 @@ void Guest::UpdateQueuing() if (sub_state != 10) { bool is_front = true; - if (NextInQueue != SPRITE_INDEX_NULL) + if (GuestNextInQueue != SPRITE_INDEX_NULL) { - // Fix #4819: Occasionally the peep->NextInQueue is incorrectly set + // Fix #4819: Occasionally the peep->GuestNextInQueue is incorrectly set // to prevent this from causing the peeps to enter a loop // first check if the next in queue is actually nearby // if they are not then it's safe to assume that this is // the front of the queue. - Peep* next_peep = GET_PEEP(NextInQueue); + Peep* next_peep = GET_PEEP(GuestNextInQueue); if (abs(next_peep->x - x) < 32 && abs(next_peep->y - y) < 32) { is_front = false; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index ad5c069af2..2c94b50915 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -2266,10 +2266,10 @@ void Peep::SwitchNextActionSpriteType() static bool peep_update_queue_position(Peep* peep, uint8_t previous_action) { peep->TimeInQueue++; - if (peep->NextInQueue == SPRITE_INDEX_NULL) + if (peep->GuestNextInQueue == SPRITE_INDEX_NULL) return false; - Peep* peep_next = GET_PEEP(peep->NextInQueue); + Peep* peep_next = GET_PEEP(peep->GuestNextInQueue); int16_t x_diff = abs(peep_next->x - peep->x); int16_t y_diff = abs(peep_next->y - peep->y); @@ -2430,7 +2430,7 @@ static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileEl uint16_t previous_last = ride->stations[stationNum].LastPeepInQueue; ride->stations[stationNum].LastPeepInQueue = peep->sprite_index; - peep->NextInQueue = previous_last; + peep->GuestNextInQueue = previous_last; ride->stations[stationNum].QueueLength++; peep->current_ride = rideIndex; @@ -2858,7 +2858,7 @@ static void peep_interact_with_path(Peep* peep, int16_t x, int16_t y, TileElemen // Add the peep to the ride queue. uint16_t old_last_peep = ride->stations[stationNum].LastPeepInQueue; ride->stations[stationNum].LastPeepInQueue = peep->sprite_index; - peep->NextInQueue = old_last_peep; + peep->GuestNextInQueue = old_last_peep; ride->stations[stationNum].QueueLength++; peep_decrement_num_riders(peep); @@ -3425,7 +3425,7 @@ void Peep::RemoveFromQueue() if (sprite_index == station.LastPeepInQueue) { - station.LastPeepInQueue = NextInQueue; + station.LastPeepInQueue = GuestNextInQueue; return; } @@ -3433,12 +3433,12 @@ void Peep::RemoveFromQueue() while (spriteId != SPRITE_INDEX_NULL) { Peep* other_peep = GET_PEEP(spriteId); - if (sprite_index == other_peep->NextInQueue) + if (sprite_index == other_peep->GuestNextInQueue) { - other_peep->NextInQueue = NextInQueue; + other_peep->GuestNextInQueue = GuestNextInQueue; return; } - spriteId = other_peep->NextInQueue; + spriteId = other_peep->GuestNextInQueue; } } diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index b7f2cf6127..1410c4c051 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -665,7 +665,7 @@ struct Peep : SpriteBase union { uint16_t MechanicTimeSinceCall; // time getting to ride to fix - uint16_t NextInQueue; + uint16_t GuestNextInQueue; }; union { diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index f50300f40f..30a2bb8538 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1530,7 +1530,7 @@ private: // Doubles as staff orders dst->GuestIsLostCountdown = src->peep_is_lost_countdown; // The ID is fixed later - dst->NextInQueue = src->next_in_queue; + dst->GuestNextInQueue = src->next_in_queue; dst->PeepFlags = 0; dst->PathfindGoal.x = 0xFF; @@ -1581,7 +1581,7 @@ private: void FixPeepNextInQueue(Peep* peep, const uint16_t* spriteIndexMap) { - peep->NextInQueue = MapSpriteIndex(peep->NextInQueue, spriteIndexMap); + peep->GuestNextInQueue = MapSpriteIndex(peep->GuestNextInQueue, spriteIndexMap); } void ImportStaffPatrolArea(Peep* staffmember) diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 5c691c2d40..a7af67c6eb 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1183,7 +1183,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) dst->action = static_cast(src->action); dst->action_frame = src->action_frame; dst->step_progress = src->step_progress; - dst->next_in_queue = src->NextInQueue; + dst->next_in_queue = src->GuestNextInQueue; dst->direction = src->PeepDirection; dst->interaction_ride_index = src->InteractionRideIndex; dst->time_in_queue = src->TimeInQueue; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 76fd427c1e..fc193f0c54 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1448,7 +1448,7 @@ public: dst->action = static_cast(src->action); dst->action_frame = src->action_frame; dst->step_progress = src->step_progress; - dst->NextInQueue = src->next_in_queue; + dst->GuestNextInQueue = src->next_in_queue; dst->PeepDirection = src->direction; dst->InteractionRideIndex = src->interaction_ride_index; dst->TimeInQueue = src->time_in_queue; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 2fd381ad16..29bb9bbee4 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -309,7 +309,7 @@ Peep* Ride::GetQueueHeadGuest(StationIndex stationIndex) const uint16_t spriteIndex = stations[stationIndex].LastPeepInQueue; while ((peep = try_get_guest(spriteIndex)) != nullptr) { - spriteIndex = peep->NextInQueue; + spriteIndex = peep->GuestNextInQueue; result = peep; } return result; @@ -322,7 +322,7 @@ void Ride::UpdateQueueLength(StationIndex stationIndex) uint16_t spriteIndex = stations[stationIndex].LastPeepInQueue; while ((peep = try_get_guest(spriteIndex)) != nullptr) { - spriteIndex = peep->NextInQueue; + spriteIndex = peep->GuestNextInQueue; count++; } stations[stationIndex].QueueLength = count; @@ -333,7 +333,7 @@ void Ride::QueueInsertGuestAtFront(StationIndex stationIndex, Peep* peep) assert(stationIndex < MAX_STATIONS); assert(peep != nullptr); - peep->NextInQueue = SPRITE_INDEX_NULL; + peep->GuestNextInQueue = SPRITE_INDEX_NULL; Peep* queueHeadGuest = GetQueueHeadGuest(peep->current_ride_station); if (queueHeadGuest == nullptr) { @@ -341,7 +341,7 @@ void Ride::QueueInsertGuestAtFront(StationIndex stationIndex, Peep* peep) } else { - queueHeadGuest->NextInQueue = peep->sprite_index; + queueHeadGuest->GuestNextInQueue = peep->sprite_index; } UpdateQueueLength(peep->current_ride_station); } diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index bc1b9204d2..a684d2c0c1 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -205,7 +205,7 @@ static void CompareSpriteDataPeep(const Peep& left, const Peep& right) COMPARE_FIELD(action); COMPARE_FIELD(action_frame); COMPARE_FIELD(step_progress); - COMPARE_FIELD(NextInQueue); + COMPARE_FIELD(GuestNextInQueue); COMPARE_FIELD(MazeLastEdge); COMPARE_FIELD(InteractionRideIndex); COMPARE_FIELD(TimeInQueue);