summaryrefslogtreecommitdiffstats
path: root/source/BlockArea.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-07 11:09:42 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-07 11:09:42 +0100
commited47a8e409ac8d5273a3d6b61aba90248cc4c70d (patch)
treedc98dfc9bebd34b4746bd4ae83812eb24aef763f /source/BlockArea.cpp
parentAdded a sanity check to cBlockArea:Crop() (diff)
downloadcuberite-ed47a8e409ac8d5273a3d6b61aba90248cc4c70d.tar
cuberite-ed47a8e409ac8d5273a3d6b61aba90248cc4c70d.tar.gz
cuberite-ed47a8e409ac8d5273a3d6b61aba90248cc4c70d.tar.bz2
cuberite-ed47a8e409ac8d5273a3d6b61aba90248cc4c70d.tar.lz
cuberite-ed47a8e409ac8d5273a3d6b61aba90248cc4c70d.tar.xz
cuberite-ed47a8e409ac8d5273a3d6b61aba90248cc4c70d.tar.zst
cuberite-ed47a8e409ac8d5273a3d6b61aba90248cc4c70d.zip
Diffstat (limited to '')
-rw-r--r--source/BlockArea.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/source/BlockArea.cpp b/source/BlockArea.cpp
index 5cc78fd88..f7132f50d 100644
--- a/source/BlockArea.cpp
+++ b/source/BlockArea.cpp
@@ -223,6 +223,52 @@ bool cBlockArea::LoadFromSchematicFile(const AString & a_FileName)
+bool cBlockArea::SaveToSchematicFile(const AString & a_FileName)
+{
+ cFastNBTWriter Writer("Schematic");
+ Writer.AddShort("Width", m_SizeX);
+ Writer.AddShort("Height", m_SizeY);
+ Writer.AddShort("Length", m_SizeZ);
+ Writer.AddString("Materials", "Alpha");
+ if (HasBlockTypes())
+ {
+ Writer.AddByteArray("Blocks", (const char *)m_BlockTypes, GetBlockCount());
+ }
+ else
+ {
+ AString Dummy(GetBlockCount(), 0);
+ Writer.AddByteArray("Blocks", Dummy.data(), Dummy.size());
+ }
+ if (HasBlockMetas())
+ {
+ Writer.AddByteArray("Data", (const char *)m_BlockMetas, GetBlockCount());
+ }
+ else
+ {
+ AString Dummy(GetBlockCount(), 0);
+ Writer.AddByteArray("Data", Dummy.data(), Dummy.size());
+ }
+ Writer.Finish();
+
+ // TODO: Save to file
+ cGZipFile File;
+ if (!File.Open(a_FileName, cGZipFile::fmWrite))
+ {
+ LOG("Cannot open file \"%s\" for writing.", a_FileName.c_str());
+ return false;
+ }
+ if (!File.Write(Writer.GetResult()))
+ {
+ LOG("Cannot write data to file \"%s\".", a_FileName.c_str());
+ return false;
+ }
+ return true;
+}
+
+
+
+
+
void cBlockArea::Crop(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ)
{
if (