1
0

Fixed cBlockArea schematic string saving signature.

This commit is contained in:
madmaxoft 2014-03-07 21:28:52 +01:00
parent 51c1849762
commit ffdf5f2022
4 changed files with 13 additions and 10 deletions

View File

@ -162,7 +162,7 @@ g_APIDesc =
RotateCW = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, clockwise (north -> east). Modifies blocks' metas (if present) to match." },
RotateCWNoMeta = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, clockwise (north -> east). Doesn't modify blocks' metas." },
SaveToSchematicFile = { Params = "FileName", Return = "", Notes = "Saves the current contents to a schematic file. Returns true if successful." },
SaveToSchematicString = { Params = "", Return = "string", Notes = "Saves the current contents to a string (in a .schematic file format). Returns the data if successful, empty string if failed." },
SaveToSchematicString = { Params = "", Return = "string", Notes = "Saves the current contents to a string (in a .schematic file format). Returns the data if successful, nil if failed." },
SetBlockLight = { Params = "BlockX, BlockY, BlockZ, BlockLight", Return = "", Notes = "Sets the blocklight at the specified absolute coords" },
SetBlockMeta = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified absolute coords" },
SetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ, SkyLight", Return = "", Notes = "Sets the skylight at the specified absolute coords" },

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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.