1
0

BlockHandler: no dynamic allocation (#4862)

* BlockHandler: no dynamic allocation
This commit is contained in:
Tiger Wang
2020-09-17 14:51:42 +01:00
committed by GitHub
parent 53549a1a4c
commit c3d2956ba5
8 changed files with 557 additions and 254 deletions

View File

@@ -21,24 +21,17 @@ cBlockInfo::cBlockInfo()
void cBlockInfo::sHandlerDeleter::operator () (cBlockHandler * a_Handler)
cBlockInfo::cBlockInfoArray::cBlockInfoArray()
{
delete a_Handler;
}
cBlockInfo::cBlockInfoArray::cBlockInfoArray()
cBlockHandler * cBlockInfo::GetHandler(BLOCKTYPE a_Type)
{
cBlockInfoArray & BlockInfos = *this;
// The piece-loading code uses the handlers for rotations, so we need valid handlers
// Insert dummy handlers:
for (size_t i = 0; i < BlockInfos.size(); i++)
{
BlockInfos[i].m_Handler.reset(new cBlockHandler(static_cast<BLOCKTYPE>(i)));
}
return nullptr;
}