summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-09-03 19:36:53 +0200
committermadmaxoft <github@xoft.cz>2014-09-03 19:36:53 +0200
commit44c1d9c2480fe6ea37dbed6199b51acf035de0c2 (patch)
tree23c4e5eb1578cc9d68ff3f184f857fa8cb1af9a3 /src/WorldStorage/WSSAnvil.cpp
parentFixed style and alpha-sorting. (diff)
downloadcuberite-44c1d9c2480fe6ea37dbed6199b51acf035de0c2.tar
cuberite-44c1d9c2480fe6ea37dbed6199b51acf035de0c2.tar.gz
cuberite-44c1d9c2480fe6ea37dbed6199b51acf035de0c2.tar.bz2
cuberite-44c1d9c2480fe6ea37dbed6199b51acf035de0c2.tar.lz
cuberite-44c1d9c2480fe6ea37dbed6199b51acf035de0c2.tar.xz
cuberite-44c1d9c2480fe6ea37dbed6199b51acf035de0c2.tar.zst
cuberite-44c1d9c2480fe6ea37dbed6199b51acf035de0c2.zip
Diffstat (limited to 'src/WorldStorage/WSSAnvil.cpp')
-rw-r--r--src/WorldStorage/WSSAnvil.cpp24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 815b6544f..239f4a155 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -66,9 +66,6 @@ Since only the header is actually in the memory, this number can be high, but st
*/
#define MAX_MCA_FILES 32
-/// The maximum size of an inflated chunk; raw chunk data is 192 KiB, allow 64 KiB more of entities
-#define CHUNK_INFLATE_MAX 256 KiB
-
#define LOAD_FAILED(CHX, CHZ) \
{ \
const int RegionX = FAST_FLOOR_DIV(CHX, 32); \
@@ -260,27 +257,18 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk)
bool cWSSAnvil::LoadChunkFromData(const cChunkCoords & a_Chunk, const AString & a_Data)
{
- // Decompress the data:
- char Uncompressed[CHUNK_INFLATE_MAX];
- z_stream strm;
- strm.zalloc = (alloc_func)NULL;
- strm.zfree = (free_func)NULL;
- strm.opaque = NULL;
- inflateInit(&strm);
- strm.next_out = (Bytef *)Uncompressed;
- strm.avail_out = sizeof(Uncompressed);
- strm.next_in = (Bytef *)a_Data.data();
- strm.avail_in = (uInt)a_Data.size();
- int res = inflate(&strm, Z_FINISH);
- inflateEnd(&strm);
- if (res != Z_STREAM_END)
+ // Uncompress the data:
+ AString Uncompressed;
+ int res = InflateString(a_Data.data(), a_Data.size(), Uncompressed);
+ if (res != Z_OK)
{
+ LOGWARNING("Uncompressing chunk [%d, %d] failed: %d", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, res);
LOAD_FAILED(a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
return false;
}
// Parse the NBT data:
- cParsedNBT NBT(Uncompressed, strm.total_out);
+ cParsedNBT NBT(Uncompressed.data(), Uncompressed.size());
if (!NBT.IsValid())
{
// NBT Parsing failed