Generator: Fixed crash with trees too high.
This commit is contained in:
parent
b0bcd75732
commit
564b9ad337
@ -100,7 +100,7 @@ void cStructGenTrees::GenerateSingleTree(
|
|||||||
|
|
||||||
int Height = a_ChunkDesc.GetHeight(x, z);
|
int Height = a_ChunkDesc.GetHeight(x, z);
|
||||||
|
|
||||||
if ((Height <= 0) || (Height > 240))
|
if ((Height <= 0) || (Height >= 230))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -128,6 +128,11 @@ void cStructGenTrees::GenerateSingleTree(
|
|||||||
// Outside the chunk
|
// Outside the chunk
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (itr->y >= cChunkDef::Height)
|
||||||
|
{
|
||||||
|
// Above the chunk, cut off (this shouldn't happen too often, we're limiting trees to y < 230)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
BLOCKTYPE Block = a_ChunkDesc.GetBlockType(itr->x, itr->y, itr->z);
|
BLOCKTYPE Block = a_ChunkDesc.GetBlockType(itr->x, itr->y, itr->z);
|
||||||
switch (Block)
|
switch (Block)
|
||||||
@ -162,7 +167,7 @@ void cStructGenTrees::ApplyTreeImage(
|
|||||||
// Put the generated image into a_BlockTypes, push things outside this chunk into a_Blocks
|
// Put the generated image into a_BlockTypes, push things outside this chunk into a_Blocks
|
||||||
for (sSetBlockVector::const_iterator itr = a_Image.begin(), end = a_Image.end(); itr != end; ++itr)
|
for (sSetBlockVector::const_iterator itr = a_Image.begin(), end = a_Image.end(); itr != end; ++itr)
|
||||||
{
|
{
|
||||||
if ((itr->ChunkX == a_ChunkX) && (itr->ChunkZ == a_ChunkZ))
|
if ((itr->ChunkX == a_ChunkX) && (itr->ChunkZ == a_ChunkZ) && (itr->y < cChunkDef::Height))
|
||||||
{
|
{
|
||||||
// Inside this chunk, integrate into a_ChunkDesc:
|
// Inside this chunk, integrate into a_ChunkDesc:
|
||||||
switch (a_ChunkDesc.GetBlockType(itr->x, itr->y, itr->z))
|
switch (a_ChunkDesc.GetBlockType(itr->x, itr->y, itr->z))
|
||||||
|
Loading…
Reference in New Issue
Block a user