1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 19:43:06 +01:00

Remove broken check_for_spatial_index_cycles

There were a number of issues with this function. It was calling index_is_in_list with invalid SPRITE_LISTs. The spatial index is no longer needed to be correct on save/load as it is rebuilt so that it is kept in order.
This commit is contained in:
duncanspumpkin
2020-06-17 21:20:58 +01:00
parent 55f0f34fe0
commit 2d28ca3b28
4 changed files with 0 additions and 37 deletions

View File

@@ -151,10 +151,8 @@ void S6Exporter::Save(IStream* stream, bool isScenario)
void S6Exporter::Export()
{
int32_t spatial_cycle = check_for_spatial_index_cycles(false);
int32_t regular_cycle = check_for_sprite_list_cycles(false);
int32_t disjoint_sprites_count = fix_disjoint_sprites();
openrct2_assert(spatial_cycle == -1, "Sprite cycle exists in spatial list %d", spatial_cycle);
openrct2_assert(regular_cycle == -1, "Sprite cycle exists in regular list %d", regular_cycle);
// This one is less harmful, no need to assert for it ~janisozaur
if (disjoint_sprites_count > 0)

View File

@@ -465,7 +465,6 @@ public:
// We try to fix the cycles on import, hence the 'true' parameter
check_for_sprite_list_cycles(true);
check_for_spatial_index_cycles(true);
int32_t disjoint_sprites_count = fix_disjoint_sprites();
// This one is less harmful, no need to assert for it ~janisozaur
if (disjoint_sprites_count > 0)

View File

@@ -1153,36 +1153,3 @@ int32_t fix_disjoint_sprites()
}
return count;
}
int32_t check_for_spatial_index_cycles(bool fix)
{
for (uint32_t i = 0; i < SPATIAL_INDEX_LOCATION_NULL; i++)
{
auto* cycle_start = find_sprite_quadrant_cycle(gSpriteSpatialIndex[i]);
if (cycle_start != nullptr)
{
if (fix)
{
// Store the leftover part of cycle to be fixed
uint16_t cycle_next = cycle_start->next_in_quadrant;
// Break the cycle
cycle_start->next_in_quadrant = SPRITE_INDEX_NULL;
// Now re-add remainder of the cycle back to list, safely.
// Add each sprite to the list until we encounter one that is already part of the list.
while (!index_is_in_list(cycle_next, static_cast<SPRITE_LIST>(i)))
{
auto* spr = GetEntity(cycle_next);
cycle_start->next_in_quadrant = cycle_next;
cycle_next = spr->next_in_quadrant;
spr->next_in_quadrant = SPRITE_INDEX_NULL;
cycle_start = spr;
}
}
return i;
}
}
return -1;
}

View File

@@ -259,7 +259,6 @@ rct_sprite_checksum sprite_checksum();
void sprite_set_flashing(SpriteBase* sprite, bool flashing);
bool sprite_get_flashing(SpriteBase* sprite);
int32_t check_for_sprite_list_cycles(bool fix);
int32_t check_for_spatial_index_cycles(bool fix);
int32_t fix_disjoint_sprites();
template<typename T, uint16_t SpriteBase::*NextList> class EntityIterator