summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2015-06-30 15:04:31 +0200
committerworktycho <work.tycho@gmail.com>2015-06-30 15:04:31 +0200
commit351110fa3cc67e67b42f16e7941891bb51730d07 (patch)
treea9d434cc6f4837495858d5fc39d2683f2569152a
parentFixed typos in the readme. (diff)
parentBlockArea: Fixed a crash with areas higher than chunk height. (diff)
downloadcuberite-351110fa3cc67e67b42f16e7941891bb51730d07.tar
cuberite-351110fa3cc67e67b42f16e7941891bb51730d07.tar.gz
cuberite-351110fa3cc67e67b42f16e7941891bb51730d07.tar.bz2
cuberite-351110fa3cc67e67b42f16e7941891bb51730d07.tar.lz
cuberite-351110fa3cc67e67b42f16e7941891bb51730d07.tar.xz
cuberite-351110fa3cc67e67b42f16e7941891bb51730d07.tar.zst
cuberite-351110fa3cc67e67b42f16e7941891bb51730d07.zip
-rw-r--r--src/BlockArea.cpp8
-rw-r--r--src/Chunk.cpp2
2 files changed, 8 insertions, 2 deletions
diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp
index 938351207..eb25d624d 100644
--- a/src/BlockArea.cpp
+++ b/src/BlockArea.cpp
@@ -336,6 +336,12 @@ void cBlockArea::Create(int a_SizeX, int a_SizeY, int a_SizeZ, int a_DataTypes)
);
return;
}
+
+ // Warn if the height is too much, but proceed with the creation:
+ if (a_SizeY > cChunkDef::Height)
+ {
+ LOGWARNING("Creating a cBlockArea with height larger than world height (%d). Continuing, but the area may misbehave.", a_SizeY);
+ }
Clear();
int BlockCount = a_SizeX * a_SizeY * a_SizeZ;
@@ -540,7 +546,7 @@ bool cBlockArea::Write(cForEachChunkProvider * a_ForEachChunkProvider, int a_Min
else if (a_MinBlockY > cChunkDef::Height - m_Size.y)
{
LOGWARNING("%s: MinBlockY + m_SizeY more than chunk height, adjusting to chunk height", __FUNCTION__);
- a_MinBlockY = cChunkDef::Height - m_Size.y;
+ a_MinBlockY = std::max(cChunkDef::Height - m_Size.y, 0);
}
return a_ForEachChunkProvider->WriteBlockArea(*this, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index a3192f638..d9410dc8d 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -411,7 +411,7 @@ void cChunk::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock
int OffZ = BlockStartZ - m_PosZ * cChunkDef::Width;
int BaseX = BlockStartX - a_MinBlockX;
int BaseZ = BlockStartZ - a_MinBlockZ;
- int SizeY = a_Area.GetSizeY();
+ int SizeY = std::min(a_Area.GetSizeY(), cChunkDef::Height - a_MinBlockY);
// TODO: Improve this by not calling FastSetBlock() and doing the processing here
// so that the heightmap is touched only once for each column.