Don't copy back already generated blocks on map generation
authorkwolekr <kwolekr@minetest.net>
Mon, 7 Jul 2014 05:51:04 +0000 (01:51 -0400)
committerkwolekr <kwolekr@minetest.net>
Mon, 7 Jul 2014 05:51:04 +0000 (01:51 -0400)
src/map.cpp
src/map.h

index 9c06750b81cd38e665bc8745fada7ea10c3318e1..29bbbc0d9388960f3e2ff0f4a4ad133567774b2f 100644 (file)
@@ -2312,7 +2312,7 @@ void ServerMap::finishBlockMake(BlockMakeData *data,
        {
                // 70ms @cs=8
                //TimeTaker timer("finishBlockMake() blitBackAll");
-               data->vmanip->blitBackAll(&changed_blocks);
+               data->vmanip->blitBackAll(&changed_blocks, false);
        }
 
        EMERGE_DBG_OUT("finishBlockMake: changed_blocks.size()=" << changed_blocks.size());
@@ -3586,7 +3586,8 @@ void ManualMapVoxelManipulator::initialEmerge(v3s16 blockpos_min,
 }
 
 void ManualMapVoxelManipulator::blitBackAll(
-               std::map<v3s16, MapBlock*> * modified_blocks)
+               std::map<v3s16, MapBlock*> *modified_blocks,
+               bool overwrite_generated)
 {
        if(m_area.getExtent() == v3s16(0,0,0))
                return;
@@ -3601,10 +3602,9 @@ void ManualMapVoxelManipulator::blitBackAll(
                v3s16 p = i->first;
                MapBlock *block = m_map->getBlockNoCreateNoEx(p);
                bool existed = !(i->second & VMANIP_BLOCK_DATA_INEXIST);
-               if((existed == false) || (block == NULL))
-               {
+               if ((existed == false) || (block == NULL) ||
+                       (overwrite_generated == false && block->isGenerated() == true))
                        continue;
-               }
 
                block->copyFrom(*this);
 
index 4972046f535590329eaae6100ea18aea586122ae..f4c7bb2fceb799026ac998bbe8ce6a2ac871b60e 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -543,10 +543,11 @@ public:
        {m_map = map;}
 
        void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
-                                               bool load_if_inexistent = true);
+                       bool load_if_inexistent = true);
 
        // This is much faster with big chunks of generated data
-       void blitBackAll(std::map<v3s16, MapBlock*> * modified_blocks);
+       void blitBackAll(std::map<v3s16, MapBlock*> * modified_blocks,
+                       bool overwrite_generated = true);
 
 protected:
        bool m_create_area;