summaryrefslogtreecommitdiffstats
path: root/src/Chunk.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-29 16:27:19 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-29 16:27:19 +0200
commit8811837aea2a33ba5da424087429864f811bf5e5 (patch)
treebaeedba8fb618766cf7d4e1657d2d48c84f45a59 /src/Chunk.cpp
parentSuggestions (diff)
parentDistortedHeightmap: Now generates gravel in deep ocean. (diff)
downloadcuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar
cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.gz
cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.bz2
cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.lz
cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.xz
cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.zst
cuberite-8811837aea2a33ba5da424087429864f811bf5e5.zip
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r--src/Chunk.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index 0be61f753..b83036b6d 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -34,6 +34,7 @@
#include "MobCensus.h"
#include "MobSpawner.h"
#include "BlockInServerPluginInterface.h"
+#include "SetChunkData.h"
#include "json/json.h"
@@ -265,41 +266,34 @@ void cChunk::GetAllData(cChunkDataCallback & a_Callback)
-void cChunk::SetAllData(
- const BLOCKTYPE * a_BlockTypes,
- const NIBBLETYPE * a_BlockMeta,
- const NIBBLETYPE * a_BlockLight,
- const NIBBLETYPE * a_BlockSkyLight,
- const HeightMap * a_HeightMap,
- const BiomeMap & a_BiomeMap,
- cBlockEntityList & a_BlockEntities
-)
+void cChunk::SetAllData(cSetChunkData & a_SetChunkData)
{
- memcpy(m_BiomeMap, a_BiomeMap, sizeof(m_BiomeMap));
+ ASSERT(a_SetChunkData.IsHeightMapValid());
+ ASSERT(a_SetChunkData.AreBiomesValid());
+
+ memcpy(m_BiomeMap, a_SetChunkData.GetBiomes(), sizeof(m_BiomeMap));
+ memcpy(m_HeightMap, a_SetChunkData.GetHeightMap(), sizeof(m_HeightMap));
- if (a_HeightMap != NULL)
+ m_ChunkData.SetBlockTypes(a_SetChunkData.GetBlockTypes());
+ m_ChunkData.SetMetas(a_SetChunkData.GetBlockMetas());
+ if (a_SetChunkData.IsLightValid())
{
- memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap));
+ m_ChunkData.SetBlockLight(a_SetChunkData.GetBlockLight());
+ m_ChunkData.SetSkyLight(a_SetChunkData.GetSkyLight());
+ m_IsLightValid = true;
}
-
- if (a_HeightMap == NULL)
+ else
{
- CalculateHeightmap(a_BlockTypes);
+ m_IsLightValid = false;
}
- m_ChunkData.SetBlockTypes(a_BlockTypes);
- m_ChunkData.SetMetas(a_BlockMeta);
- m_ChunkData.SetBlockLight(a_BlockLight);
- m_ChunkData.SetSkyLight(a_BlockSkyLight);
-
- m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL);
-
// Clear the block entities present - either the loader / saver has better, or we'll create empty ones:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
{
delete *itr;
}
- std::swap(a_BlockEntities, m_BlockEntities);
+ m_BlockEntities.clear();
+ std::swap(a_SetChunkData.GetBlockEntities(), m_BlockEntities);
// Set all block entities' World variable:
for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)