You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I managed to parse half of the region files on my server before it got stuck in a loop, with this code calling my reader function repeatedly despite the reader function always returning 0 since there was no more data. I was too lazy to read the zlib documentation in full, but I did find a sentence which suggested ret == Z_OK && stream.avail_in != 0 is the correct condition to determine if inflate() needs to be called again. So I changed the while (stream.avail_out == 0) to while (ret == Z_OK && stream.avail_in != 0) and, IDK if that's correct, but it at least was able to process all of the region files on my server after that change.
In nbt_parse():
do {
stream.avail_in = reader.read(reader.userdata, in_buffer, NBT_BUFFER_SIZE);
stream.next_in = in_buffer;
do {
stream.avail_out = NBT_BUFFER_SIZE;
stream.next_out = out_buffer;
ret = inflate(&stream, Z_NO_FLUSH);
size_t have = NBT_BUFFER_SIZE - stream.avail_out;
buffer = (uint8_t*)NBT_REALLOC(buffer, buffer_size + have);
NBT_MEMCPY(buffer + buffer_size, out_buffer, have);
buffer_size += have;
} while (stream.avail_out == 0);
} while (ret != Z_STREAM_END);
The text was updated successfully, but these errors were encountered:
I forgot to mention that what made me suspect the while() condition was that I put assert(stream.avail_in == 0); before the call to reader.read() and it triggered on the same region file that was giving me trouble.
I managed to parse half of the region files on my server before it got stuck in a loop, with this code calling my reader function repeatedly despite the reader function always returning 0 since there was no more data. I was too lazy to read the zlib documentation in full, but I did find a sentence which suggested
ret == Z_OK && stream.avail_in != 0
is the correct condition to determine if inflate() needs to be called again. So I changed thewhile (stream.avail_out == 0)
towhile (ret == Z_OK && stream.avail_in != 0)
and, IDK if that's correct, but it at least was able to process all of the region files on my server after that change.In nbt_parse():
The text was updated successfully, but these errors were encountered: