From b0b5c432542ea5f9292f428bb59e2670c0d7c53d Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 10 Apr 2011 22:50:31 +0300 Subject: better support for old maps --- src/map.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 8 deletions(-) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index c258d157b..7fe58dc11 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1801,7 +1801,6 @@ ServerMap::ServerMap(std::string savedir): //m_chunksize = 4; //m_chunksize = 2; - // TODO: Save to and load from a file m_seed = (((u64)(myrand()%0xffff)<<0) + ((u64)(myrand()%0xffff)<<16) + ((u64)(myrand()%0xffff)<<32) @@ -1838,8 +1837,16 @@ ServerMap::ServerMap(std::string savedir): // Load map metadata (seed, chunksize) loadMapMeta(); - // Load chunk metadata - loadChunkMeta(); + try{ + // Load chunk metadata + loadChunkMeta(); + } + catch(FileNotGoodException &e){ + dstream<no_op) + return; + s16 y_nodes_min = data->y_blocks_min * MAP_BLOCKSIZE; s16 y_nodes_max = data->y_blocks_max * MAP_BLOCKSIZE + MAP_BLOCKSIZE - 1; s16 h_blocks = data->y_blocks_max - data->y_blocks_min + 1; @@ -2938,8 +2948,8 @@ void makeChunk(ChunkMakeData *data) // Add to transforming liquid queue (in case it'd // start flowing) - /*v3s16 p = v3s16(p2d.X, y, p2d.Y); - m_transforming_liquid.push_back(p);*/ + v3s16 p = v3s16(p2d.X, y, p2d.Y); + data->transforming_liquid.push_back(p); } // Next one @@ -3419,6 +3429,14 @@ void makeChunk(ChunkMakeData *data) 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); @@ -3449,7 +3467,7 @@ void ServerMap::initChunkMake(ChunkMakeData &data, v2s16 chunkpos) Create the whole area of this and the neighboring chunks */ { - TimeTaker timer("generateChunkRaw() create area"); + TimeTaker timer("initChunkMake() create area"); for(s16 x=0; x &changed_blocks) { + if(data.no_op) + return NULL; + /* Blit generated stuff to map */ @@ -3533,6 +3554,15 @@ MapChunk* ServerMap::finishChunkMake(ChunkMakeData &data, } } + /* + Copy transforming liquid information + */ + while(data.transforming_liquid.size() > 0) + { + v3s16 p = data.transforming_liquid.pop_front(); + m_transforming_liquid.push_back(p); + } + /* Add random objects to blocks */ @@ -3590,6 +3620,7 @@ MapChunk* ServerMap::finishChunkMake(ChunkMakeData &data, return chunk; } +#if 0 // NOTE: Deprecated MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos, core::map &changed_blocks, @@ -3661,6 +3692,7 @@ MapChunk* ServerMap::generateChunk(v2s16 chunkpos1, MapChunk *chunk = getChunk(chunkpos1); return chunk; } +#endif ServerMapSector * ServerMap::createSector(v2s16 p2d) { @@ -3715,6 +3747,7 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d) return sector; } +#if 0 MapSector * ServerMap::emergeSector(v2s16 p2d, core::map &changed_blocks) { @@ -3801,6 +3834,7 @@ MapSector * ServerMap::emergeSector(v2s16 p2d, */ //return generateSector(); } +#endif /* NOTE: This is not used for main map generation, only for blocks @@ -3817,6 +3851,14 @@ MapBlock * ServerMap::generateBlock( DSTACK("%s: p=(%d,%d,%d)", __FUNCTION_NAME, p.X, p.Y, p.Z); + + // If chunks are disabled + /*if(m_chunksize == 0) + { + dstream<<"ServerMap::generateBlock(): Chunks disabled -> " + <<"not generating."<