diff options
author | Bond_009 <bond.009@outlook.com> | 2022-01-13 21:23:20 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2022-01-14 18:24:59 +0100 |
commit | b14874978a3e3da6439b8a71c9cd3c804ebab33c (patch) | |
tree | fe01c121ea5859be5c3ec62b54c719d4d1f7b4f6 | |
parent | Simplify diff and remove excessive logging. (diff) | |
download | cuberite-b14874978a3e3da6439b8a71c9cd3c804ebab33c.tar cuberite-b14874978a3e3da6439b8a71c9cd3c804ebab33c.tar.gz cuberite-b14874978a3e3da6439b8a71c9cd3c804ebab33c.tar.bz2 cuberite-b14874978a3e3da6439b8a71c9cd3c804ebab33c.tar.lz cuberite-b14874978a3e3da6439b8a71c9cd3c804ebab33c.tar.xz cuberite-b14874978a3e3da6439b8a71c9cd3c804ebab33c.tar.zst cuberite-b14874978a3e3da6439b8a71c9cd3c804ebab33c.zip |
-rw-r--r-- | src/ByteBuffer.cpp | 2 | ||||
-rw-r--r-- | tests/ByteBuffer/ByteBufferTest.cpp | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 80be9baee..e75051570 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -788,7 +788,7 @@ bool cByteBuffer::WriteXZYPosition64(Int32 a_BlockX, Int32 a_BlockY, Int32 a_Blo CheckValid(); return WriteBEInt64( (static_cast<Int64>(a_BlockX & 0x3FFFFFF) << 38) | - (static_cast<Int64>(a_BlockZ & 0x3FFFFFF) << 26) | + (static_cast<Int64>(a_BlockZ & 0x3FFFFFF) << 12) | (static_cast<Int64>(a_BlockY & 0xFFF)) ); } diff --git a/tests/ByteBuffer/ByteBufferTest.cpp b/tests/ByteBuffer/ByteBufferTest.cpp index 9aecc2e3c..0cd14e246 100644 --- a/tests/ByteBuffer/ByteBufferTest.cpp +++ b/tests/ByteBuffer/ByteBufferTest.cpp @@ -70,8 +70,40 @@ static void TestWrap(void) +static void TestXYZPositionRoundtrip(void) +{ + cByteBuffer buf(50); + buf.WriteXYZPosition64(-33554432, -2048, -33554432); // Testing the minimun values + int x, y, z; + TEST_TRUE(buf.ReadXYZPosition64(x, y, z)); + TEST_EQUAL(x, -33554432); + TEST_EQUAL(y, -2048); + TEST_EQUAL(z, -33554432); +} + + + + + +static void TestXZYPositionRoundtrip(void) +{ + cByteBuffer buf(50); + buf.WriteXZYPosition64(-33554432, -2048, -33554432); // Testing the minimun values + int x, y, z; + TEST_TRUE(buf.ReadXZYPosition64(x, y, z)); + TEST_EQUAL(x, -33554432); + TEST_EQUAL(y, -2048); + TEST_EQUAL(z, -33554432); +} + + + + + IMPLEMENT_TEST_MAIN("ByteBuffer", TestRead(); TestWrite(); TestWrap(); + TestXYZPositionRoundtrip(); + TestXZYPositionRoundtrip(); ) |