]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Remove get_noiseparams function. read_noiseparams should be used from now on
authorkwolekr <kwolekr@minetest.net>
Wed, 10 Dec 2014 05:56:44 +0000 (00:56 -0500)
committerkwolekr <kwolekr@minetest.net>
Wed, 10 Dec 2014 05:56:44 +0000 (00:56 -0500)
src/mg_decoration.cpp
src/mg_decoration.h
src/mg_ore.cpp
src/mg_ore.h
src/script/common/c_content.cpp
src/script/common/c_content.h
src/script/lua_api/l_mapgen.cpp

index a8fd9eaadf0b87fe362d9bd588a42f263e0bc7c6..20b9fbda68510dbe03ff055c82466b0fc4871049 100644 (file)
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 const char *DecorationManager::ELEMENT_TITLE = "decoration";
 
-FlagDesc flagdesc_deco_schematic[] = {
+FlagDesc flagdesc_deco[] = {
        {"place_center_x", DECO_PLACE_CENTER_X},
        {"place_center_y", DECO_PLACE_CENTER_Y},
        {"place_center_z", DECO_PLACE_CENTER_Z},
@@ -61,15 +61,14 @@ size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 seed, v3s16 nmin, v3s16
 Decoration::Decoration()
 {
        mapseed    = 0;
-       np         = NULL;
        fill_ratio = 0;
        sidelen    = 1;
+       flags      = 0;
 }
 
 
 Decoration::~Decoration()
 {
-       delete np;
 }
 
 
@@ -104,8 +103,8 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
                );
 
                // Amount of decorations
-               float nval = np ?
-                       NoisePerlin2D(np, p2d_center.X, p2d_center.Y, mapseed) :
+               float nval = (flags & DECO_USE_NOISE) ?
+                       NoisePerlin2D(&np, p2d_center.X, p2d_center.Y, mapseed) :
                        fill_ratio;
                u32 deco_count = area * MYMAX(nval, 0.f);
 
index 3262924b02f1e2700096fcc99400bade177a9bf2..f360e3b76945cf84d69280296897f7d84d906d7f 100644 (file)
@@ -38,8 +38,9 @@ enum DecorationType {
 #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_schematic[];
+extern FlagDesc flagdesc_deco[];
 
 
 #if 0
@@ -61,11 +62,12 @@ class Decoration : public GenElement {
 public:
        INodeDefManager *ndef;
 
+       u32 flags;
        int mapseed;
        std::vector<content_t> c_place_on;
        s16 sidelen;
        float fill_ratio;
-       NoiseParams *np;
+       NoiseParams np;
 
        std::set<u8> biomes;
        //std::list<CutoffData> cutoffs;
@@ -98,7 +100,6 @@ class DecoSimple : public Decoration {
 
 class DecoSchematic : public Decoration {
 public:
-       u32 flags;
        Rotation rotation;
        Schematic *schematic;
        std::string filename;
index 1aac59ddb0efe71f9f869e7d43e5c5c685db2da2..d94b861c22779ecbe03e1dea5e3bfd37704a9dcb 100644 (file)
@@ -57,6 +57,13 @@ size_t OreManager::placeAllOres(Mapgen *mg, u32 seed, v3s16 nmin, v3s16 nmax)
 ///////////////////////////////////////////////////////////////////////////////
 
 
+Ore::Ore()
+{
+       flags = 0;
+       noise = NULL;
+}
+
+
 size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
 {
        int in_range = 0;
index f3a565050c748457bd8abb66cb6c0d66282ca50d..b6db860b9fa4537fba4c45d24e3d926a6d07e17f 100644 (file)
@@ -71,6 +71,8 @@ class Ore : public GenElement {
        NoiseParams np;     // noise for distribution of clusters (NULL for uniform scattering)
        Noise *noise;
 
+       Ore();
+
        size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
        virtual void generate(ManualMapVoxelManipulator *vm, int seed,
                                                u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
index 1c78f139ff7e517e48cd3d438536aaea4f23d4c6..cab346caebc66a3c639fd3a652ba2e3ab5056cf3 100644 (file)
@@ -975,18 +975,6 @@ void luaentity_get(lua_State *L, u16 id)
 }
 
 /******************************************************************************/
-NoiseParams *get_noiseparams(lua_State *L, int index)
-{
-       NoiseParams *np = new NoiseParams;
-
-       if (!read_noiseparams(L, index, np)) {
-               delete np;
-               np = NULL;
-       }
-
-       return np;
-}
-
 bool read_noiseparams(lua_State *L, int index, NoiseParams *np)
 {
        if (index < 0)
index 02e3e29fa89eb9a2ebb5308e6a19ffc2fa608881..834db319b3b6404cbc8d434bfb1baf36e9edf4a2 100644 (file)
@@ -147,8 +147,6 @@ bool               string_to_enum            (const EnumString *spec,
                                               int &result,
                                               const std::string &str);
 
-NoiseParams*       get_noiseparams           (lua_State *L, int index);
-
 bool               read_noiseparams          (lua_State *L, int index,
                                               NoiseParams *np);
 bool               get_schematic             (lua_State *L, int index,
index 3176b920cca47b4222d1332c1c1dcc5010d02948..03a2ee0d5f53fdaf64afb0661caa58a936b087e7 100644 (file)
@@ -394,9 +394,12 @@ int ModApiMapgen::l_register_decoration(lua_State *L)
        for (size_t i = 0; i != place_on_names.size(); i++)
                resolver->addNodeList(place_on_names[i], &deco->c_place_on);
 
+       getflagsfield(L, index, "flags", flagdesc_deco, &deco->flags, NULL);
+
        //// Get NoiseParams to define how decoration is placed
        lua_getfield(L, index, "noise_params");
-       deco->np = get_noiseparams(L, -1);
+       if (read_noiseparams(L, -1, &deco->np))
+               deco->flags |= DECO_USE_NOISE;
        lua_pop(L, 1);
 
        //// Get biomes associated with this decoration (if any)
@@ -482,9 +485,6 @@ bool ModApiMapgen::regDecoSchematic(lua_State *L, INodeDefManager *ndef,
 {
        int index = 1;
 
-       deco->flags = 0;
-       getflagsfield(L, index, "flags", flagdesc_deco_schematic, &deco->flags, NULL);
-
        deco->rotation = (Rotation)getenumfield(L, index, "rotation",
                es_Rotation, ROTATE_0);