]> git.lizzy.rs Git - minetest.git/blobdiff - src/serialization.cpp
* refactored liquid transformation code (has some flaws)
[minetest.git] / src / serialization.cpp
index eb80f3c608b3ec000bd393426f398b91a21974ba..ff7ca15f2571e08f938afddb4caf28c08e9af74e 100644 (file)
@@ -19,6 +19,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "serialization.h"
 #include "utility.h"
+#ifdef _WIN32
+       #define ZLIB_WINAPI
+#endif
 #include "zlib.h"
 
 /* report a zlib or i/o error */
@@ -102,6 +105,12 @@ void compressZlib(SharedBuffer<u8> data, std::ostream &os)
 
 }
 
+void compressZlib(const std::string &data, std::ostream &os)
+{
+       SharedBuffer<u8> databuf((u8*)data.c_str(), data.size());
+       compressZlib(databuf, os);
+}
+
 void decompressZlib(std::istream &is, std::ostream &os)
 {
        z_stream z;
@@ -119,7 +128,7 @@ void decompressZlib(std::istream &is, std::ostream &os)
 
        ret = inflateInit(&z);
        if(ret != Z_OK)
-               throw SerializationError("compressZlib: inflateInit failed");
+               throw SerializationError("dcompressZlib: inflateInit failed");
        
        z.avail_in = 0;
        
@@ -153,7 +162,7 @@ void decompressZlib(std::istream &is, std::ostream &os)
                                || status == Z_MEM_ERROR)
                {
                        zerr(status);
-                       throw SerializationError("compressZlib: inflate failed");
+                       throw SerializationError("decompressZlib: inflate failed");
                }
                int count = bufsize - z.avail_out;
                //dstream<<"count="<<count<<std::endl;
@@ -173,7 +182,7 @@ void decompressZlib(std::istream &is, std::ostream &os)
                                {
                                        dstream<<"unget #"<<i<<" failed"<<std::endl;
                                        dstream<<"fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;
-                                       throw SerializationError("compressZlib: unget failed");
+                                       throw SerializationError("decompressZlib: unget failed");
                                }
                        }