+}
+
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+//###################################################################
+
+void ServerMap::initChunkMake(ChunkMakeData &data, v2s16 chunkpos)
+{
+ if(m_chunksize == 0)
+ {
+ data.no_op = true;
+ return;
+ }
+
+ data.no_op = false;
+
+ // The distance how far into the neighbors the generator is allowed to go.
+ s16 max_spread_amount_sectors = 2;
+ assert(max_spread_amount_sectors <= m_chunksize);
+ s16 max_spread_amount = max_spread_amount_sectors * MAP_BLOCKSIZE;
+
+ s16 y_blocks_min = -4;
+ s16 y_blocks_max = 3;
+
+ v2s16 sectorpos_base = chunk_to_sector(chunkpos);
+ s16 sectorpos_base_size = m_chunksize;
+
+ v2s16 sectorpos_bigbase =
+ sectorpos_base - v2s16(1,1) * max_spread_amount_sectors;
+ s16 sectorpos_bigbase_size =
+ sectorpos_base_size + 2 * max_spread_amount_sectors;
+
+ // Check limits
+ const s16 limit = MAP_GENERATION_LIMIT / MAP_BLOCKSIZE;
+ if(sectorpos_bigbase.X < -limit
+ || sectorpos_bigbase.X + sectorpos_bigbase_size >= limit
+ || sectorpos_bigbase.Y < -limit
+ || sectorpos_bigbase.Y + sectorpos_bigbase_size >= limit)
+ {
+ data.no_op = true;
+ return;
+ }
+
+ data.seed = m_seed;
+ data.chunkpos = chunkpos;
+ data.y_blocks_min = y_blocks_min;
+ data.y_blocks_max = y_blocks_max;
+ data.sectorpos_base = sectorpos_base;
+ data.sectorpos_base_size = sectorpos_base_size;
+ data.sectorpos_bigbase = sectorpos_bigbase;
+ data.sectorpos_bigbase_size = sectorpos_bigbase_size;
+ data.max_spread_amount = max_spread_amount;
+
+ /*
+ Create the whole area of this and the neighboring chunks
+ */
+ {
+ TimeTaker timer("initChunkMake() create area");
+
+ for(s16 x=0; x<sectorpos_bigbase_size; x++)
+ for(s16 z=0; z<sectorpos_bigbase_size; z++)
+ {
+ v2s16 sectorpos = sectorpos_bigbase + v2s16(x,z);
+ ServerMapSector *sector = createSector(sectorpos);
+ assert(sector);
+
+ for(s16 y=y_blocks_min; y<=y_blocks_max; y++)
+ {
+ v3s16 blockpos(sectorpos.X, y, sectorpos.Y);
+ MapBlock *block = createBlock(blockpos);
+
+ // Lighting won't be calculated
+ //block->setLightingExpired(true);
+ // Lighting will be calculated
+ block->setLightingExpired(false);
+
+ /*
+ Block gets sunlight if this is true.
+
+ This should be set to true when the top side of a block
+ is completely exposed to the sky.
+
+ Actually this doesn't matter now because the
+ initial lighting is done here.
+ */
+ block->setIsUnderground(y != y_blocks_max);
+ }
+ }
+ }
+
+ /*
+ Now we have a big empty area.
+
+ Make a ManualMapVoxelManipulator that contains this and the
+ neighboring chunks
+ */
+
+ v3s16 bigarea_blocks_min(
+ sectorpos_bigbase.X,
+ y_blocks_min,
+ sectorpos_bigbase.Y
+ );
+ v3s16 bigarea_blocks_max(
+ sectorpos_bigbase.X + sectorpos_bigbase_size - 1,
+ y_blocks_max,
+ sectorpos_bigbase.Y + sectorpos_bigbase_size - 1
+ );
+
+ data.vmanip.setMap(this);
+ // Add the area
+ {
+ TimeTaker timer("initChunkMake() initialEmerge");
+ data.vmanip.initialEmerge(bigarea_blocks_min, bigarea_blocks_max);
+ }
+
+}