Use std::queue for HTTPFetchRequest and std::vector for log_output instead of std...
[oweals/minetest.git] / src / mg_decoration.h
index 78ff9dc2e5c3bc2e9be5c20676724cb0c419ec20..ab4a9377b49361999f6dc9d77e8c4cea44f03e7b 100644 (file)
@@ -21,12 +21,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #define MG_DECORATION_HEADER
 
 #include <set>
-#include "mapnode.h"
+#include "mapgen.h"
 
-class NoiseParams;
+struct NoiseParams;
 class Mapgen;
-class ManualMapVoxelManipulator;
+class MMVManip;
 class PseudoRandom;
+class Schematic;
 
 enum DecorationType {
        DECO_SIMPLE,
@@ -34,6 +35,14 @@ enum DecorationType {
        DECO_LSYSTEM
 };
 
+#define DECO_PLACE_CENTER_X 0x01
+#define DECO_PLACE_CENTER_Y 0x02
+#define DECO_PLACE_CENTER_Z 0x04
+#define DECO_USE_NOISE      0x08
+
+extern FlagDesc flagdesc_deco[];
+
+
 #if 0
 struct CutoffData {
        VoxelArea a;
@@ -49,15 +58,18 @@ struct CutoffData {
 };
 #endif
 
-class Decoration {
+class Decoration : public GenElement, public NodeResolver {
 public:
        INodeDefManager *ndef;
 
+       u32 flags;
        int mapseed;
        std::vector<content_t> c_place_on;
        s16 sidelen;
+       s16 y_min;
+       s16 y_max;
        float fill_ratio;
-       NoiseParams *np;
+       NoiseParams np;
 
        std::set<u8> biomes;
        //std::list<CutoffData> cutoffs;
@@ -66,12 +78,13 @@ public:
        Decoration();
        virtual ~Decoration();
 
-       void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
-       void placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+       virtual void resolveNodeNames(NodeResolveInfo *nri);
+
+       size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+       //size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
 
-       virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
+       virtual size_t generate(MMVManip *vm, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
        virtual int getHeight() = 0;
-       virtual std::string getName() = 0;
 };
 
 class DecoSimple : public Decoration {
@@ -82,14 +95,24 @@ public:
        s16 deco_height_max;
        s16 nspawnby;
 
-       ~DecoSimple() {}
+       virtual void resolveNodeNames(NodeResolveInfo *nri);
 
-       bool canPlaceDecoration(ManualMapVoxelManipulator *vm, v3s16 p);
-       virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
+       bool canPlaceDecoration(MMVManip *vm, v3s16 p);
+       virtual size_t generate(MMVManip *vm, PseudoRandom *pr, s16 max_y, v3s16 p);
        virtual int getHeight();
-       virtual std::string getName();
 };
 
+class DecoSchematic : public Decoration {
+public:
+       Rotation rotation;
+       Schematic *schematic;
+       std::string filename;
+
+       virtual size_t generate(MMVManip *vm, PseudoRandom *pr, s16 max_y, v3s16 p);
+       virtual int getHeight();
+};
+
+
 /*
 class DecoLSystem : public Decoration {
 public:
@@ -97,6 +120,31 @@ public:
 };
 */
 
-Decoration *createDecoration(DecorationType type);
+class DecorationManager : public GenElementManager {
+public:
+       static const char *ELEMENT_TITLE;
+       static const size_t ELEMENT_LIMIT = 0x10000;
+
+       DecorationManager(IGameDef *gamedef);
+       ~DecorationManager() {}
+
+       Decoration *create(int type)
+       {
+               switch (type) {
+               case DECO_SIMPLE:
+                       return new DecoSimple;
+               case DECO_SCHEMATIC:
+                       return new DecoSchematic;
+               //case DECO_LSYSTEM:
+               //      return new DecoLSystem;
+               default:
+                       return NULL;
+               }
+       }
+
+       void clear();
+
+       size_t placeAllDecos(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
+};
 
 #endif