1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

Add a bit of debug code around MapBlock refcounting

This commit is contained in:
sfan5 2025-07-24 14:18:38 +02:00
parent 39417cf7a7
commit 0c12c1f400
6 changed files with 74 additions and 31 deletions

View file

@ -19,12 +19,18 @@ MapSector::~MapSector()
deleteBlocks();
}
void MapSector::deleteBlocks()
void MapSector::deleteBlocks(size_t *used_count)
{
// Clear cache
m_block_cache = nullptr;
// Delete all blocks
size_t u = 0;
for (auto &it : m_blocks) {
if (it.second->refGet() > 0)
u++;
it.second.reset();
}
if (used_count)
*used_count += u;
m_blocks.clear();
}