diff options
author | kwolekr <kwolekr@minetest.net> | 2014-12-10 00:56:44 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-12-10 00:56:44 -0500 |
commit | cfba55ba0a79eb1a4e9250d6dcc7ed4dd2bd519e (patch) | |
tree | 38fc831ee02f25810b1134a8fbdb0d871ef0a1d4 | |
parent | fb2bc956b18bd70a47bff00d5726d4754867856a (diff) | |
download | minetest-cfba55ba0a79eb1a4e9250d6dcc7ed4dd2bd519e.tar.gz minetest-cfba55ba0a79eb1a4e9250d6dcc7ed4dd2bd519e.tar.bz2 minetest-cfba55ba0a79eb1a4e9250d6dcc7ed4dd2bd519e.zip |
Remove get_noiseparams function. read_noiseparams should be used from now on
-rw-r--r-- | src/mg_decoration.cpp | 9 | ||||
-rw-r--r-- | src/mg_decoration.h | 7 | ||||
-rw-r--r-- | src/mg_ore.cpp | 7 | ||||
-rw-r--r-- | src/mg_ore.h | 2 | ||||
-rw-r--r-- | src/script/common/c_content.cpp | 12 | ||||
-rw-r--r-- | src/script/common/c_content.h | 2 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 8 |
7 files changed, 21 insertions, 26 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp index a8fd9eaad..20b9fbda6 100644 --- a/src/mg_decoration.cpp +++ b/src/mg_decoration.cpp @@ -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); diff --git a/src/mg_decoration.h b/src/mg_decoration.h index 3262924b0..f360e3b76 100644 --- a/src/mg_decoration.h +++ b/src/mg_decoration.h @@ -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 @@ public: class DecoSchematic : public Decoration { public: - u32 flags; Rotation rotation; Schematic *schematic; std::string filename; diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp index 1aac59ddb..d94b861c2 100644 --- a/src/mg_ore.cpp +++ b/src/mg_ore.cpp @@ -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; diff --git a/src/mg_ore.h b/src/mg_ore.h index f3a565050..b6db860b9 100644 --- a/src/mg_ore.h +++ b/src/mg_ore.h @@ -71,6 +71,8 @@ public: 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; diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 1c78f139f..cab346cae 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -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) diff --git a/src/script/common/c_content.h b/src/script/common/c_content.h index 02e3e29fa..834db319b 100644 --- a/src/script/common/c_content.h +++ b/src/script/common/c_content.h @@ -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, diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 3176b920c..03a2ee0d5 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -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); |