summaryrefslogtreecommitdiffstats
path: root/src/ChunkMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ChunkMap.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index a2bc50fe9..d982d0cf3 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -474,6 +474,11 @@ void cChunkMap::CollectPickupsByEntity(cEntity & a_Entity)
BLOCKTYPE cChunkMap::GetBlock(Vector3i a_BlockPos) const
{
+ if (!cChunkDef::IsValidHeight(a_BlockPos))
+ {
+ return 0;
+ }
+
auto chunkPos = cChunkDef::BlockToChunk(a_BlockPos);
auto relPos = cChunkDef::AbsoluteToRelative(a_BlockPos, chunkPos);
@@ -493,6 +498,11 @@ BLOCKTYPE cChunkMap::GetBlock(Vector3i a_BlockPos) const
NIBBLETYPE cChunkMap::GetBlockMeta(Vector3i a_BlockPos) const
{
+ if (!cChunkDef::IsValidHeight(a_BlockPos))
+ {
+ return 0;
+ }
+
auto chunkPos = cChunkDef::BlockToChunk(a_BlockPos);
auto relPos = cChunkDef::AbsoluteToRelative(a_BlockPos, chunkPos);
@@ -585,6 +595,14 @@ void cChunkMap::SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE
bool cChunkMap::GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const
{
+ if (!cChunkDef::IsValidHeight(a_BlockPos))
+ {
+ // Initialise the params to fulfil our contract.
+ a_BlockType = 0;
+ a_BlockMeta = 0;
+ return false;
+ }
+
auto chunkCoord = cChunkDef::BlockToChunk(a_BlockPos);
auto relPos = cChunkDef::AbsoluteToRelative(a_BlockPos, chunkCoord);
@@ -595,6 +613,10 @@ bool cChunkMap::GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE & a_BlockType, N
Chunk->GetBlockTypeMeta(relPos, a_BlockType, a_BlockMeta);
return true;
}
+
+ // Initialise the params to fulfil our contract.
+ a_BlockType = 0;
+ a_BlockMeta = 0;
return false;
}