From 115bc5609ad73d08ba90702519754f48866ec341 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Thu, 7 Sep 2017 09:40:58 +0100 Subject: cBlockArea: change MakeIndex to return size_t --- src/BlockArea.h | 46 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) (limited to 'src/BlockArea.h') diff --git a/src/BlockArea.h b/src/BlockArea.h index 94081f93f..ab7fb8f2c 100644 --- a/src/BlockArea.h +++ b/src/BlockArea.h @@ -370,7 +370,11 @@ public: NIBBLETYPE * GetBlockLight (void) const { return m_BlockLight.get(); } // NOTE: one byte per block! NIBBLETYPE * GetBlockSkyLight(void) const { return m_BlockSkyLight.get(); } // NOTE: one byte per block! size_t GetBlockCount(void) const { return static_cast(m_Size.x * m_Size.y * m_Size.z); } - int MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const; + static size_t MakeIndexForSize(Vector3i a_RelPos, Vector3i a_Size); + size_t MakeIndex(int a_RelX, int a_RelY, int a_RelZ) const + { + return MakeIndexForSize({ a_RelX, a_RelY, a_RelZ }, m_Size); + } /** Calls the callback for the block entity at the specified coords. Returns false if there is no block entity at those coords, or the block area doesn't have baBlockEntities. @@ -418,44 +422,8 @@ protected: virtual void BlockEntity(cBlockEntity * a_BlockEntity) override; } ; - template - class cDynArray: - public std::unique_ptr - { - using Super = std::unique_ptr; - public: - // using Super::Super; - cDynArray() = default; - cDynArray(cDynArray && a_Other) : Super(std::move(a_Other)) {} - cDynArray & operator = (cDynArray && a_Other) - { - Super::operator = (std::move(a_Other)); - return *this; - } - - cDynArray(std::nullptr_t) {} - - cDynArray(T * a_Ptr): - Super(a_Ptr) - { - } - - // Allow indexing with signed types - T & operator [] (int a_Idx) const - { - ASSERT(a_Idx >= 0); - return (Super::get())[a_Idx]; - } - - T & operator [] (size_t a_Idx) const - { - return (Super::get())[a_Idx]; - } - }; - - using NIBBLEARRAY = cDynArray; - using BLOCKARRAY = cDynArray; - + using NIBBLEARRAY = std::unique_ptr; + using BLOCKARRAY = std::unique_ptr; Vector3i m_Origin; Vector3i m_Size; -- cgit v1.2.3