summaryrefslogtreecommitdiff
path: root/src/content_abm.cpp
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-11-02 10:48:13 +0100
committerNovatux <nathanael.courant@laposte.net>2013-11-02 10:50:11 +0100
commit69a59f1e419d8204cc90cfaa25ad690c9b3d9e16 (patch)
treea876a5563e5cd582946ccd4bb7ef6f3986fe8225 /src/content_abm.cpp
parentb1c82f332caa778d698d665f9269ba1304d5d5a4 (diff)
downloadminetest-69a59f1e419d8204cc90cfaa25ad690c9b3d9e16.tar.gz
minetest-69a59f1e419d8204cc90cfaa25ad690c9b3d9e16.tar.bz2
minetest-69a59f1e419d8204cc90cfaa25ad690c9b3d9e16.zip
Move the sapling growing and grass adding/removing ABMs to Lua
Diffstat (limited to 'src/content_abm.cpp')
-rw-r--r--src/content_abm.cpp139
1 files changed, 0 insertions, 139 deletions
diff --git a/src/content_abm.cpp b/src/content_abm.cpp
index ada20a27c..9289035b8 100644
--- a/src/content_abm.cpp
+++ b/src/content_abm.cpp
@@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_sao.h"
#include "settings.h"
#include "mapblock.h" // For getNodeBlockPos
-#include "treegen.h" // For treegen::make_tree
#include "main.h" // for g_settings
#include "map.h"
#include "scripting_game.h"
@@ -33,141 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
-class GrowGrassABM : public ActiveBlockModifier
-{
-private:
-public:
- virtual std::set<std::string> getTriggerContents()
- {
- std::set<std::string> s;
- s.insert("mapgen_dirt");
- return s;
- }
- virtual float getTriggerInterval()
- { return 2.0; }
- virtual u32 getTriggerChance()
- { return 200; }
- virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n)
- {
- INodeDefManager *ndef = env->getGameDef()->ndef();
- ServerMap *map = &env->getServerMap();
-
- MapNode n_top = map->getNodeNoEx(p+v3s16(0,1,0));
- content_t c_snow = ndef->getId("snow");
- if(ndef->get(n_top).light_propagates &&
- !ndef->get(n_top).isLiquid() &&
- n_top.getLightBlend(env->getDayNightRatio(), ndef) >= 13)
- {
- if(c_snow != CONTENT_IGNORE && n_top.getContent() == c_snow)
- n.setContent(ndef->getId("dirt_with_snow"));
- else
- n.setContent(ndef->getId("mapgen_dirt_with_grass"));
- map->addNodeWithEvent(p, n);
- }
- }
-};
-
-class RemoveGrassABM : public ActiveBlockModifier
-{
-private:
-public:
- virtual std::set<std::string> getTriggerContents()
- {
- std::set<std::string> s;
- s.insert("mapgen_dirt_with_grass");
- return s;
- }
- virtual float getTriggerInterval()
- { return 2.0; }
- virtual u32 getTriggerChance()
- { return 20; }
- virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n)
- {
- INodeDefManager *ndef = env->getGameDef()->ndef();
- ServerMap *map = &env->getServerMap();
-
- MapNode n_top = map->getNodeNoEx(p+v3s16(0,1,0));
- if((!ndef->get(n_top).light_propagates &&
- n_top.getContent() != CONTENT_IGNORE) ||
- ndef->get(n_top).isLiquid())
- {
- n.setContent(ndef->getId("mapgen_dirt"));
- map->addNodeWithEvent(p, n);
- }
- }
-};
-
-class MakeTreesFromSaplingsABM : public ActiveBlockModifier
-{
-private:
- content_t c_junglesapling;
-
-public:
- MakeTreesFromSaplingsABM(ServerEnvironment *env, INodeDefManager *nodemgr) {
- c_junglesapling = nodemgr->getId("junglesapling");
- }
-
- virtual std::set<std::string> getTriggerContents()
- {
- std::set<std::string> s;
- s.insert("sapling");
- s.insert("junglesapling");
- return s;
- }
- virtual float getTriggerInterval()
- { return 10.0; }
- virtual u32 getTriggerChance()
- { return 50; }
- virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n,
- u32 active_object_count, u32 active_object_count_wider)
- {
- INodeDefManager *ndef = env->getGameDef()->ndef();
- ServerMap *map = &env->getServerMap();
-
- MapNode n_below = map->getNodeNoEx(p - v3s16(0, 1, 0));
- if (!((ItemGroupList) ndef->get(n_below).groups)["soil"])
- return;
-
- bool is_jungle_tree = n.getContent() == c_junglesapling;
-
- actionstream <<"A " << (is_jungle_tree ? "jungle " : "")
- << "sapling grows into a tree at "
- << PP(p) << std::endl;
-
- std::map<v3s16, MapBlock*> 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));
-
- 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
- std::map<v3s16, MapBlock*> 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;
-// event.modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
- for(std::map<v3s16, MapBlock*>::iterator
- i = modified_blocks.begin();
- i != modified_blocks.end(); ++i)
- {
- event.modified_blocks.insert(i->first);
- }
- map->dispatchEvent(&event);
- }
-};
-
class LiquidFlowABM : public ActiveBlockModifier {
private:
std::set<std::string> contents;
@@ -370,9 +234,6 @@ class LiquidMeltAround : public LiquidMeltHot {
*/
void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef) {
- env->addActiveBlockModifier(new GrowGrassABM());
- env->addActiveBlockModifier(new RemoveGrassABM());
- env->addActiveBlockModifier(new MakeTreesFromSaplingsABM(env, nodedef));
if (g_settings->getBool("liquid_finite")) {
env->addActiveBlockModifier(new LiquidFlowABM(env, nodedef));
env->addActiveBlockModifier(new LiquidDropABM(env, nodedef));