Fixed new map generator causing a crash when generating at map limit

This commit is contained in:
Perttu Ahola 2011-07-22 01:37:05 +03:00
parent 74ef5b8a42
commit fe855e004f
2 changed files with 42 additions and 28 deletions

@ -2013,6 +2013,14 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
/*dstream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<"," /*dstream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;*/ <<blockpos.Z<<")"<<std::endl;*/
// Do nothing if not inside limits (+-1 because of neighbors)
if(blockpos_over_limit(blockpos - v3s16(1,1,1)) ||
blockpos_over_limit(blockpos + v3s16(1,1,1)))
{
data->no_op = true;
return;
}
data->no_op = false; data->no_op = false;
data->seed = m_seed; data->seed = m_seed;
data->blockpos = blockpos; data->blockpos = blockpos;
@ -2063,6 +2071,7 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
neighboring blocks neighboring blocks
*/ */
// The area that contains this block and it's neighbors
v3s16 bigarea_blocks_min = blockpos - v3s16(1,1,1); v3s16 bigarea_blocks_min = blockpos - v3s16(1,1,1);
v3s16 bigarea_blocks_max = blockpos + v3s16(1,1,1); v3s16 bigarea_blocks_max = blockpos + v3s16(1,1,1);
@ -2087,7 +2096,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
if(data->no_op) if(data->no_op)
{ {
dstream<<"finishBlockMake(): no-op"<<std::endl; //dstream<<"finishBlockMake(): no-op"<<std::endl;
return NULL; return NULL;
} }
@ -2339,12 +2348,13 @@ MapBlock * ServerMap::generateBlock(
Get central block Get central block
*/ */
MapBlock *block = getBlockNoCreateNoEx(p); MapBlock *block = getBlockNoCreateNoEx(p);
assert(block);
#if 0 #if 0
/* /*
Check result Check result
*/ */
if(block)
{
bool erroneus_content = false; bool erroneus_content = false;
for(s16 z0=0; z0<MAP_BLOCKSIZE; z0++) for(s16 z0=0; z0<MAP_BLOCKSIZE; z0++)
for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++) for(s16 y0=0; y0<MAP_BLOCKSIZE; y0++)
@ -2365,12 +2375,15 @@ MapBlock * ServerMap::generateBlock(
{ {
assert(0); assert(0);
} }
}
#endif #endif
#if 0 #if 0
/* /*
Generate a completely empty block Generate a completely empty block
*/ */
if(block)
{
for(s16 z0=0; z0<MAP_BLOCKSIZE; z0++) for(s16 z0=0; z0<MAP_BLOCKSIZE; z0++)
for(s16 x0=0; x0<MAP_BLOCKSIZE; x0++) for(s16 x0=0; x0<MAP_BLOCKSIZE; x0++)
{ {
@ -2384,6 +2397,7 @@ MapBlock * ServerMap::generateBlock(
block->setNode(v3s16(x0,y0,z0), n); block->setNode(v3s16(x0,y0,z0), n);
} }
} }
}
#endif #endif
if(enable_mapgen_debug_info == false) if(enable_mapgen_debug_info == false)

@ -1303,7 +1303,7 @@ void make_block(BlockMakeData *data)
{ {
if(data->no_op) if(data->no_op)
{ {
dstream<<"makeBlock: no-op"<<std::endl; //dstream<<"makeBlock: no-op"<<std::endl;
return; return;
} }