From 67cbe2a2a18c26f1dcfab266afaf06e47b19984a Mon Sep 17 00:00:00 2001 From: rwjuk Date: Wed, 5 Jul 2017 22:55:46 +0100 Subject: [PATCH] Fix compilation issues and restore line that went astray --- src/openrct2/world/sprite.c | 57 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/openrct2/world/sprite.c b/src/openrct2/world/sprite.c index fb81396841..0efa585d52 100644 --- a/src/openrct2/world/sprite.c +++ b/src/openrct2/world/sprite.c @@ -247,34 +247,6 @@ const char * sprite_checksum() #endif // DISABLE_NETWORK -/** - * Clears all the unused sprite memory to zero. Probably so that it can be compressed better when saving. - * rct2: 0x0069EBA4 - */ -void sprite_clear_all_unused() -{ - rct_unk_sprite *sprite; - uint16 spriteIndex, nextSpriteIndex, previousSpriteIndex; - - spriteIndex = gSpriteListHead[SPRITE_LIST_NULL]; - while (spriteIndex != SPRITE_INDEX_NULL) { - sprite = &get_sprite(spriteIndex)->unknown; - sprite_reset(sprite); - sprite->linked_list_type_offset = SPRITE_LIST_NULL * 2; - - // This shouldn't be necessary, as sprite_reset() preserves the index - // but it has been left in as a safety net in case the index isn't set correctly - sprite->sprite_index = spriteIndex; - - // sprite->next_in_quadrant will only end up as zero owing to corruption - // most likely due to previous builds not preserving it when resetting sprites - // We reset it to SPRITE_INDEX_NULL to prevent cycles in the sprite lists - if (sprite->next_in_quadrant == 0) { sprite->next_in_quadrant = SPRITE_INDEX_NULL; } - _spriteFlashingList[spriteIndex] = false; - spriteIndex = nextSpriteIndex; - } -} - static void sprite_reset(rct_unk_sprite *sprite) { // Need to retain how the sprite is linked in lists @@ -295,6 +267,35 @@ static void sprite_reset(rct_unk_sprite *sprite) sprite->sprite_identifier = SPRITE_IDENTIFIER_NULL; } +/** +* Clears all the unused sprite memory to zero. Probably so that it can be compressed better when saving. +* rct2: 0x0069EBA4 +*/ +void sprite_clear_all_unused() +{ + rct_unk_sprite *sprite; + uint16 spriteIndex, nextSpriteIndex; + + spriteIndex = gSpriteListHead[SPRITE_LIST_NULL]; + while (spriteIndex != SPRITE_INDEX_NULL) { + sprite = &get_sprite(spriteIndex)->unknown; + nextSpriteIndex = sprite->next; + sprite_reset(sprite); + sprite->linked_list_type_offset = SPRITE_LIST_NULL * 2; + + // This shouldn't be necessary, as sprite_reset() preserves the index + // but it has been left in as a safety net in case the index isn't set correctly + sprite->sprite_index = spriteIndex; + + // sprite->next_in_quadrant will only end up as zero owing to corruption + // most likely due to previous builds not preserving it when resetting sprites + // We reset it to SPRITE_INDEX_NULL to prevent cycles in the sprite lists + if (sprite->next_in_quadrant == 0) { sprite->next_in_quadrant = SPRITE_INDEX_NULL; } + _spriteFlashingList[spriteIndex] = false; + spriteIndex = nextSpriteIndex; + } +} + // Resets all sprites in SPRITE_LIST_NULL list void reset_empty_sprites() {