1
0

Added several more testsfor arrays and coordinates

This commit is contained in:
Tycho 2014-05-11 19:24:09 +01:00
parent 5d39ecc64b
commit c46f240d81
3 changed files with 21 additions and 5 deletions

View File

@ -151,7 +151,7 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src)
size_t j = 0;
// do nothing whilst 0
for (; j < segment_length && a_src[i * segment_length + j] == 0; j++);
if (j != (segment_length - 1))
if (j != segment_length)
{
m_Sections[i] = Allocate();
memcpy(
@ -159,6 +159,9 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src)
&a_src[i * segment_length],
sizeof(BLOCKTYPE) * segment_length
);
memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta));
memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight));
memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight));
}
else
{
@ -186,7 +189,7 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src)
size_t j = 0;
// do nothing whilst 0
for (; j < segment_length && a_src[i * segment_length + j] == 0; j++);
if (j != (segment_length - 1))
if (j != segment_length)
{
m_Sections[i] = Allocate();
memcpy(
@ -194,6 +197,9 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src)
&a_src[i * segment_length],
sizeof(BLOCKTYPE) * segment_length
);
memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes));
memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight));
memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight));
}
else
{
@ -222,7 +228,7 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src)
size_t j = 0;
// do nothing whilst 0
for (; j < segment_length && a_src[i * segment_length + j] == 0; j++);
if (j != (segment_length - 1))
if (j != segment_length)
{
m_Sections[i] = Allocate();
memcpy(
@ -230,6 +236,9 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src)
&a_src[i * segment_length],
sizeof(BLOCKTYPE) * segment_length
);
memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes));
memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta));
memset(m_Sections[i]->m_BlockSkyLight,0xFF,sizeof(m_Sections[i]->m_BlockSkyLight));
}
else
{
@ -258,7 +267,7 @@ void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src)
size_t j = 0;
// do nothing whilst 0
for (; j < segment_length && a_src[i * segment_length + j] == 0xFF; j++);
if (j != (segment_length -1))
if (j != segment_length)
{
m_Sections[i] = Allocate();
memcpy(
@ -266,6 +275,9 @@ void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src)
&a_src[i * segment_length],
sizeof(BLOCKTYPE) * segment_length
);
memset(m_Sections[i]->m_BlockTypes,0x00,sizeof(m_Sections[i]->m_BlockTypes));
memset(m_Sections[i]->m_BlockMeta,0x00,sizeof(m_Sections[i]->m_BlockMeta));
memset(m_Sections[i]->m_BlockLight,0x00,sizeof(m_Sections[i]->m_BlockLight));
}
else
{

View File

@ -18,3 +18,8 @@ add_test(NAME coordinates-test COMMAND coordinates-exe)
add_executable(copies-exe Copies.cpp)
target_link_libraries(copies-exe ChunkBuffer)
add_test(NAME copies-test COMMAND copies-exe)
add_executable(arraystocoords-exe ArraytoCoord.cpp)
target_link_libraries(arraystocoords-exe ChunkBuffer)
add_test(NAME arraystocoords-test COMMAND arraystocoords-exe)

View File

@ -99,7 +99,6 @@ int main(int argc, char** argv)
DstBlockBuffer = NULL;
SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
buffer.SetMeta(SrcNibbleBuffer);
DstNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/ 2];