processRegionVoxels fix

This commit is contained in:
MihailRis 2024-04-15 01:27:02 +03:00
parent 0cbaa1ccc6
commit d955a0ead3
2 changed files with 3 additions and 1 deletions

View File

@ -598,9 +598,10 @@ void WorldFiles::processRegionVoxels(int x, int z, regionproc func) {
int gx = cx + x * REGION_SIZE;
int gz = cz + z * REGION_SIZE;
uint32_t length;
std::unique_ptr<ubyte[]> data (readChunkData(gx, gz, length, regfile.get()));
auto data = readChunkData(gx, gz, length, regfile.get());
if (data == nullptr)
continue;
data = decompress(data.get(), length, CHUNK_DATA_LEN);
if (func(data.get())) {
put(gx, gz, REGION_LAYER_VOXELS, std::move(data), CHUNK_DATA_LEN, true);
}

View File

@ -117,6 +117,7 @@ class WorldFiles {
/// @param dstlen max expected length of source buffer
/// @return decompressed bytes array
std::unique_ptr<ubyte[]> decompress(const ubyte* src, size_t srclen, size_t dstlen);
std::unique_ptr<ubyte[]> readChunkData(int x, int y, uint32_t& length, regfile* file);
void fetchChunks(WorldRegion* region, int x, int y, regfile* file);