diff --git a/src/voxels/Chunk.cpp b/src/voxels/Chunk.cpp index 5dfb9fe3..80bfcd73 100644 --- a/src/voxels/Chunk.cpp +++ b/src/voxels/Chunk.cpp @@ -158,7 +158,6 @@ bool Chunk::decodeV2(const ubyte* data) { void Chunk::convert(ubyte* data, const ContentReport* report) { for (uint i = 0; i < CHUNK_VOL; i++) { - // see encode method to understand what the hell is going on here blockid_t id = ((static_cast(data[i]) << 8) | static_cast(data[CHUNK_VOL + i])); @@ -167,3 +166,12 @@ void Chunk::convert(ubyte* data, const ContentReport* report) { data[CHUNK_VOL + i] = replacement & 0xFF; } } + +void Chunk::convertV2(ubyte* data, const ContentReport* report) { + auto buffer = reinterpret_cast(data); + for (uint i = 0; i < CHUNK_VOL; i++) { + blockid_t id = dataio::le2h(buffer[i]); + blockid_t replacement = report->blocks.getId(id); + buffer[i] = dataio::h2le(replacement); + } +} diff --git a/src/voxels/Chunk.hpp b/src/voxels/Chunk.hpp index bd8bf965..382c69f3 100644 --- a/src/voxels/Chunk.hpp +++ b/src/voxels/Chunk.hpp @@ -81,4 +81,5 @@ public: bool decodeV2(const ubyte* data); static void convert(ubyte* data, const ContentReport* report); + static void convertV2(ubyte* data, const ContentReport* report); };