2014-05-11 14:40:32 -04:00
|
|
|
|
2014-05-27 07:44:56 -04:00
|
|
|
#include "Globals.h"
|
2019-08-26 15:38:34 -04:00
|
|
|
#include "../TestHelpers.h"
|
2014-05-21 14:58:48 -04:00
|
|
|
#include "ChunkData.h"
|
2014-05-11 14:40:32 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-26 15:38:34 -04:00
|
|
|
/** Performs the entire ArrayToCoords test. */
|
|
|
|
static void test()
|
2014-05-11 14:40:32 -04:00
|
|
|
{
|
|
|
|
{
|
2021-03-05 08:03:55 -05:00
|
|
|
// Test first segment (blocks)
|
|
|
|
ChunkBlockData buffer;
|
2014-05-11 14:40:32 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
|
2014-05-30 03:17:50 -04:00
|
|
|
memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer));
|
|
|
|
SrcBlockBuffer[7 + (4 * 16) + (5 * 16 * 16)] = 0xcd;
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
2014-05-30 03:17:50 -04:00
|
|
|
memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
|
|
|
|
SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xe;
|
2021-03-05 08:03:55 -05:00
|
|
|
|
|
|
|
buffer.SetAll(SrcBlockBuffer, SrcNibbleBuffer);
|
|
|
|
|
|
|
|
TEST_EQUAL(buffer.GetBlock({ 7, 5, 4 }), 0xcd);
|
2019-08-26 15:38:34 -04:00
|
|
|
TEST_EQUAL(buffer.GetMeta({ 6, 2, 1 }), 0xe);
|
2021-03-05 08:03:55 -05:00
|
|
|
}
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2021-03-05 08:03:55 -05:00
|
|
|
{
|
|
|
|
// Test first segment (lights)
|
|
|
|
ChunkLightData buffer;
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2021-03-05 08:03:55 -05:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
2014-05-30 03:17:50 -04:00
|
|
|
memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
|
|
|
|
SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xe;
|
2021-03-05 08:03:55 -05:00
|
|
|
|
|
|
|
buffer.SetAll(SrcNibbleBuffer, SrcNibbleBuffer);
|
|
|
|
|
|
|
|
TEST_EQUAL(buffer.GetBlockLight({ 6, 2, 1 }), 0xe);
|
2019-08-26 15:38:34 -04:00
|
|
|
TEST_EQUAL(buffer.GetSkyLight({ 6, 2, 1 }), 0xe);
|
2014-05-11 14:40:32 -04:00
|
|
|
}
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2014-05-11 14:40:32 -04:00
|
|
|
{
|
2021-03-05 08:03:55 -05:00
|
|
|
// test following segment (blocks)
|
|
|
|
ChunkBlockData buffer;
|
2014-05-11 14:40:32 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
|
2014-05-30 03:17:50 -04:00
|
|
|
memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer));
|
|
|
|
SrcBlockBuffer[7 + (4 * 16) + (24 * 16 * 16)] = 0xcd;
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
2014-05-30 03:17:50 -04:00
|
|
|
memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
|
|
|
|
SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16)) / 2] = 0xe;
|
2021-03-05 08:03:55 -05:00
|
|
|
|
|
|
|
buffer.SetAll(SrcBlockBuffer, SrcNibbleBuffer);
|
|
|
|
|
|
|
|
TEST_EQUAL(buffer.GetBlock({ 7, 24, 4 }), 0xcd);
|
2019-08-26 15:38:34 -04:00
|
|
|
TEST_EQUAL(buffer.GetMeta({ 6, 24, 1 }), 0xe);
|
2021-03-05 08:03:55 -05:00
|
|
|
}
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2021-03-05 08:03:55 -05:00
|
|
|
{
|
|
|
|
// test following segment (lights)
|
|
|
|
ChunkLightData buffer;
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2021-03-05 08:03:55 -05:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
|
|
|
memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
|
2014-05-30 03:17:50 -04:00
|
|
|
SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16)) / 2] = 0xe;
|
2021-03-05 08:03:55 -05:00
|
|
|
|
|
|
|
buffer.SetAll(SrcNibbleBuffer, SrcNibbleBuffer);
|
|
|
|
|
|
|
|
TEST_EQUAL(buffer.GetBlockLight({ 6, 24, 1 }), 0xe);
|
2019-08-26 15:38:34 -04:00
|
|
|
TEST_EQUAL(buffer.GetSkyLight({ 6, 24, 1 }), 0xe);
|
2014-05-11 14:40:32 -04:00
|
|
|
}
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2014-05-17 09:07:49 -04:00
|
|
|
{
|
2021-03-05 08:03:55 -05:00
|
|
|
// test zeros (blocks)
|
|
|
|
ChunkBlockData buffer;
|
2014-05-17 09:07:49 -04:00
|
|
|
|
2014-05-24 08:33:40 -04:00
|
|
|
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
|
2014-05-30 03:17:50 -04:00
|
|
|
memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer));
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2014-05-30 03:17:50 -04:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
|
|
|
memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
|
2021-03-05 08:03:55 -05:00
|
|
|
|
|
|
|
buffer.SetAll(SrcBlockBuffer, SrcNibbleBuffer);
|
|
|
|
|
|
|
|
TEST_EQUAL(buffer.GetBlock({ 7, 24, 4 }), 0x00);
|
2019-08-26 15:38:34 -04:00
|
|
|
TEST_EQUAL(buffer.GetMeta({ 6, 24, 1 }), 0x0);
|
2021-03-05 08:03:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// test zeros (lights)
|
|
|
|
ChunkLightData buffer;
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2021-03-05 08:03:55 -05:00
|
|
|
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
|
2014-05-30 03:17:50 -04:00
|
|
|
memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
|
2018-02-04 17:15:31 -05:00
|
|
|
|
2021-03-05 08:03:55 -05:00
|
|
|
NIBBLETYPE SrcNibbleBuffer2[16 * 16 * 256 / 2];
|
|
|
|
memset(SrcNibbleBuffer2, 0xff, sizeof(SrcNibbleBuffer2));
|
|
|
|
|
|
|
|
buffer.SetAll(SrcNibbleBuffer, SrcNibbleBuffer2);
|
|
|
|
|
|
|
|
TEST_EQUAL(buffer.GetBlockLight({ 6, 24, 1 }), 0x0);
|
2019-08-26 15:38:34 -04:00
|
|
|
TEST_EQUAL(buffer.GetSkyLight({ 6, 24, 1 }), 0xf);
|
2014-05-17 09:07:49 -04:00
|
|
|
}
|
2014-05-11 14:40:32 -04:00
|
|
|
}
|
|
|
|
|
2019-08-26 15:38:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_TEST_MAIN("ChunkData ArrayToCoord",
|
|
|
|
test();
|
|
|
|
)
|