1
0

Merge pull request #3489 from cuberite/EntityOwnership

* Changed entity ownership model to use smart pointers
This commit is contained in:
Tiger Wang
2017-08-18 11:17:56 +01:00
committed by GitHub
39 changed files with 484 additions and 425 deletions

View File

@@ -60,11 +60,11 @@ void cSandSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
Pos.x, Pos.y, Pos.z, ItemTypeToString(BlockType).c_str(), ItemTypeToString(BlockBelow).c_str()
);
*/
cFallingBlock * FallingBlock = new cFallingBlock(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z));
if (!FallingBlock->Initialize(m_World))
auto FallingBlock = cpp14::make_unique<cFallingBlock>(Pos, BlockType, a_Chunk->GetMeta(itr->x, itr->y, itr->z));
auto FallingBlockPtr = FallingBlock.get();
if (!FallingBlockPtr->Initialize(std::move(FallingBlock), m_World))
{
delete FallingBlock;
FallingBlock = nullptr;
continue;
}
a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0);