1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Safely handle block deletion (#13315)

Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
This commit is contained in:
DS 2023-03-24 12:34:44 +01:00 committed by GitHub
parent f3b198e490
commit ed632f3854
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 74 additions and 5 deletions

View file

@ -109,6 +109,12 @@ void MapSector::insertBlock(MapBlock *block)
}
void MapSector::deleteBlock(MapBlock *block)
{
detachBlock(block);
delete block;
}
void MapSector::detachBlock(MapBlock *block)
{
s16 block_y = block->getPos().Y;
@ -118,8 +124,8 @@ void MapSector::deleteBlock(MapBlock *block)
// Remove from container
m_blocks.erase(block_y);
// Delete
delete block;
// Mark as removed
block->makeOrphan();
}
void MapSector::getBlocks(MapBlockVect &dest)