summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-03-12 17:59:10 +0100
committerTycho <work.tycho+git@gmail.com>2014-03-12 17:59:10 +0100
commit3caa4a38b9a60afdda0e76cfb267c49ffac1063c (patch)
tree89bd29d89d6892a94137ebf4829dfe6a4ae3c450 /src/WorldStorage
parentFixed comments an assert (diff)
parentFixed missing comment terminator. (diff)
downloadcuberite-3caa4a38b9a60afdda0e76cfb267c49ffac1063c.tar
cuberite-3caa4a38b9a60afdda0e76cfb267c49ffac1063c.tar.gz
cuberite-3caa4a38b9a60afdda0e76cfb267c49ffac1063c.tar.bz2
cuberite-3caa4a38b9a60afdda0e76cfb267c49ffac1063c.tar.lz
cuberite-3caa4a38b9a60afdda0e76cfb267c49ffac1063c.tar.xz
cuberite-3caa4a38b9a60afdda0e76cfb267c49ffac1063c.tar.zst
cuberite-3caa4a38b9a60afdda0e76cfb267c49ffac1063c.zip
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/SchematicFileSerializer.cpp23
-rw-r--r--src/WorldStorage/WSSCompact.h2
2 files changed, 24 insertions, 1 deletions
diff --git a/src/WorldStorage/SchematicFileSerializer.cpp b/src/WorldStorage/SchematicFileSerializer.cpp
index b021aeb0c..ef67fdb13 100644
--- a/src/WorldStorage/SchematicFileSerializer.cpp
+++ b/src/WorldStorage/SchematicFileSerializer.cpp
@@ -177,6 +177,25 @@ bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cP
a_BlockArea.Clear();
a_BlockArea.SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (cBlockArea::baTypes | cBlockArea::baMetas) : cBlockArea::baTypes);
+ int TOffsetX = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetX");
+ int TOffsetY = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetY");
+ int TOffsetZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetZ");
+
+ if (
+ (TOffsetX < 0) || (TOffsetY < 0) || (TOffsetZ < 0) ||
+ (a_NBT.GetType(TOffsetX) != TAG_Int) ||
+ (a_NBT.GetType(TOffsetY) != TAG_Int) ||
+ (a_NBT.GetType(TOffsetZ) != TAG_Int)
+ )
+ {
+ // Not every schematic file has an offset, so we shoudn't give a warn message.
+ a_BlockArea.SetWEOffset(0, 0, 0);
+ }
+ else
+ {
+ a_BlockArea.SetWEOffset(a_NBT.GetInt(TOffsetX), a_NBT.GetInt(TOffsetY), a_NBT.GetInt(TOffsetZ));
+ }
+
// Copy the block types and metas:
int NumBytes = a_BlockArea.m_SizeX * a_BlockArea.m_SizeY * a_BlockArea.m_SizeZ;
if (a_NBT.GetDataLength(TBlockTypes) < NumBytes)
@@ -234,6 +253,10 @@ AString cSchematicFileSerializer::SaveToSchematicNBT(const cBlockArea & a_BlockA
Writer.AddByteArray("Data", Dummy.data(), Dummy.size());
}
+ Writer.AddInt("WEOffsetX", a_BlockArea.m_WEOffset.x);
+ Writer.AddInt("WEOffsetY", a_BlockArea.m_WEOffset.y);
+ Writer.AddInt("WEOffsetZ", a_BlockArea.m_WEOffset.z);
+
// TODO: Save entities and block entities
Writer.BeginList("Entities", TAG_Compound);
Writer.EndList();
diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h
index 64b8d7f31..4df146ec3 100644
--- a/src/WorldStorage/WSSCompact.h
+++ b/src/WorldStorage/WSSCompact.h
@@ -12,7 +12,7 @@
#define WSSCOMPACT_H_INCLUDED
#include "WorldStorage.h"
-#include "../Vector3i.h"
+#include "../Vector3.h"
#include "json/json.h"