]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/content_abm.cpp
Add one more curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
[dragonfireclient.git] / src / content_abm.cpp
index 0d0f0dedb713e89f5de43812a2c3ce068a2ed8f9..03fc82ed4d8396f4710b84c1c6e489e9f90eb65f 100644 (file)
@@ -1,6 +1,6 @@
 /*
-Minetest-c55
-Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
+Minetest
+Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "settings.h"
 #include "mapblock.h" // For getNodeBlockPos
 #include "treegen.h" // For treegen::make_tree
+#include "main.h" // for g_settings
 #include "map.h"
 
 #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
@@ -37,7 +38,7 @@ class GrowGrassABM : public ActiveBlockModifier
        virtual std::set<std::string> getTriggerContents()
        {
                std::set<std::string> s;
-               s.insert("dirt");
+               s.insert("mapgen_dirt");
                return s;
        }
        virtual float getTriggerInterval()
@@ -54,7 +55,7 @@ class GrowGrassABM : public ActiveBlockModifier
                                !ndef->get(n_top).isLiquid() &&
                                n_top.getLightBlend(env->getDayNightRatio(), ndef) >= 13)
                {
-                       n.setContent(ndef->getId("dirt_with_grass"));
+                       n.setContent(ndef->getId("mapgen_dirt_with_grass"));
                        map->addNodeWithEvent(p, n);
                }
        }
@@ -67,7 +68,7 @@ class RemoveGrassABM : public ActiveBlockModifier
        virtual std::set<std::string> getTriggerContents()
        {
                std::set<std::string> s;
-               s.insert("dirt_with_grass");
+               s.insert("mapgen_dirt_with_grass");
                return s;
        }
        virtual float getTriggerInterval()
@@ -80,10 +81,11 @@ class RemoveGrassABM : public ActiveBlockModifier
                ServerMap *map = &env->getServerMap();
                
                MapNode n_top = map->getNodeNoEx(p+v3s16(0,1,0));
-               if(!ndef->get(n_top).light_propagates ||
+               if((!ndef->get(n_top).light_propagates &&
+                               n_top.getContent() != CONTENT_IGNORE) ||
                                ndef->get(n_top).isLiquid())
                {
-                       n.setContent(ndef->getId("dirt"));
+                       n.setContent(ndef->getId("mapgen_dirt"));
                        map->addNodeWithEvent(p, n);
                }
        }
@@ -118,7 +120,7 @@ class MakeTreesFromSaplingsABM : public ActiveBlockModifier
                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);
+               treegen::make_tree(vmanip, tree_p, is_apple_tree, ndef, myrand());
                vmanip.blitBackAll(&modified_blocks);
 
                // update lighting
@@ -145,11 +147,42 @@ class MakeTreesFromSaplingsABM : public ActiveBlockModifier
        }
 };
 
+class LiquidFlowABM : public ActiveBlockModifier
+{
+private:
+       std::set<std::string> contents;
+
+public:
+       LiquidFlowABM(ServerEnvironment *env, INodeDefManager *nodemgr) 
+       {
+               std::set<content_t> liquids;
+               nodemgr->getIds("group:liquid", liquids);
+               for(std::set<content_t>::const_iterator k = liquids.begin(); k != liquids.end(); k++)
+                       contents.insert(nodemgr->get(*k).liquid_alternative_flowing);
+               
+       }
+       virtual std::set<std::string> getTriggerContents()
+       {
+               return contents;
+       }
+       virtual float getTriggerInterval()
+       { return 10.0; }
+       virtual u32 getTriggerChance()
+       { return 10; }
+       virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n)
+       {
+               ServerMap *map = &env->getServerMap();
+               if (map->transforming_liquid_size() < 500)
+                       map->transforming_liquid_add(p);
+               //if ((*map).m_transforming_liquid.size() < 500) (*map).m_transforming_liquid.push_back(p);
+       }
+};
+
 void add_legacy_abms(ServerEnvironment *env, INodeDefManager *nodedef)
 {
        env->addActiveBlockModifier(new GrowGrassABM());
        env->addActiveBlockModifier(new RemoveGrassABM());
        env->addActiveBlockModifier(new MakeTreesFromSaplingsABM());
+       if (g_settings->getBool("liquid_finite"))
+               env->addActiveBlockModifier(new LiquidFlowABM(env, nodedef));
 }
-
-