diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 23fe74ebc7..7a62e5626b 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -52,6 +52,7 @@ extern "C" #include "../world/Climate.h" #include "../world/map_animation.h" #include "../world/park.h" + #include "../world/sprite.h" } S6Exporter::S6Exporter() @@ -178,6 +179,13 @@ void S6Exporter::Export() memcpy(_s6.map_elements, gMapElements, sizeof(_s6.map_elements)); _s6.next_free_map_element_pointer_index = gNextFreeMapElementPointerIndex; + // Sprites needs to be reset before they get used. + // Might as well reset them in here to zero out the space and improve + // compression ratios. Especially useful for multiplayer servers that + // use zlib on the sent stream. + { + reset_empty_sprites(); + } for (sint32 i = 0; i < MAX_SPRITES; i++) { memcpy(&_s6.sprites[i], get_sprite(i), sizeof(rct_sprite)); diff --git a/src/openrct2/world/sprite.c b/src/openrct2/world/sprite.c index efc30d5075..164173898b 100644 --- a/src/openrct2/world/sprite.c +++ b/src/openrct2/world/sprite.c @@ -289,6 +289,22 @@ static void sprite_reset(rct_unk_sprite *sprite) sprite->sprite_index = sprite_index; } +// Resets all sprites in SPRITE_LIST_NULL list +void reset_empty_sprites() +{ + uint16 spriteIndex; + spriteIndex = gSpriteListHead[SPRITE_LIST_NULL]; + while (spriteIndex != SPRITE_INDEX_NULL) + { + rct_unk_sprite *sprite = &(get_sprite(spriteIndex))->unknown; + spriteIndex = sprite->next; + if (sprite->sprite_identifier == SPRITE_IDENTIFIER_NULL) + { + sprite_reset(sprite); + } + } +} + /* * rct2: 0x0069EC6B * bl: if bl & 2 > 0, the sprite ends up in the MISC linked list. diff --git a/src/openrct2/world/sprite.h b/src/openrct2/world/sprite.h index 86ed1db666..50e4914cd8 100644 --- a/src/openrct2/world/sprite.h +++ b/src/openrct2/world/sprite.h @@ -419,6 +419,7 @@ extern uint16 *gSpriteListCount; extern uint16 gSpriteSpatialIndex[0x10001]; rct_sprite *create_sprite(uint8 bl); +void reset_empty_sprites(); void reset_sprite_list(); void reset_sprite_spatial_index(); void sprite_clear_all_unused();