Fix wrong version when saving blocks
This commit is contained in:
parent
8cf52b8967
commit
ac73904df7
@ -19,7 +19,6 @@
|
||||
namespace zylann::voxel {
|
||||
namespace BlockSerializer {
|
||||
|
||||
const uint8_t BLOCK_FORMAT_VERSION = 3;
|
||||
const unsigned int BLOCK_TRAILING_MAGIC = 0x900df00d;
|
||||
const unsigned int BLOCK_TRAILING_MAGIC_SIZE = 4;
|
||||
const unsigned int BLOCK_METADATA_HEADER_SIZE = sizeof(uint32_t);
|
||||
|
@ -15,6 +15,9 @@ class VoxelBufferInternal;
|
||||
|
||||
namespace BlockSerializer {
|
||||
|
||||
// Latest version, used when serializing
|
||||
static const uint8_t BLOCK_FORMAT_VERSION = 4;
|
||||
|
||||
struct SerializeResult {
|
||||
// The lifetime of the pointed object is only valid in the calling thread,
|
||||
// until another serialization or deserialization call is made
|
||||
|
@ -1138,17 +1138,37 @@ void test_block_serializer() {
|
||||
voxel_buffer.fill_area(43, Vector3i(2, 3, 4), Vector3i(6, 6, 6), 0);
|
||||
voxel_buffer.fill_area(44, Vector3i(1, 2, 3), Vector3i(5, 5, 5), 1);
|
||||
|
||||
// Serialize
|
||||
BlockSerializer::SerializeResult result = BlockSerializer::serialize_and_compress(voxel_buffer);
|
||||
ZYLANN_TEST_ASSERT(result.success);
|
||||
std::vector<uint8_t> data = result.data;
|
||||
{
|
||||
// Serialize without compression wrapper
|
||||
BlockSerializer::SerializeResult result = BlockSerializer::serialize(voxel_buffer);
|
||||
ZYLANN_TEST_ASSERT(result.success);
|
||||
std::vector<uint8_t> data = result.data;
|
||||
|
||||
// Deserialize
|
||||
VoxelBufferInternal deserialized_voxel_buffer;
|
||||
ZYLANN_TEST_ASSERT(BlockSerializer::decompress_and_deserialize(to_span_const(data), deserialized_voxel_buffer));
|
||||
ZYLANN_TEST_ASSERT(data.size() > 0);
|
||||
ZYLANN_TEST_ASSERT(data[0] == BlockSerializer::BLOCK_FORMAT_VERSION);
|
||||
|
||||
// Must be equal
|
||||
ZYLANN_TEST_ASSERT(voxel_buffer.equals(deserialized_voxel_buffer));
|
||||
// Deserialize
|
||||
VoxelBufferInternal deserialized_voxel_buffer;
|
||||
ZYLANN_TEST_ASSERT(BlockSerializer::deserialize(to_span_const(data), deserialized_voxel_buffer));
|
||||
|
||||
// Must be equal
|
||||
ZYLANN_TEST_ASSERT(voxel_buffer.equals(deserialized_voxel_buffer));
|
||||
}
|
||||
{
|
||||
// Serialize
|
||||
BlockSerializer::SerializeResult result = BlockSerializer::serialize_and_compress(voxel_buffer);
|
||||
ZYLANN_TEST_ASSERT(result.success);
|
||||
std::vector<uint8_t> data = result.data;
|
||||
|
||||
ZYLANN_TEST_ASSERT(data.size() > 0);
|
||||
|
||||
// Deserialize
|
||||
VoxelBufferInternal deserialized_voxel_buffer;
|
||||
ZYLANN_TEST_ASSERT(BlockSerializer::decompress_and_deserialize(to_span_const(data), deserialized_voxel_buffer));
|
||||
|
||||
// Must be equal
|
||||
ZYLANN_TEST_ASSERT(voxel_buffer.equals(deserialized_voxel_buffer));
|
||||
}
|
||||
}
|
||||
|
||||
void test_block_serializer_stream_peer() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user