1
0

Fixed a few out-of-bounds reads

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1465 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-05-09 19:06:16 +00:00
parent 7dc9b2ce8d
commit 7e02ec87b9
2 changed files with 18 additions and 7 deletions

View File

@ -34,12 +34,15 @@ public:
}
// Grass becomes dirt if there is something on top of it:
if (a_BlockY < cChunkDef::Height - 1)
{
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:
MTRand rand;
@ -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))
{

View File

@ -407,9 +407,12 @@ void cLightingThread::PrepareSkyLight(void)
}
// Add Current as a seed:
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)