+
+ // Returns the position of the chunk where the sector is in
+ v2s16 sector_to_chunk(v2s16 sectorpos)
+ {
+ if(m_chunksize == 0)
+ return v2s16(0,0);
+ sectorpos.X += m_chunksize / 2;
+ sectorpos.Y += m_chunksize / 2;
+ v2s16 chunkpos = getContainerPos(sectorpos, m_chunksize);
+ return chunkpos;
+ }
+
+ // Returns the position of the (0,0) sector of the chunk
+ v2s16 chunk_to_sector(v2s16 chunkpos)
+ {
+ if(m_chunksize == 0)
+ return v2s16(0,0);
+ v2s16 sectorpos(
+ chunkpos.X * m_chunksize,
+ chunkpos.Y * m_chunksize
+ );
+ sectorpos.X -= m_chunksize / 2;
+ sectorpos.Y -= m_chunksize / 2;
+ return sectorpos;
+ }
+
+ /*
+ Get a chunk.
+ */
+ MapChunk *getChunk(v2s16 chunkpos)
+ {
+ core::map<v2s16, MapChunk*>::Node *n;
+ n = m_chunks.find(chunkpos);
+ if(n == NULL)
+ return NULL;
+ return n->getValue();
+ }
+
+ /*
+ True if the chunk and its neighbors are fully generated.
+ It means the chunk will not be touched in the future by the
+ generator. If false, generateChunk will make it true.
+ */
+ bool chunkNonVolatile(v2s16 chunkpos)
+ {
+ if(m_chunksize == 0)
+ return true;
+
+ /*for(s16 x=-1; x<=1; x++)
+ for(s16 y=-1; y<=1; y++)*/
+ s16 x=0;
+ s16 y=0;
+ {
+ v2s16 chunkpos0 = chunkpos + v2s16(x,y);
+ MapChunk *chunk = getChunk(chunkpos);
+ if(chunk == NULL)
+ return false;
+ if(chunk->getGenLevel() != GENERATED_FULLY)
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ Returns true if any chunk is marked as modified
+ */
+ bool anyChunkModified()
+ {
+ for(core::map<v2s16, MapChunk*>::Iterator
+ i = m_chunks.getIterator();
+ i.atEnd()==false; i++)
+ {
+ v2s16 p = i.getNode()->getKey();
+ MapChunk *chunk = i.getNode()->getValue();
+ if(chunk->isModified())
+ return true;
+ }
+ return false;
+ }
+
+ void setChunksNonModified()
+ {
+ for(core::map<v2s16, MapChunk*>::Iterator
+ i = m_chunks.getIterator();
+ i.atEnd()==false; i++)
+ {
+ v2s16 p = i.getNode()->getKey();
+ MapChunk *chunk = i.getNode()->getValue();
+ chunk->setModified(false);
+ }
+ }
+
+ /*
+ Chunks are generated by using these and makeChunk().
+ */
+ void initChunkMake(ChunkMakeData &data, v2s16 chunkpos);
+ MapChunk* finishChunkMake(ChunkMakeData &data,
+ core::map<v3s16, MapBlock*> &changed_blocks);
+
+ /*
+ Generate a chunk.
+
+ All chunks touching this one can be altered also.
+ */
+ /*MapChunk* generateChunkRaw(v2s16 chunkpos,
+ core::map<v3s16, MapBlock*> &changed_blocks,
+ bool force=false);*/
+
+ /*
+ Generate a chunk and its neighbors so that it won't be touched
+ anymore.
+ */
+ /*MapChunk* generateChunk(v2s16 chunkpos,
+ core::map<v3s16, MapBlock*> &changed_blocks);*/
+
+ /*
+ Generate a sector.
+
+ This is mainly called by generateChunkRaw.
+ */
+ //ServerMapSector * generateSector(v2s16 p);
+
+ /*
+ Get a sector from somewhere.
+ - Check memory
+ - Check disk (loads blocks also)
+ - Create blank one
+ */
+ ServerMapSector * createSector(v2s16 p);
+
+ /*
+ Get a sector from somewhere.
+ - Check memory
+ - Check disk (loads blocks also)
+ - Generate chunk
+ */
+ /*MapSector * emergeSector(v2s16 p,
+ core::map<v3s16, MapBlock*> &changed_blocks);*/
+
+ /*MapSector * emergeSector(v2s16 p)
+ {
+ core::map<v3s16, MapBlock*> changed_blocks;
+ return emergeSector(p, changed_blocks);
+ }*/
+
+ MapBlock * generateBlock(
+ v3s16 p,
+ MapBlock *original_dummy,
+ ServerMapSector *sector,
+ core::map<v3s16, MapBlock*> &changed_blocks,
+ core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
+ );
+
+ /*
+ Get a block from somewhere.
+ - Memory
+ - Create blank
+ */
+ MapBlock * createBlock(v3s16 p);
+
+ /*
+ only_from_disk, changed_blocks and lighting_invalidated_blocks
+ are not properly used by the new map generator.
+ */
+ MapBlock * emergeBlock(
+ v3s16 p,
+ bool only_from_disk,
+ core::map<v3s16, MapBlock*> &changed_blocks,
+ core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
+ );
+
+#if 0