From 6a1670dbc31cc0e44178bbd9ad34ff0d5981a060 Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Thu, 20 Dec 2012 21:19:49 +0400 Subject: Migrate to STL containers/algorithms. --- src/content_abm.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/content_abm.cpp') diff --git a/src/content_abm.cpp b/src/content_abm.cpp index 03fc82ed4..a88450095 100644 --- a/src/content_abm.cpp +++ b/src/content_abm.cpp @@ -114,7 +114,7 @@ public: actionstream<<"A sapling grows into a tree at " < modified_blocks; + std::map modified_blocks; v3s16 tree_p = p; ManualMapVoxelManipulator vmanip(map); v3s16 tree_blockp = getNodeBlockPos(tree_p); @@ -124,24 +124,19 @@ public: vmanip.blitBackAll(&modified_blocks); // update lighting - core::map lighting_modified_blocks; - for(core::map::Iterator - i = modified_blocks.getIterator(); - i.atEnd() == false; i++) - { - lighting_modified_blocks.insert(i.getNode()->getKey(), i.getNode()->getValue()); - } + std::map lighting_modified_blocks; + lighting_modified_blocks.insert(modified_blocks.begin(), modified_blocks.end()); map->updateLighting(lighting_modified_blocks, modified_blocks); // Send a MEET_OTHER event MapEditEvent event; event.type = MEET_OTHER; - for(core::map::Iterator - i = modified_blocks.getIterator(); - i.atEnd() == false; i++) +// event.modified_blocks.insert(modified_blocks.begin(), modified_blocks.end()); + for(std::map::iterator + i = modified_blocks.begin(); + i != modified_blocks.end(); ++i) { - v3s16 p = i.getNode()->getKey(); - event.modified_blocks.insert(p, true); + event.modified_blocks.insert(i->first); } map->dispatchEvent(&event); } -- cgit v1.2.3 From 6823ce99a7deabe410dd8b143b688cd364490cec Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sat, 16 Mar 2013 17:06:11 -0400 Subject: Re-add jungles, apple trees --- src/content_abm.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/content_abm.cpp') diff --git a/src/content_abm.cpp b/src/content_abm.cpp index a88450095..e50edddd7 100644 --- a/src/content_abm.cpp +++ b/src/content_abm.cpp @@ -99,6 +99,7 @@ public: { std::set s; s.insert("sapling"); + s.insert("junglesapling"); return s; } virtual float getTriggerInterval() @@ -111,16 +112,25 @@ public: INodeDefManager *ndef = env->getGameDef()->ndef(); ServerMap *map = &env->getServerMap(); - actionstream<<"A sapling grows into a tree at " - <getId("junglesapling"); + + actionstream <<"A " << (is_jungle_tree ? "jungle " : "") + << "sapling grows into a tree at " + << PP(p) << std::endl; std::map modified_blocks; v3s16 tree_p = p; ManualMapVoxelManipulator vmanip(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; - treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand()); + + if (is_jungle_tree) { + treegen::make_jungletree(vmanip, tree_p, ndef, myrand()); + } else { + bool is_apple_tree = myrand() % 4 == 0; + treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand()); + } + vmanip.blitBackAll(&modified_blocks); // update lighting -- cgit v1.2.3 From e3badd7062d4bee62335cf100f3f91ef4c370aae Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sat, 16 Mar 2013 19:37:27 -0400 Subject: Make saplings only grow on dirt or grass, make jungle tree trunks only replace air --- src/content_abm.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/content_abm.cpp') diff --git a/src/content_abm.cpp b/src/content_abm.cpp index e50edddd7..ccd9ca19c 100644 --- a/src/content_abm.cpp +++ b/src/content_abm.cpp @@ -94,7 +94,17 @@ public: class MakeTreesFromSaplingsABM : public ActiveBlockModifier { private: + content_t c_junglesapling; + content_t c_dirt; + content_t c_dirt_with_grass; + public: + MakeTreesFromSaplingsABM(ServerEnvironment *env, INodeDefManager *nodemgr) { + c_junglesapling = nodemgr->getId("junglesapling"); + c_dirt = nodemgr->getId("mapgen_dirt"); + c_dirt_with_grass = nodemgr->getId("mapgen_dirt_with_grass"); + } + virtual std::set getTriggerContents() { std::set s; @@ -112,7 +122,12 @@ public: INodeDefManager *ndef = env->getGameDef()->ndef(); ServerMap *map = &env->getServerMap(); - bool is_jungle_tree = n.getContent() == ndef->getId("junglesapling"); + MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0)); + if (n_below.getContent() != c_dirt && + n_below.getContent() != c_dirt_with_grass) + return; + + bool is_jungle_tree = n.getContent() == c_junglesapling; actionstream <<"A " << (is_jungle_tree ? "jungle " : "") << "sapling grows into a tree at " @@ -187,7 +202,7 @@ void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef) { env->addActiveBlockModifier(new GrowGrassABM()); env->addActiveBlockModifier(new RemoveGrassABM()); - env->addActiveBlockModifier(new MakeTreesFromSaplingsABM()); + env->addActiveBlockModifier(new MakeTreesFromSaplingsABM(env, nodedef)); if (g_settings->getBool("liquid_finite")) env->addActiveBlockModifier(new LiquidFlowABM(env, nodedef)); } -- cgit v1.2.3