Fix issue of VManip occasionally not blitting back blocks, and pitch black lighting bug
authorkwolekr <kwolekr@minetest.net>
Tue, 25 Jun 2013 15:49:08 +0000 (11:49 -0400)
committerkwolekr <kwolekr@minetest.net>
Fri, 28 Jun 2013 02:35:35 +0000 (22:35 -0400)
src/map.cpp
src/map.h

index 001ae1609e3a26063ca396d31b5665a410eb2757..cf7dd6f9fd94fef1e9b6febffe1d3c93d1af0d44 100644 (file)
@@ -2596,7 +2596,7 @@ bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
        // Add the area
        {
                //TimeTaker timer("initBlockMake() initialEmerge");
-               data->vmanip->initialEmerge(bigarea_blocks_min, bigarea_blocks_max);
+               data->vmanip->initialEmerge(bigarea_blocks_min, bigarea_blocks_max, false);
        }
        
        // Ensure none of the blocks to be generated were marked as containing CONTENT_IGNORE
@@ -4202,8 +4202,8 @@ void ManualMapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
        VoxelManipulator::emerge(a, caller_id);
 }
 
-void ManualMapVoxelManipulator::initialEmerge(
-               v3s16 blockpos_min, v3s16 blockpos_max)
+void ManualMapVoxelManipulator::initialEmerge(v3s16 blockpos_min,
+                                               v3s16 blockpos_max, bool load_if_inexistent)
 {
        TimeTaker timer1("initialEmerge", &emerge_time);
 
@@ -4255,18 +4255,28 @@ void ManualMapVoxelManipulator::initialEmerge(
 
                if(block_data_inexistent)
                {
-                       flags |= VMANIP_BLOCK_DATA_INEXIST;
                        
-                       /*
-                               Mark area inexistent
-                       */
-                       VoxelArea a(p*MAP_BLOCKSIZE, (p+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
-                       // Fill with VOXELFLAG_INEXISTENT
-                       for(s32 z=a.MinEdge.Z; z<=a.MaxEdge.Z; z++)
-                       for(s32 y=a.MinEdge.Y; y<=a.MaxEdge.Y; y++)
-                       {
-                               s32 i = m_area.index(a.MinEdge.X,y,z);
-                               memset(&m_flags[i], VOXELFLAG_INEXISTENT, MAP_BLOCKSIZE);
+                       if (load_if_inexistent) {
+                               ServerMap *svrmap = (ServerMap *)m_map;
+                               block = svrmap->emergeBlock(p, false);
+                               if (block == NULL)
+                                       block = svrmap->createBlock(p);
+                               else
+                                       block->copyTo(*this);
+                       } else {
+                               flags |= VMANIP_BLOCK_DATA_INEXIST;
+                               
+                               /*
+                                       Mark area inexistent
+                               */
+                               VoxelArea a(p*MAP_BLOCKSIZE, (p+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
+                               // Fill with VOXELFLAG_INEXISTENT
+                               for(s32 z=a.MinEdge.Z; z<=a.MaxEdge.Z; z++)
+                               for(s32 y=a.MinEdge.Y; y<=a.MaxEdge.Y; y++)
+                               {
+                                       s32 i = m_area.index(a.MinEdge.X,y,z);
+                                       memset(&m_flags[i], VOXELFLAG_INEXISTENT, MAP_BLOCKSIZE);
+                               }
                        }
                }
                /*else if (block->getNode(0, 0, 0).getContent() == CONTENT_IGNORE)
index 8326d3e586312f20e45c27a5ddf38d8af4703a05..bccadcec52a8e0847dc3165c4f5ec8a41180aa98 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -555,7 +555,8 @@ public:
 
        virtual void emerge(VoxelArea a, s32 caller_id=-1);
 
-       void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max);
+       void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
+                                               bool load_if_inexistent = true);
 
        // This is much faster with big chunks of generated data
        void blitBackAll(std::map<v3s16, MapBlock*> * modified_blocks);