aboutsummaryrefslogtreecommitdiff
path: root/src/environment.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-09-26 22:41:06 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-09-26 22:41:06 +0300
commita7833cca22bbb923efbc01fd0f820318a613eca6 (patch)
treeb8da72d3e36b70f1cd018615ed38de5d009cfe57 /src/environment.cpp
parent08ac3454ccb473156d39ebf543d617c1541588ca (diff)
parentbc01ae4cbd6e9ba2bcc0b75bab8ba5d99fcc4e34 (diff)
downloadhax-minetest-server-a7833cca22bbb923efbc01fd0f820318a613eca6.tar.gz
hax-minetest-server-a7833cca22bbb923efbc01fd0f820318a613eca6.zip
Merge remote-tracking branch 'marktraceur/master'
Diffstat (limited to 'src/environment.cpp')
-rw-r--r--src/environment.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index ff570554d..92263c675 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock.h"
#include "serverobject.h"
#include "content_sao.h"
+#include "mapgen.h"
Environment::Environment():
m_time_of_day(9000)
@@ -922,7 +923,47 @@ void ServerEnvironment::step(float dtime)
addActiveObject(obj);
}
}
- }
+ }
+ /*
+ Make trees from saplings!
+ */
+ if(n.getContent() == CONTENT_SAPLING)
+ {
+ if(myrand()%50 == 0)
+ {
+ core::map<v3s16, MapBlock*> modified_blocks;
+ v3s16 tree_p = p;
+ 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++)
+ {
+ v3s16 p = i.getNode()->getKey();
+ event.modified_blocks.insert(p, true);
+ }
+ m_map->dispatchEvent(&event);
+ }
+ }
+
}
}
}