1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 16:54:52 +01:00

Merge pull request #11274 from TomasZilinek/issue11075fix

Fix #11075 SpriteListHead Refactor
This commit is contained in:
Duncan
2020-04-18 11:55:10 +01:00
committed by GitHub
5 changed files with 15 additions and 20 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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))

View File

@@ -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++)