summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-04-03 20:17:04 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-04-03 20:17:04 +0200
commitd5faf5a38ebe164d705cc67baaa4b3c9d7eb6159 (patch)
treee6d769b5884c9e7dbe91ffe82fa08417f6afcecc
parentPerformance improvements and chunk flipping fixed (diff)
downloadcuberite-d5faf5a38ebe164d705cc67baaa4b3c9d7eb6159.tar
cuberite-d5faf5a38ebe164d705cc67baaa4b3c9d7eb6159.tar.gz
cuberite-d5faf5a38ebe164d705cc67baaa4b3c9d7eb6159.tar.bz2
cuberite-d5faf5a38ebe164d705cc67baaa4b3c9d7eb6159.tar.lz
cuberite-d5faf5a38ebe164d705cc67baaa4b3c9d7eb6159.tar.xz
cuberite-d5faf5a38ebe164d705cc67baaa4b3c9d7eb6159.tar.zst
cuberite-d5faf5a38ebe164d705cc67baaa4b3c9d7eb6159.zip
-rw-r--r--src/Chunk.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index a73bf7ca9..d80e93702 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -242,11 +242,12 @@ void cChunk::GetAllData(cChunkDataCallback & a_Callback)
a_Callback.BiomeData (&m_BiomeMap);
std::vector<BLOCKTYPE> Blocks;
- Blocks.reserve(cChunkDef::NumBlocks);
+ Blocks.reserve(NumBlocks);
for (std::vector<std::vector<BLOCKTYPE>>::const_iterator itr = m_BlockTypes.begin(); itr != m_BlockTypes.end(); ++itr)
{
Blocks.insert(Blocks.end(), itr->begin(), itr->end());
}
+ Blocks.resize(NumBlocks);
a_Callback.BlockTypes (Blocks.data());
a_Callback.BlockMeta (m_BlockMeta);
@@ -291,7 +292,7 @@ void cChunk::SetAllData(
m_BlockTypes.clear();
m_BlockTypes.reserve(Height / 2);
- for (int y = Height; y >= 0; y--)
+ for (int y = Height - 1; y >= 0; y--)
{
for (int z = 0; z < Width; z++)
{
@@ -393,11 +394,12 @@ void cChunk::SetLight(
void cChunk::GetBlockTypes(BLOCKTYPE * a_BlockTypes)
{
std::vector<BLOCKTYPE> Blocks;
- Blocks.reserve(cChunkDef::NumBlocks);
+ Blocks.reserve(NumBlocks);
for (std::vector<std::vector<BLOCKTYPE>>::const_iterator itr = m_BlockTypes.begin(); itr != m_BlockTypes.end(); ++itr)
{
Blocks.insert(Blocks.end(), itr->begin(), itr->end());
}
+ Blocks.resize(NumBlocks);
memcpy(a_BlockTypes, Blocks.data(), NumBlocks);
}