diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-07-24 11:39:13 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-07-24 11:39:13 +0300 |
commit | 112b85d0fb97b896da977a3915dab73015681896 (patch) | |
tree | 2a33893b0a12e6462933b22ddb34f4097ad45285 /src | |
parent | 8d84086f35b714906be013d536c42cf9c3dd4828 (diff) | |
parent | 52ad5944c080e858c49267c49703ec79b18e120f (diff) | |
download | minetest-112b85d0fb97b896da977a3915dab73015681896.tar.gz minetest-112b85d0fb97b896da977a3915dab73015681896.tar.bz2 minetest-112b85d0fb97b896da977a3915dab73015681896.zip |
merged fix to decapitated trees; other bugs now exists
Diffstat (limited to 'src')
-rw-r--r-- | src/map.cpp | 74 | ||||
-rw-r--r-- | src/mapblock.cpp | 7 |
2 files changed, 63 insertions, 18 deletions
diff --git a/src/map.cpp b/src/map.cpp index 1c63943c4..f0ea2f6f1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2012,8 +2012,8 @@ ServerMap::~ServerMap() void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos) { - /*dstream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<"," - <<blockpos.Z<<")"<<std::endl;*/ + dstream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<"," + <<blockpos.Z<<")"<<std::endl; // Do nothing if not inside limits (+-1 because of neighbors) if(blockpos_over_limit(blockpos - v3s16(1,1,1)) || @@ -2043,25 +2043,28 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos) for(s16 y=-1; y<=1; y++) { - //MapBlock *block = createBlock(blockpos); + v3s16 p(blockpos.X+x, blockpos.Y+y, blockpos.Z+z); + //MapBlock *block = createBlock(p); // 1) get from memory, 2) load from disk - MapBlock *block = emergeBlock(blockpos, false); + MapBlock *block = emergeBlock(p, false); // 3) create a blank one if(block == NULL) - block = createBlock(blockpos); + { + block = createBlock(p); + + /* + Block gets sunlight if this is true. + + Refer to the map generator heuristics. + */ + bool ug = mapgen::block_is_underground(data->seed, p); + block->setIsUnderground(ug); + } // Lighting will not be valid after make_chunk is called block->setLightingExpired(true); // Lighting will be calculated //block->setLightingExpired(false); - - /* - Block gets sunlight if this is true. - - This should be set to true when the top side of a block - is completely exposed to the sky. - */ - block->setIsUnderground(false); } } } @@ -2137,10 +2140,14 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data, assert(block); /* - Set is_underground flag for lighting with sunlight + Set is_underground flag for lighting with sunlight. + + Refer to map generator heuristics. + + NOTE: This is done in initChunkMake */ + //block->setIsUnderground(mapgen::block_is_underground(data->seed, blockpos)); - block->setIsUnderground(mapgen::block_is_underground(data->seed, blockpos)); /* Add sunlight to central block. @@ -2171,6 +2178,13 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data, #if 1 // Center block lighting_update_blocks.insert(block->getPos(), block); + + /*{ + s16 x = 0; + s16 z = 0; + v3s16 p = block->getPos()+v3s16(x,1,z); + lighting_update_blocks[p] = getBlockNoCreateNoEx(p); + }*/ #endif #if 0 // All modified blocks @@ -2187,8 +2201,28 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data, lighting_update_blocks.insert(i.getNode()->getKey(), i.getNode()->getValue()); } + /*// Also force-add all the upmost blocks for proper sunlight + for(s16 x=-1; x<=1; x++) + for(s16 z=-1; z<=1; z++) + { + v3s16 p = block->getPos()+v3s16(x,1,z); + lighting_update_blocks[p] = getBlockNoCreateNoEx(p); + }*/ #endif updateLighting(lighting_update_blocks, changed_blocks); + + /* + Set lighting to non-expired state in all of them. + This is cheating, but it is not fast enough if all of them + would actually be updated. + */ + for(s16 x=-1; x<=1; x++) + for(s16 y=-1; y<=1; y++) + for(s16 z=-1; z<=1; z++) + { + v3s16 p = block->getPos()+v3s16(x,y,z); + getBlockNoCreateNoEx(p)->setLightingExpired(false); + } if(enable_mapgen_debug_info == false) t.stop(true); // Hide output @@ -2479,7 +2513,7 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool allow_generate) { MapBlock *block = getBlockNoCreateNoEx(p); - if(block) + if(block && block->isDummy() == false) return block; } @@ -4081,10 +4115,16 @@ void ManualMapVoxelManipulator::blitBackAll( i = m_loaded_blocks.getIterator(); i.atEnd() == false; i++) { + v3s16 p = i.getNode()->getKey(); bool existed = i.getNode()->getValue(); if(existed == false) + { + // The Great Bug was found using this + /*dstream<<"ManualMapVoxelManipulator::blitBackAll: " + <<"Inexistent ("<<p.X<<","<<p.Y<<","<<p.Z<<")" + <<std::endl;*/ continue; - v3s16 p = i.getNode()->getKey(); + } MapBlock *block = m_map->getBlockNoCreateNoEx(p); if(block == NULL) { diff --git a/src/mapblock.cpp b/src/mapblock.cpp index ead26dd1f..49d215bf6 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -242,7 +242,12 @@ bool MapBlock::propagateSunlight(core::map<v3s16, bool> & light_sources, // Check if node above block has sunlight try{ MapNode n = getNodeParent(v3s16(x, MAP_BLOCKSIZE, z)); - if(n.getContent() == CONTENT_IGNORE || n.getLight(LIGHTBANK_DAY) != LIGHT_SUN) + if(n.getContent() == CONTENT_IGNORE) + { + // Trust heuristics + no_sunlight = is_underground; + } + else if(n.getLight(LIGHTBANK_DAY) != LIGHT_SUN) { no_sunlight = true; } |