From 070d483236279e69c736e740fa8459d3ac627790 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 2 Mar 2014 21:25:05 +0200 Subject: cBlockInfo now manages the respective cBlockHandler --- src/BlockInfo.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/BlockInfo.cpp') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index c73ae18b6..195af49c7 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -2,6 +2,7 @@ #include "Globals.h" #include "BlockInfo.h" +#include "Blocks/BlockHandler.h" @@ -23,12 +24,25 @@ cBlockInfo::cBlockInfo() , m_RequiresSpecialTool(false) , m_IsSolid(true) , m_FullyOccupiesVoxel(false) + , m_Handler(NULL) {} +cBlockInfo::~cBlockInfo() +{ + if (m_Handler != NULL) + { + delete m_Handler; + } +} + + + + + cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type) { ASSERT(a_Type < 256); @@ -42,6 +56,14 @@ cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type) void cBlockInfo::Initialize(void) { + for (unsigned int i = 0; i < 256; ++i) + { + if (ms_Info[i].m_Handler == NULL) + { + ms_Info[i].m_Handler = cBlockHandler::CreateBlockHandler((BLOCKTYPE) i); + } + } + // Emissive blocks ms_Info[E_BLOCK_FIRE ].m_LightValue = 15; ms_Info[E_BLOCK_GLOWSTONE ].m_LightValue = 15; -- cgit v1.2.3 From 36fd78af35b49d64b97e93df6428ace787c88c4c Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 2 Mar 2014 22:55:14 +0200 Subject: Removed if condition --- src/BlockInfo.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/BlockInfo.cpp') diff --git a/src/BlockInfo.cpp b/src/BlockInfo.cpp index 195af49c7..399efcd9b 100644 --- a/src/BlockInfo.cpp +++ b/src/BlockInfo.cpp @@ -33,10 +33,7 @@ cBlockInfo::cBlockInfo() cBlockInfo::~cBlockInfo() { - if (m_Handler != NULL) - { - delete m_Handler; - } + delete m_Handler; } -- cgit v1.2.3