X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fmg_decoration.h;h=986328ec3bc86be4a4ba741823d96bca45920057;hb=57e5aa662851485902575c3c747437e365bf72c8;hp=20a22d449e058ad08193f159f1538b419dbf5e13;hpb=89217faec5723fa1dae3217994a553d395426a35;p=minetest.git diff --git a/src/mg_decoration.h b/src/mg_decoration.h index 20a22d449..986328ec3 100644 --- a/src/mg_decoration.h +++ b/src/mg_decoration.h @@ -20,13 +20,14 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef MG_DECORATION_HEADER #define MG_DECORATION_HEADER -#include -#include "mapgen.h" +#include "util/cpp11_container.h" +#include "objdef.h" +#include "noise.h" +#include "nodedef.h" -struct NoiseParams; class Mapgen; class MMVManip; -class PseudoRandom; +class PcgRandom; class Schematic; enum DecorationType { @@ -40,6 +41,7 @@ enum DecorationType { #define DECO_PLACE_CENTER_Z 0x04 #define DECO_USE_NOISE 0x08 #define DECO_FORCE_PLACEMENT 0x10 +#define DECO_LIQUID_SURFACE 0x20 extern FlagDesc flagdesc_deco[]; @@ -59,9 +61,19 @@ struct CutoffData { }; #endif -class Decoration : public GenElement, public NodeResolver { +class Decoration : public ObjDef, public NodeResolver { public: - INodeDefManager *ndef; + Decoration(); + virtual ~Decoration(); + + virtual void resolveNodeNames(); + + bool canPlaceDecoration(MMVManip *vm, v3s16 p); + size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); + //size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); + + virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0; + virtual int getHeight() = 0; u32 flags; int mapseed; @@ -71,46 +83,35 @@ class Decoration : public GenElement, public NodeResolver { s16 y_max; float fill_ratio; NoiseParams np; + std::vector c_spawnby; + s16 nspawnby; - std::set biomes; + UNORDERED_SET biomes; //std::list cutoffs; - //JMutex cutoff_mutex; - - Decoration(); - virtual ~Decoration(); - - 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 size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p) = 0; - virtual int getHeight() = 0; + //Mutex cutoff_mutex; }; class DecoSimple : public Decoration { public: + virtual void resolveNodeNames(); + virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p); + virtual int getHeight(); + std::vector c_decos; - std::vector c_spawnby; s16 deco_height; s16 deco_height_max; - s16 nspawnby; - - virtual void resolveNodeNames(NodeResolveInfo *nri); - - bool canPlaceDecoration(MMVManip *vm, v3s16 p); - virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p); - virtual int getHeight(); + u8 deco_param2; }; class DecoSchematic : public Decoration { public: - Rotation rotation; - Schematic *schematic; - std::string filename; + DecoSchematic(); - virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p); + virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p); virtual int getHeight(); + + Rotation rotation; + Schematic *schematic; }; @@ -121,15 +122,17 @@ class DecoLSystem : public Decoration { }; */ -class DecorationManager : public GenElementManager { +class DecorationManager : public ObjDefManager { public: - static const char *ELEMENT_TITLE; - static const size_t ELEMENT_LIMIT = 0x10000; - DecorationManager(IGameDef *gamedef); - ~DecorationManager() {} + virtual ~DecorationManager() {} - Decoration *create(int type) + const char *getObjectTitle() const + { + return "decoration"; + } + + static Decoration *create(DecorationType type) { switch (type) { case DECO_SIMPLE: @@ -143,8 +146,6 @@ class DecorationManager : public GenElementManager { } } - void clear(); - size_t placeAllDecos(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); };