From e92238edc831a34081790e71249f1459e997974c Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 1 Feb 2011 16:17:55 +0200 Subject: This map generator is starting to look pretty good now... also, disabled loading player position from disk because map is regenerated always. --- src/map.h | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) (limited to 'src/map.h') diff --git a/src/map.h b/src/map.h index 757f06ab5..048aeb9b6 100644 --- a/src/map.h +++ b/src/map.h @@ -100,7 +100,9 @@ public: This is overloaded by ClientMap and ServerMap to allow their differing fetch methods. */ - virtual MapSector * emergeSector(v2s16 p) = 0; + virtual MapSector * emergeSector(v2s16 p){ return NULL; } + virtual MapSector * emergeSector(v2s16 p, + core::map &changed_blocks){ return NULL; } // Returns InvalidPositionException if not found MapBlock * getBlockNoCreate(v3s16 p); @@ -364,22 +366,42 @@ public: 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) + { + /*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; + } + /* Generate a chunk. All chunks touching this one can be altered also. - - Doesn't update lighting. */ - MapChunk* generateChunkRaw(v2s16 chunkpos); + MapChunk* generateChunkRaw(v2s16 chunkpos, + core::map &changed_blocks); /* Generate a chunk and its neighbors so that it won't be touched anymore. - - Doesn't update lighting. */ - MapChunk* generateChunk(v2s16 chunkpos); + MapChunk* generateChunk(v2s16 chunkpos, + core::map &changed_blocks); /* Generate a sector. @@ -402,7 +424,14 @@ public: - Check disk (loads blocks also) - Generate chunk */ - MapSector * emergeSector(v2s16 p); + MapSector * emergeSector(v2s16 p, + core::map &changed_blocks); + + MapSector * emergeSector(v2s16 p) + { + core::map changed_blocks; + return emergeSector(p, changed_blocks); + } MapBlock * generateBlock( v3s16 p, @@ -418,7 +447,11 @@ public: - 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, -- cgit v1.2.3