From aac592f98598aae327d07b2a1bb155e33c6d51b1 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Fri, 3 Apr 2020 22:23:38 +0100 Subject: Manage block entity lifetime with unique_ptr (#4080) --- src/BlockArea.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 9c0cb4ec9..f9dd388c0 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -19,6 +19,7 @@ #include "ChunkDataCallback.h" #include "Cuboid.h" #include "FunctionRef.h" +#include "BlockEntities/BlockEntity.h" @@ -456,6 +457,7 @@ protected: using NIBBLEARRAY = std::unique_ptr; using BLOCKARRAY = std::unique_ptr; + using cBlockEntitiesPtr = std::unique_ptr; Vector3i m_Origin; Vector3i m_Size; @@ -469,14 +471,6 @@ protected: NIBBLEARRAY m_BlockLight; // Each light value is stored as a separate byte for faster access NIBBLEARRAY m_BlockSkyLight; // Each light value is stored as a separate byte for faster access - /** Deleter to clear the block entities before deleting the container. */ - struct sBlockEntitiesDeleter - { - void operator () (cBlockEntities * a_BlockEntities); - }; - - using cBlockEntitiesPtr = std::unique_ptr; - /** The block entities contained within the area. Only valid if the area was created / read with the baBlockEntities flag. The block entities are owned by this object. */ @@ -512,9 +506,6 @@ protected: template void MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas); - /** Clears the block entities from the specified container, freeing each blockentity. */ - static void ClearBlockEntities(cBlockEntities & a_BlockEntities); - /** Updates m_BlockEntities to remove BEs that no longer match the blocktype at their coords, and clones from a_Src the BEs that are missing. a_RelX, a_RelY and a_RelZ are relative coords that should be added to all BEs from a_Src before checking them. If a block should have a BE but one cannot be found in either this or a_Src, a new one is created. */ -- cgit v1.2.3