X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fserialization.cpp;h=c0fbe10e23335fb9cc8f2031dd8637e0cec548a3;hb=63867b1a372a4d1a4a4ffdec9d0862b094211a89;hp=118bad467c91e880a3a1cecb0e9ed77dd678c65c;hpb=6d0ea26c2d62c3774ff384cf1bfc2a3372b49a3b;p=minetest.git diff --git a/src/serialization.cpp b/src/serialization.cpp index 118bad467..c0fbe10e2 100644 --- a/src/serialization.cpp +++ b/src/serialization.cpp @@ -53,7 +53,7 @@ void zerr(int ret) } } -void compressZlib(SharedBuffer data, std::ostream &os) +void compressZlib(SharedBuffer data, std::ostream &os, int level) { z_stream z; const s32 bufsize = 16384; @@ -65,7 +65,7 @@ void compressZlib(SharedBuffer data, std::ostream &os) z.zfree = Z_NULL; z.opaque = Z_NULL; - ret = deflateInit(&z, -1); + ret = deflateInit(&z, level); if(ret != Z_OK) throw SerializationError("compressZlib: deflateInit failed"); @@ -94,13 +94,12 @@ void compressZlib(SharedBuffer data, std::ostream &os) } deflateEnd(&z); - } -void compressZlib(const std::string &data, std::ostream &os) +void compressZlib(const std::string &data, std::ostream &os, int level) { SharedBuffer databuf((u8*)data.c_str(), data.size()); - compressZlib(databuf, os); + compressZlib(databuf, os, level); } void decompressZlib(std::istream &is, std::ostream &os)