diff options
author | madmaxoft <github@xoft.cz> | 2014-03-07 21:28:52 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-03-07 21:28:52 +0100 |
commit | ffdf5f2022cbeb568cb6ff28448aad98876334b1 (patch) | |
tree | e2cf24bab59db43a022400c514da6b579914ff88 /src | |
parent | Merge pull request #765 from worktycho/fastmath (diff) | |
download | cuberite-ffdf5f2022cbeb568cb6ff28448aad98876334b1.tar cuberite-ffdf5f2022cbeb568cb6ff28448aad98876334b1.tar.gz cuberite-ffdf5f2022cbeb568cb6ff28448aad98876334b1.tar.bz2 cuberite-ffdf5f2022cbeb568cb6ff28448aad98876334b1.tar.lz cuberite-ffdf5f2022cbeb568cb6ff28448aad98876334b1.tar.xz cuberite-ffdf5f2022cbeb568cb6ff28448aad98876334b1.tar.zst cuberite-ffdf5f2022cbeb568cb6ff28448aad98876334b1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 10 | ||||
-rw-r--r-- | src/WorldStorage/SchematicFileSerializer.cpp | 7 | ||||
-rw-r--r-- | src/WorldStorage/SchematicFileSerializer.h | 4 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 05dc9717e..a5247bbe6 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -2563,9 +2563,13 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * tolua_S) return 0; } - AString Data = cSchematicFileSerializer::SaveToSchematicString(*self); - L.Push(Data); - return 1; + AString Data; + if (cSchematicFileSerializer::SaveToSchematicString(*self, Data)) + { + L.Push(Data); + return 1; + } + return 0; } diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp index a6ae8d8e0..b021aeb0c 100644 --- a/src/WorldStorage/SchematicFileSerializer.cpp +++ b/src/WorldStorage/SchematicFileSerializer.cpp @@ -103,7 +103,7 @@ bool cSchematicFileSerializer::SaveToSchematicFile(const cBlockArea & a_BlockAre -AString cSchematicFileSerializer::SaveToSchematicString(const cBlockArea & a_BlockArea) +bool cSchematicFileSerializer::SaveToSchematicString(const cBlockArea & a_BlockArea, AString & a_Out) { // Serialize into NBT data: AString NBT = SaveToSchematicNBT(a_BlockArea); @@ -114,14 +114,13 @@ AString cSchematicFileSerializer::SaveToSchematicString(const cBlockArea & a_Blo } // Gzip the data: - AString Compressed; - int res = CompressStringGZIP(NBT.data(), NBT.size(), Compressed); + int res = CompressStringGZIP(NBT.data(), NBT.size(), a_Out); if (res != Z_OK) { LOG("%s: Cannot Gzip the area data NBT representation: %d", __FUNCTION__, res); return false; } - return Compressed; + return true; } diff --git a/src/WorldStorage/SchematicFileSerializer.h b/src/WorldStorage/SchematicFileSerializer.h index f6ce1c16c..05b6c74f4 100644 --- a/src/WorldStorage/SchematicFileSerializer.h +++ b/src/WorldStorage/SchematicFileSerializer.h @@ -36,8 +36,8 @@ public: static bool SaveToSchematicFile(const cBlockArea & a_BlockArea, const AString & a_FileName); /** Saves the area into a string containing the .schematic file data. - Returns the data, or empty string if failed. */ - static AString SaveToSchematicString(const cBlockArea & a_BlockArea); + Returns true if successful, false on failure. The data is stored into a_Out. */ + static bool SaveToSchematicString(const cBlockArea & a_BlockArea, AString & a_Out); private: /** Loads the area from a schematic file uncompressed and parsed into a NBT tree. |