diff --git a/contributors.md b/contributors.md index a9d2eacb27..c4af6a2e87 100644 --- a/contributors.md +++ b/contributors.md @@ -138,6 +138,7 @@ The following people are not part of the development team, but have been contrib * Kevin Laframboise (klaframboise) * Tushar Sariya (TusharSariya) * (WantDiscussion) +* Tomáš Žilínek (TomasZilinek) ## Toolchain * (Balletie) - macOS diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index b3b65aaac2..a3038fa3a5 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -642,7 +642,7 @@ private: void RemoveAllGuests() const { - uint16_t spriteIndex, nextSpriteIndex; + uint16_t spriteIndex; for (auto& ride : GetRideManager()) { ride.num_riders = 0; @@ -685,14 +685,10 @@ private: } } - for (spriteIndex = gSpriteListHead[SPRITE_LIST_PEEP]; spriteIndex != SPRITE_INDEX_NULL; spriteIndex = nextSpriteIndex) + Peep* peep; + FOR_ALL_GUESTS (spriteIndex, peep) { - auto peep = &(get_sprite(spriteIndex)->peep); - nextSpriteIndex = peep->next; - if (peep->type == PEEP_TYPE_GUEST) - { - peep->Remove(); - } + peep->Remove(); } window_invalidate_by_class(WC_RIDE); diff --git a/src/openrct2/actions/StaffSetColourAction.hpp b/src/openrct2/actions/StaffSetColourAction.hpp index dd5f6aacb6..b47214dc6b 100644 --- a/src/openrct2/actions/StaffSetColourAction.hpp +++ b/src/openrct2/actions/StaffSetColourAction.hpp @@ -67,9 +67,9 @@ public: // Update each staff member's uniform int32_t spriteIndex; Peep* peep; - FOR_ALL_PEEPS (spriteIndex, peep) + FOR_ALL_STAFF (spriteIndex, peep) { - if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == _staffType) + if (peep->staff_type == _staffType) { peep->tshirt_colour = _colour; peep->trousers_colour = _colour; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 70d77a7c36..616135486e 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -404,18 +404,18 @@ int32_t peep_get_staff_count() */ void peep_update_all() { - int32_t i; + int32_t i = 0; uint16_t spriteIndex; Peep* peep; if (gScreenFlags & SCREEN_FLAGS_EDITOR) return; - spriteIndex = gSpriteListHead[SPRITE_LIST_PEEP]; - i = 0; - while (spriteIndex != SPRITE_INDEX_NULL) + // Do not use the FOR_ALL_PEEPS macro for this as next sprite index + // will be fetched on a delted peep if peep leaves the park. + for (spriteIndex = gSpriteListHead[SPRITE_LIST_PEEP]; spriteIndex != SPRITE_INDEX_NULL;) { - peep = &(get_sprite(spriteIndex)->peep); + peep = GET_PEEP(spriteIndex); spriteIndex = peep->next; if ((uint32_t)(i & 0x7F) != (gCurrentTicks & 0x7F)) diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index aff8d6d7f7..2b24a1c1f2 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -143,6 +143,7 @@ bool staff_hire_new_member(STAFF_TYPE staffType, ENTERTAINER_COSTUME entertainer void staff_update_greyed_patrol_areas() { Peep* peep; + uint16_t sprite_index; for (int32_t staff_type = 0; staff_type < STAFF_TYPE_COUNT; ++staff_type) { @@ -152,12 +153,9 @@ void staff_update_greyed_patrol_areas() gStaffPatrolAreas[staffPatrolOffset + i] = 0; } - for (uint16_t sprite_index = gSpriteListHead[SPRITE_LIST_PEEP]; sprite_index != SPRITE_INDEX_NULL; - sprite_index = peep->next) + FOR_ALL_STAFF (sprite_index, peep) { - peep = GET_PEEP(sprite_index); - - if (peep->type == PEEP_TYPE_STAFF && staff_type == peep->staff_type) + if (peep->staff_type == staff_type) { int32_t peepPatrolOffset = peep->staff_id * STAFF_PATROL_AREA_SIZE; for (int32_t i = 0; i < STAFF_PATROL_AREA_SIZE; i++)