Remove get_noiseparams function. read_noiseparams should be used from now on

master
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";
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);

View 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 @@ public:
class DecoSchematic : public Decoration {
public:
u32 flags;
Rotation rotation;
Schematic *schematic;
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)
{
int in_range = 0;

View File

@ -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;

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)
{
if (index < 0)

View 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,

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++)
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);