summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ChunkBuffer.cpp11
-rw-r--r--src/ChunkBuffer.h12
2 files changed, 23 insertions, 0 deletions
diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp
index baeeff890..96077b966 100644
--- a/src/ChunkBuffer.cpp
+++ b/src/ChunkBuffer.cpp
@@ -295,3 +295,14 @@ void cChunkBuffer::Free(cChunkBuffer::sChunkSection * ptr) const
+void cChunkBuffer::ZeroSection(cChunkBuffer::sChunkSection * ptr) const
+{
+ memset(ptr->m_BlockTypes,0x00,sizeof(ptr->m_BlockTypes));
+ memset(ptr->m_BlockMeta,0x00,sizeof(ptr->m_BlockMeta));
+ memset(ptr->m_BlockLight,0x00,sizeof(ptr->m_BlockLight));
+ memset(ptr->m_BlockSkyLight,0x00,sizeof(ptr->m_BlockSkyLight));
+}
+
+
+
+
diff --git a/src/ChunkBuffer.h b/src/ChunkBuffer.h
index b1bd024d5..e16575bb2 100644
--- a/src/ChunkBuffer.h
+++ b/src/ChunkBuffer.h
@@ -121,12 +121,17 @@ public:
int Section = a_RelY / CHUNK_SECTION_HEIGHT;
if(!m_Sections[Section])
{
+ if(a_Block == 0x00)
+ {
+ return;
+ }
m_Sections[Section] = Allocate();
if(!m_Sections[Section])
{
ASSERT(!"Failed to allocate a new section in Chunkbuffer");
return;
}
+ ZeroSection(m_Sections[Section]);
}
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ);
m_Sections[Section]->m_BlockTypes[Index] = a_Block;
@@ -166,12 +171,17 @@ public:
int Section = a_RelY / CHUNK_SECTION_HEIGHT;
if(!m_Sections[Section])
{
+ if((a_Nibble & 0xf) == 0x00)
+ {
+ return;
+ }
m_Sections[Section] = Allocate();
if(!m_Sections[Section])
{
ASSERT(!"Failed to allocate a new section in Chunkbuffer");
return;
}
+ ZeroSection(m_Sections[Section]);
}
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ);
m_Sections[Section]->m_BlockMeta[Index / 2] = static_cast<NIBBLETYPE>(
@@ -247,6 +257,8 @@ private:
sChunkSection * Allocate() const;
void Free(sChunkSection * ptr) const;
+
+ void ZeroSection(sChunkSection * ptr) const;
};