1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +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

@ -30,12 +30,23 @@ Map::Map(IGameDef *gamedef):
Map::~Map()
{
/*
Free all MapSectors
*/
// Free all sectors
size_t used = 0;
for (auto &sector : m_sectors) {
sector.second->deleteBlocks(&used);
delete sector.second;
}
m_sectors.clear();
if (used > 0) {
#ifdef NDEBUG
std::ostream &to = infostream;
#else
std::ostream &to = warningstream;
#endif
PrintInfo(to);
to << used << " blocks deleted despite reference count > 0. Potential bug." << std::endl;
}
}
void Map::addEventReceiver(MapEventReceiver *event_receiver)