summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-09 21:06:16 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-05-09 21:06:16 +0200
commit7e02ec87b9d7e26e6f811bae4586636c9b880fcb (patch)
tree78ae81695c54cea6d2946bd6c9dad3836112259f /source
parentFixed error while compiling. (diff)
downloadcuberite-7e02ec87b9d7e26e6f811bae4586636c9b880fcb.tar
cuberite-7e02ec87b9d7e26e6f811bae4586636c9b880fcb.tar.gz
cuberite-7e02ec87b9d7e26e6f811bae4586636c9b880fcb.tar.bz2
cuberite-7e02ec87b9d7e26e6f811bae4586636c9b880fcb.tar.lz
cuberite-7e02ec87b9d7e26e6f811bae4586636c9b880fcb.tar.xz
cuberite-7e02ec87b9d7e26e6f811bae4586636c9b880fcb.tar.zst
cuberite-7e02ec87b9d7e26e6f811bae4586636c9b880fcb.zip
Diffstat (limited to 'source')
-rw-r--r--source/Blocks/BlockDirt.h16
-rw-r--r--source/LightingThread.cpp9
2 files changed, 18 insertions, 7 deletions
diff --git a/source/Blocks/BlockDirt.h b/source/Blocks/BlockDirt.h
index 73bc28dc5..6cec5d99e 100644
--- a/source/Blocks/BlockDirt.h
+++ b/source/Blocks/BlockDirt.h
@@ -34,11 +34,14 @@ public:
}
// Grass becomes dirt if there is something on top of it:
- BLOCKTYPE Above = a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ);
- if (!g_BlockTransparent[Above] && !g_BlockOneHitDig[Above])
+ if (a_BlockY < cChunkDef::Height - 1)
{
- a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DIRT, 0);
- return;
+ BLOCKTYPE Above = a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ);
+ if (!g_BlockTransparent[Above] && !g_BlockOneHitDig[Above])
+ {
+ a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DIRT, 0);
+ return;
+ }
}
// Grass spreads to adjacent blocks:
@@ -51,6 +54,11 @@ public:
BLOCKTYPE DestBlock;
NIBBLETYPE DestMeta;
+ if ((a_BlockY + OfsY < 0) || (a_BlockY + OfsY >= cChunkDef::Height - 1))
+ {
+ // Y Coord out of range
+ continue;
+ }
bool IsValid = a_World->GetBlockTypeMeta(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, DestBlock, DestMeta);
if (!IsValid || (DestBlock != E_BLOCK_DIRT))
{
diff --git a/source/LightingThread.cpp b/source/LightingThread.cpp
index 258fd7dd4..d7e60e458 100644
--- a/source/LightingThread.cpp
+++ b/source/LightingThread.cpp
@@ -407,9 +407,12 @@ void cLightingThread::PrepareSkyLight(void)
}
// Add Current as a seed:
- int CurrentIdx = idx + Current * BlocksPerYLayer;
- m_IsSeed1[CurrentIdx] = true;
- m_SeedIdx1[m_NumSeeds++] = CurrentIdx;
+ if (Current < cChunkDef::Height)
+ {
+ int CurrentIdx = idx + Current * BlocksPerYLayer;
+ m_IsSeed1[CurrentIdx] = true;
+ m_SeedIdx1[m_NumSeeds++] = CurrentIdx;
+ }
// Add seed from Current up to the highest neighbor:
for (int y = Current + 1, Index = idx + y * BlocksPerYLayer; y < MaxNeighbor; y++, Index += BlocksPerYLayer)