summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2017-08-21 00:23:23 +0200
committerLukas Pioch <lukas@zgow.de>2017-08-26 20:56:44 +0200
commit447d929da18b656227c77d9c00958bcf52afeeb2 (patch)
tree9614d84d6164f79be0061495a684d76b583f1f13 /src/WorldStorage
parentLeashes work in 1.12.1 (diff)
downloadcuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar
cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.gz
cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.bz2
cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.lz
cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.xz
cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.tar.zst
cuberite-447d929da18b656227c77d9c00958bcf52afeeb2.zip
Diffstat (limited to 'src/WorldStorage')
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp6
-rw-r--r--src/WorldStorage/NBTChunkSerializer.h13
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp32
3 files changed, 25 insertions, 26 deletions
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 73c633e1a..1e8543648 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -68,11 +68,11 @@ void cNBTChunkSerializer::Finish(void)
m_Writer.EndList();
}
- // If light not valid, reset it to all zeroes:
+ // If light not valid, reset it to defaults:
if (!m_IsLightValid)
{
- memset(m_BlockLight, 0, sizeof(m_BlockLight));
- memset(m_BlockSkyLight, 0, sizeof(m_BlockSkyLight));
+ m_Data.FillBlockLight(0x00);
+ m_Data.FillSkyLight(0x0f);
}
// Check if "Entity" and "TileEntities" lists exists. MCEdit requires this.
diff --git a/src/WorldStorage/NBTChunkSerializer.h b/src/WorldStorage/NBTChunkSerializer.h
index 3637ea655..50d98a518 100644
--- a/src/WorldStorage/NBTChunkSerializer.h
+++ b/src/WorldStorage/NBTChunkSerializer.h
@@ -1,4 +1,4 @@
-
+
// NBTChunkSerializer.h
// Declares the cNBTChunkSerializer class that is used for saving individual chunks into NBT format used by Anvil
@@ -55,7 +55,7 @@ class cPainting;
class cNBTChunkSerializer :
- public cChunkDataSeparateCollector
+ public cChunkDataCopyCollector
{
public:
cChunkDef::BiomeMap m_Biomes;
@@ -69,15 +69,12 @@ public:
/** Close NBT tags that we've opened */
void Finish(void);
- bool IsLightValid(void) const {return m_IsLightValid; }
+ bool IsLightValid(void) const { return m_IsLightValid; }
protected:
- /* From cChunkDataSeparateCollector we inherit:
- - m_BlockTypes[]
- - m_BlockMetas[]
- - m_BlockLight[]
- - m_BlockSkyLight[] */
+ /* From cChunkDataCopyCollector we inherit:
+ - cChunkData m_Data */
cFastNBTWriter & m_Writer;
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index bbbffb07f..a3251481f 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -515,23 +515,25 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_
// Save blockdata:
a_Writer.BeginList("Sections", TAG_Compound);
- size_t SliceSizeBlock = cChunkDef::Width * cChunkDef::Width * 16;
- size_t SliceSizeNibble = SliceSizeBlock / 2;
- const char * BlockTypes = reinterpret_cast<const char *>(Serializer.m_BlockTypes);
- const char * BlockMetas = reinterpret_cast<const char *>(Serializer.m_BlockMetas);
- #ifdef DEBUG_SKYLIGHT
- const char * BlockLight = reinterpret_cast<const char *>(Serializer.m_BlockSkyLight);
- #else
- const char * BlockLight = reinterpret_cast<const char *>(Serializer.m_BlockLight);
- #endif
- const char * BlockSkyLight = reinterpret_cast<const char *>(Serializer.m_BlockSkyLight);
- for (int Y = 0; Y < 16; Y++)
+ for (size_t Y = 0; Y != cChunkData::NumSections; ++Y)
{
+ auto Section = Serializer.m_Data.GetSection(Y);
+ if (Section == nullptr)
+ {
+ continue;
+ }
+
a_Writer.BeginCompound("");
- a_Writer.AddByteArray("Blocks", BlockTypes + static_cast<unsigned int>(Y) * SliceSizeBlock, SliceSizeBlock);
- a_Writer.AddByteArray("Data", BlockMetas + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
- a_Writer.AddByteArray("SkyLight", BlockSkyLight + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
- a_Writer.AddByteArray("BlockLight", BlockLight + static_cast<unsigned int>(Y) * SliceSizeNibble, SliceSizeNibble);
+ a_Writer.AddByteArray("Blocks", reinterpret_cast<const char *>(Section->m_BlockTypes), ARRAYCOUNT(Section->m_BlockTypes));
+ a_Writer.AddByteArray("Data", reinterpret_cast<const char *>(Section->m_BlockMetas), ARRAYCOUNT(Section->m_BlockMetas));
+
+ #ifdef DEBUG_SKYLIGHT
+ a_Writer.AddByteArray("BlockLight", reinterpret_cast<const char *>(Section->m_BlockSkyLight), ARRAYCOUNT(Section->m_BlockSkyLight));
+ #else
+ a_Writer.AddByteArray("BlockLight", reinterpret_cast<const char *>(Section->m_BlockLight), ARRAYCOUNT(Section->m_BlockLight));
+ #endif
+
+ a_Writer.AddByteArray("SkyLight", reinterpret_cast<const char *>(Section->m_BlockSkyLight), ARRAYCOUNT(Section->m_BlockSkyLight));
a_Writer.AddByte("Y", static_cast<unsigned char>(Y));
a_Writer.EndCompound();
}