summaryrefslogtreecommitdiffstats
path: root/src/ChunkBuffer.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-04-27 17:11:56 +0200
committerTycho <work.tycho+git@gmail.com>2014-04-27 17:11:56 +0200
commitd412630904c1de6c0d9ef00fbc75b5558f931e8b (patch)
treec44fc16863072c077b8aaa7a1c9ca1331a9dc266 /src/ChunkBuffer.cpp
parentAdded other half of implementation (diff)
downloadcuberite-d412630904c1de6c0d9ef00fbc75b5558f931e8b.tar
cuberite-d412630904c1de6c0d9ef00fbc75b5558f931e8b.tar.gz
cuberite-d412630904c1de6c0d9ef00fbc75b5558f931e8b.tar.bz2
cuberite-d412630904c1de6c0d9ef00fbc75b5558f931e8b.tar.lz
cuberite-d412630904c1de6c0d9ef00fbc75b5558f931e8b.tar.xz
cuberite-d412630904c1de6c0d9ef00fbc75b5558f931e8b.tar.zst
cuberite-d412630904c1de6c0d9ef00fbc75b5558f931e8b.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkBuffer.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/ChunkBuffer.cpp b/src/ChunkBuffer.cpp
index 7946fba1e..a41b8f61a 100644
--- a/src/ChunkBuffer.cpp
+++ b/src/ChunkBuffer.cpp
@@ -160,6 +160,11 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src)
sizeof(BLOCKTYPE) * segment_length
);
}
+ else
+ {
+ Free(m_Sections[i]);
+ m_Sections[i] = 0;
+ }
}
}
}
@@ -185,11 +190,16 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src)
{
m_Sections[i] = Allocate();
memcpy(
- &m_Sections[i]->m_BlockTypes,
+ &m_Sections[i]->m_BlockMeta,
&a_src[i * segment_length],
sizeof(BLOCKTYPE) * segment_length
);
}
+ else
+ {
+ Free(m_Sections[i]);
+ m_Sections[i] = 0;
+ }
}
}
}
@@ -199,6 +209,7 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src)
void cChunkBuffer::SetLight(const NIBBLETYPE * a_src)
{
+ if (!a_src) return;
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2;
@@ -215,11 +226,16 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src)
{
m_Sections[i] = Allocate();
memcpy(
- &m_Sections[i]->m_BlockTypes,
+ &m_Sections[i]->m_BlockLight,
&a_src[i * segment_length],
sizeof(BLOCKTYPE) * segment_length
);
}
+ else
+ {
+ Free(m_Sections[i]);
+ m_Sections[i] = 0;
+ }
}
}
}
@@ -229,6 +245,7 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src)
void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src)
{
+ if (!a_src) return;
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2;
@@ -245,11 +262,16 @@ void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src)
{
m_Sections[i] = Allocate();
memcpy(
- &m_Sections[i]->m_BlockTypes,
+ &m_Sections[i]->m_BlockSkyLight,
&a_src[i * segment_length],
sizeof(BLOCKTYPE) * segment_length
);
}
+ else
+ {
+ Free(m_Sections[i]);
+ m_Sections[i] = 0;
+ }
}
}
}
@@ -263,3 +285,13 @@ cChunkBuffer::sChunkSection * cChunkBuffer::Allocate() const
// TODO: use a allocation pool
return new cChunkBuffer::sChunkSection;
}
+
+
+
+void cChunkBuffer::Free(cChunkBuffer::sChunkSection * ptr) const
+{
+ delete ptr;
+}
+
+
+