1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-23 16:08:51 -05:00

Remove get_noiseparams function. read_noiseparams should be used from now on

This commit is contained in:
kwolekr 2014-12-10 00:56:44 -05:00
parent fb2bc956b1
commit cfba55ba0a
7 changed files with 21 additions and 26 deletions

View File

@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
const char *DecorationManager::ELEMENT_TITLE = "decoration"; const char *DecorationManager::ELEMENT_TITLE = "decoration";
FlagDesc flagdesc_deco_schematic[] = { FlagDesc flagdesc_deco[] = {
{"place_center_x", DECO_PLACE_CENTER_X}, {"place_center_x", DECO_PLACE_CENTER_X},
{"place_center_y", DECO_PLACE_CENTER_Y}, {"place_center_y", DECO_PLACE_CENTER_Y},
{"place_center_z", DECO_PLACE_CENTER_Z}, {"place_center_z", DECO_PLACE_CENTER_Z},
@ -61,15 +61,14 @@ size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 seed, v3s16 nmin, v3s16
Decoration::Decoration() Decoration::Decoration()
{ {
mapseed = 0; mapseed = 0;
np = NULL;
fill_ratio = 0; fill_ratio = 0;
sidelen = 1; sidelen = 1;
flags = 0;
} }
Decoration::~Decoration() Decoration::~Decoration()
{ {
delete np;
} }
@ -104,8 +103,8 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
); );
// Amount of decorations // Amount of decorations
float nval = np ? float nval = (flags & DECO_USE_NOISE) ?
NoisePerlin2D(np, p2d_center.X, p2d_center.Y, mapseed) : NoisePerlin2D(&np, p2d_center.X, p2d_center.Y, mapseed) :
fill_ratio; fill_ratio;
u32 deco_count = area * MYMAX(nval, 0.f); u32 deco_count = area * MYMAX(nval, 0.f);

View File

@ -38,8 +38,9 @@ enum DecorationType {
#define DECO_PLACE_CENTER_X 0x01 #define DECO_PLACE_CENTER_X 0x01
#define DECO_PLACE_CENTER_Y 0x02 #define DECO_PLACE_CENTER_Y 0x02
#define DECO_PLACE_CENTER_Z 0x04 #define DECO_PLACE_CENTER_Z 0x04
#define DECO_USE_NOISE 0x08
extern FlagDesc flagdesc_deco_schematic[]; extern FlagDesc flagdesc_deco[];
#if 0 #if 0
@ -61,11 +62,12 @@ class Decoration : public GenElement {
public: public:
INodeDefManager *ndef; INodeDefManager *ndef;
u32 flags;
int mapseed; int mapseed;
std::vector<content_t> c_place_on; std::vector<content_t> c_place_on;
s16 sidelen; s16 sidelen;
float fill_ratio; float fill_ratio;
NoiseParams *np; NoiseParams np;
std::set<u8> biomes; std::set<u8> biomes;
//std::list<CutoffData> cutoffs; //std::list<CutoffData> cutoffs;
@ -98,7 +100,6 @@ public:
class DecoSchematic : public Decoration { class DecoSchematic : public Decoration {
public: public:
u32 flags;
Rotation rotation; Rotation rotation;
Schematic *schematic; Schematic *schematic;
std::string filename; std::string filename;

View 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) size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
{ {
int in_range = 0; int in_range = 0;

View File

@ -71,6 +71,8 @@ public:
NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering) NoiseParams np; // noise for distribution of clusters (NULL for uniform scattering)
Noise *noise; Noise *noise;
Ore();
size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
virtual void generate(ManualMapVoxelManipulator *vm, int seed, virtual void generate(ManualMapVoxelManipulator *vm, int seed,
u32 blockseed, v3s16 nmin, v3s16 nmax) = 0; u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;

View 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) bool read_noiseparams(lua_State *L, int index, NoiseParams *np)
{ {
if (index < 0) if (index < 0)

View File

@ -147,8 +147,6 @@ bool string_to_enum (const EnumString *spec,
int &result, int &result,
const std::string &str); const std::string &str);
NoiseParams* get_noiseparams (lua_State *L, int index);
bool read_noiseparams (lua_State *L, int index, bool read_noiseparams (lua_State *L, int index,
NoiseParams *np); NoiseParams *np);
bool get_schematic (lua_State *L, int index, bool get_schematic (lua_State *L, int index,

View File

@ -394,9 +394,12 @@ int ModApiMapgen::l_register_decoration(lua_State *L)
for (size_t i = 0; i != place_on_names.size(); i++) for (size_t i = 0; i != place_on_names.size(); i++)
resolver->addNodeList(place_on_names[i], &deco->c_place_on); 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 //// Get NoiseParams to define how decoration is placed
lua_getfield(L, index, "noise_params"); 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); lua_pop(L, 1);
//// Get biomes associated with this decoration (if any) //// Get biomes associated with this decoration (if any)
@ -482,9 +485,6 @@ bool ModApiMapgen::regDecoSchematic(lua_State *L, INodeDefManager *ndef,
{ {
int index = 1; int index = 1;
deco->flags = 0;
getflagsfield(L, index, "flags", flagdesc_deco_schematic, &deco->flags, NULL);
deco->rotation = (Rotation)getenumfield(L, index, "rotation", deco->rotation = (Rotation)getenumfield(L, index, "rotation",
es_Rotation, ROTATE_0); es_Rotation, ROTATE_0);