Use sprite_identifier when identifying entitys

The linked list index is only meant to be used for accessing the linked lists. Using the wrong variable is unlikely to cause issues for this exact case but it makes things cleaner.
This commit is contained in:
duncanspumpkin 2020-04-27 18:47:51 +01:00
parent 06bbf5ddda
commit 5b07a76f05
7 changed files with 16 additions and 18 deletions

View File

@ -5482,7 +5482,7 @@ void Guest::UpdateWalking()
{
sprite = get_sprite(sprite_id);
if (sprite->generic.linked_list_index != SPRITE_LIST_PEEP)
if (sprite->generic.sprite_identifier != SPRITE_IDENTIFIER_PEEP)
continue;
if (sprite->peep.state != PEEP_STATE_WATCHING)
@ -6068,7 +6068,7 @@ bool Guest::UpdateWalkingFindBench()
{
sprite = get_sprite(sprite_id);
if (sprite->generic.linked_list_index != SPRITE_LIST_PEEP)
if (sprite->generic.sprite_identifier != SPRITE_IDENTIFIER_PEEP)
continue;
if (sprite->peep.state != PEEP_STATE_SITTING)
@ -6262,7 +6262,7 @@ static void peep_update_walking_break_scenery(Peep* peep)
{
sprite = get_sprite(sprite_id);
if ((sprite->generic.linked_list_index != SPRITE_LIST_PEEP) || (sprite->peep.state != PEEP_STATE_SITTING)
if ((sprite->generic.sprite_identifier != SPRITE_IDENTIFIER_PEEP) || (sprite->peep.state != PEEP_STATE_SITTING)
|| (peep->z != sprite->peep.z))
{
continue;

View File

@ -434,7 +434,7 @@ void peep_update_all()
else
{
peep_128_tick_update(peep, i);
if (peep->linked_list_index == SPRITE_LIST_PEEP)
if (peep->sprite_identifier == SPRITE_IDENTIFIER_PEEP)
{
peep->Update();
}

View File

@ -1813,7 +1813,7 @@ static int32_t peep_update_patrolling_find_sweeping(Peep* peep)
{
sprite = get_sprite(sprite_id);
if (sprite->generic.linked_list_index != SPRITE_LIST_LITTER)
if (sprite->generic.sprite_identifier != SPRITE_IDENTIFIER_LITTER)
continue;
uint16_t z_diff = abs(peep->z - sprite->litter.z);

View File

@ -324,8 +324,6 @@ void ride_update_favourited_stat()
FOR_ALL_GUESTS (spriteIndex, peep)
{
if (peep->linked_list_index != SPRITE_LIST_PEEP)
return;
if (peep->favourite_ride != RIDE_ID_NULL)
{
auto ride = get_ride(peep->favourite_ride);

View File

@ -395,7 +395,7 @@ void footpath_remove_litter(const CoordsXYZ& footpathPos)
{
Litter* sprite = &get_sprite(spriteIndex)->litter;
uint16_t nextSpriteIndex = sprite->next_in_quadrant;
if (sprite->linked_list_index == SPRITE_LIST_LITTER)
if (sprite->sprite_identifier == SPRITE_IDENTIFIER_LITTER)
{
int32_t distanceZ = abs(sprite->z - footpathPos.z);
if (distanceZ <= 32)
@ -417,10 +417,11 @@ void footpath_interrupt_peeps(const CoordsXYZ& footpathPos)
uint16_t spriteIndex = sprite_get_first_in_quadrant(footpathPos.x, footpathPos.y);
while (spriteIndex != SPRITE_INDEX_NULL)
{
Peep* peep = &get_sprite(spriteIndex)->peep;
uint16_t nextSpriteIndex = peep->next_in_quadrant;
if (peep->linked_list_index == SPRITE_LIST_PEEP)
auto* entity = get_sprite(spriteIndex);
uint16_t nextSpriteIndex = entity->generic.next_in_quadrant;
if (entity->generic.sprite_identifier == SPRITE_IDENTIFIER_PEEP)
{
Peep* peep = &entity->peep;
if (peep->state == PEEP_STATE_SITTING || peep->state == PEEP_STATE_WATCHING)
{
if (peep->z == footpathPos.z)

View File

@ -202,7 +202,7 @@ static bool map_animation_invalidate_small_scenery(const CoordsXYZ& loc)
for (; spriteIdx != SPRITE_INDEX_NULL; spriteIdx = sprite->generic.next_in_quadrant)
{
sprite = get_sprite(spriteIdx);
if (sprite->generic.linked_list_index != SPRITE_LIST_PEEP)
if (sprite->generic.sprite_identifier != SPRITE_IDENTIFIER_PEEP)
continue;
peep = &sprite->peep;

View File

@ -163,7 +163,7 @@ void reset_sprite_list()
spr->generic.sprite_identifier = SPRITE_IDENTIFIER_NULL;
spr->generic.sprite_index = i;
spr->generic.next = SPRITE_INDEX_NULL;
spr->generic.linked_list_index = 0;
spr->generic.linked_list_index = SPRITE_LIST_FREE;
if (previous_spr != nullptr)
{
@ -827,7 +827,7 @@ void litter_remove_at(int32_t x, int32_t y, int32_t z)
{
rct_sprite* sprite = get_sprite(spriteIndex);
uint16_t nextSpriteIndex = sprite->generic.next_in_quadrant;
if (sprite->generic.linked_list_index == SPRITE_LIST_LITTER)
if (sprite->generic.sprite_identifier == SPRITE_IDENTIFIER_LITTER)
{
Litter* litter = &sprite->litter;
@ -884,11 +884,10 @@ uint16_t remove_floating_sprites()
*/
static bool sprite_should_tween(rct_sprite* sprite)
{
switch (sprite->generic.linked_list_index)
switch (sprite->generic.sprite_identifier)
{
case SPRITE_LIST_PEEP:
case SPRITE_LIST_TRAIN_HEAD:
case SPRITE_LIST_VEHICLE:
case SPRITE_IDENTIFIER_PEEP:
case SPRITE_IDENTIFIER_VEHICLE:
return true;
}
return false;