summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WSSAnvil.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2019-09-24 14:20:50 +0200
committerMattes D <github@xoft.cz>2019-09-24 17:38:59 +0200
commit66e73a2d682f02224a2c84319f6db03964ecbac2 (patch)
tree681876b2622b843b1cb98cae4a875ac2d7771e75 /src/WorldStorage/WSSAnvil.cpp
parentAdd ProtocolBlockTypePalette (#4391) (diff)
downloadcuberite-66e73a2d682f02224a2c84319f6db03964ecbac2.tar
cuberite-66e73a2d682f02224a2c84319f6db03964ecbac2.tar.gz
cuberite-66e73a2d682f02224a2c84319f6db03964ecbac2.tar.bz2
cuberite-66e73a2d682f02224a2c84319f6db03964ecbac2.tar.lz
cuberite-66e73a2d682f02224a2c84319f6db03964ecbac2.tar.xz
cuberite-66e73a2d682f02224a2c84319f6db03964ecbac2.tar.zst
cuberite-66e73a2d682f02224a2c84319f6db03964ecbac2.zip
Diffstat (limited to 'src/WorldStorage/WSSAnvil.cpp')
-rwxr-xr-xsrc/WorldStorage/WSSAnvil.cpp61
1 files changed, 2 insertions, 59 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index d2f3284f5..8c6c9fb67 100755
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -491,68 +491,11 @@ void cWSSAnvil::CopyNBTData(const cParsedNBT & a_NBT, int a_Tag, const AString &
bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_Writer)
{
- a_Writer.BeginCompound("Level");
- a_Writer.AddInt("xPos", a_Chunk.m_ChunkX);
- a_Writer.AddInt("zPos", a_Chunk.m_ChunkZ);
-
- cNBTChunkSerializer Serializer(a_Writer);
- if (!m_World->GetChunkData(a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, Serializer))
+ if (!NBTChunkSerializer::serialize(*m_World, a_Chunk, a_Writer))
{
- LOGWARNING("Cannot get chunk [%d, %d] data for NBT saving", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
+ LOGWARNING("Failed to save chunk %s.", a_Chunk.ToString());
return false;
}
- Serializer.Finish(); // Close NBT tags
-
- // Save biomes, both MCS (IntArray) and MC-vanilla (ByteArray):
- if (Serializer.m_BiomesAreValid)
- {
- a_Writer.AddByteArray("Biomes", reinterpret_cast<const char *>(Serializer.m_VanillaBiomes), ARRAYCOUNT(Serializer.m_VanillaBiomes));
- a_Writer.AddIntArray ("MCSBiomes", reinterpret_cast<const int *>(Serializer.m_Biomes), ARRAYCOUNT(Serializer.m_Biomes));
- }
-
- // Save heightmap (Vanilla require this):
- a_Writer.AddIntArray("HeightMap", reinterpret_cast<const int *>(Serializer.m_VanillaHeightMap), ARRAYCOUNT(Serializer.m_VanillaHeightMap));
-
- // Save blockdata:
- a_Writer.BeginList("Sections", TAG_Compound);
- 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", 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();
- }
- a_Writer.EndList(); // "Sections"
-
- // Store the information that the lighting is valid.
- // For compatibility reason, the default is "invalid" (missing) - this means older data is re-lighted upon loading.
- if (Serializer.IsLightValid())
- {
- a_Writer.AddByte("MCSIsLightValid", 1);
- }
-
- // Save the world age to the chunk data. Required by vanilla and mcedit.
- a_Writer.AddLong("LastUpdate", m_World->GetWorldAge());
-
- // Store the flag that the chunk has all the ores, trees, dungeons etc. MCS chunks are always complete.
- a_Writer.AddByte("TerrainPopulated", 1);
-
- a_Writer.EndCompound(); // "Level"
return true;
}