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},
Decoration::Decoration()
{
mapseed = 0;
- np = NULL;
fill_ratio = 0;
sidelen = 1;
+ flags = 0;
}
Decoration::~Decoration()
{
- delete np;
}
);
// 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);
#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
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;
class DecoSchematic : public Decoration {
public:
- u32 flags;
Rotation rotation;
Schematic *schematic;
std::string filename;
///////////////////////////////////////////////////////////////////////////////
+Ore::Ore()
+{
+ flags = 0;
+ noise = NULL;
+}
+
+
size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
{
int in_range = 0;
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;
}
/******************************************************************************/
-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)
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,
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)
{
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);