diff options
author | Mark Holmquist <marktraceur@gmail.com> | 2011-09-23 07:27:57 -0700 |
---|---|---|
committer | Mark Holmquist <marktraceur@gmail.com> | 2011-09-23 18:14:35 -0700 |
commit | 319f43e6d2d59b6062b3643b8cb26f4153cbc750 (patch) | |
tree | 770cd2a583743e41f80ae00ba265f0bba0fe88ae | |
parent | f19919546de790686a5a042436ff5bc59e5aed09 (diff) | |
download | minetest-319f43e6d2d59b6062b3643b8cb26f4153cbc750.tar.gz minetest-319f43e6d2d59b6062b3643b8cb26f4153cbc750.tar.bz2 minetest-319f43e6d2d59b6062b3643b8cb26f4153cbc750.zip |
Fixed saplings growing into trees (thanks so much, Kahrl!)
Put the random interval back to 1 in 50 chance. It's not as rare as rats, but rarer than grass.
-rw-r--r-- | src/environment.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index 93f1627c5..71fceae28 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -929,17 +929,30 @@ void ServerEnvironment::step(float dtime) */ if(n.getContent() == CONTENT_SAPLING) { - if(myrand()%2 == 0) + if(myrand()%50 == 0) { core::map<v3s16, MapBlock*> modified_blocks; v3s16 tree_p = p; - MapEditEvent event; - event.type = MEET_OTHER; ManualMapVoxelManipulator vmanip(m_map); v3s16 tree_blockp = getNodeBlockPos(tree_p); vmanip.initialEmerge(tree_blockp - v3s16(1,1,1), tree_blockp + v3s16(1,1,1)); bool is_apple_tree = myrand()%4 == 0; mapgen::make_tree(vmanip, tree_p, is_apple_tree); + vmanip.blitBackAll(&modified_blocks); + + // update lighting + core::map<v3s16, MapBlock*> lighting_modified_blocks; + for(core::map<v3s16, MapBlock*>::Iterator + i = modified_blocks.getIterator(); + i.atEnd() == false; i++) + { + lighting_modified_blocks.insert(i.getNode()->getKey(), i.getNode()->getValue()); + } + m_map->updateLighting(lighting_modified_blocks, modified_blocks); + + // Send a MEET_OTHER event + MapEditEvent event; + event.type = MEET_OTHER; for(core::map<v3s16, MapBlock*>::Iterator i = modified_blocks.getIterator(); i.atEnd() == false; i++) |