aboutsummaryrefslogtreecommitdiff
path: root/src/mg_ore.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2014-11-12 23:01:13 -0500
committerkwolekr <kwolekr@minetest.net>2014-11-12 23:02:41 -0500
commit7616537bc071bc93f8d36c84b94603528be1efb0 (patch)
tree487185069e4f39f1f828a831b1d1ba9c88ed4298 /src/mg_ore.cpp
parentf25cc0dbae0209f2647ac5eec9fe6ddb08174f55 (diff)
downloadminetest-7616537bc071bc93f8d36c84b94603528be1efb0.tar.gz
minetest-7616537bc071bc93f8d36c84b94603528be1efb0.tar.bz2
minetest-7616537bc071bc93f8d36c84b94603528be1efb0.zip
Add Generator Element Management framework
Add BiomeManager, OreManager, DecorationManager, and SchematicManager
Diffstat (limited to 'src/mg_ore.cpp')
-rw-r--r--src/mg_ore.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp
index c8d224dc6..9e2d456ee 100644
--- a/src/mg_ore.cpp
+++ b/src/mg_ore.cpp
@@ -19,10 +19,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mg_ore.h"
#include "mapgen.h"
+#include "noise.h"
#include "util/numeric.h"
#include "map.h"
#include "log.h"
+const char *OreManager::ELEMENT_TITLE = "ore";
FlagDesc flagdesc_ore[] = {
{"absheight", OREFLAG_ABSHEIGHT},
@@ -31,24 +33,36 @@ FlagDesc flagdesc_ore[] = {
{NULL, 0}
};
+
///////////////////////////////////////////////////////////////////////////////
-Ore *createOre(OreType type)
+size_t OreManager::placeAllOres(Mapgen *mg, u32 seed, v3s16 nmin, v3s16 nmax)
{
- switch (type) {
- case ORE_SCATTER:
- return new OreScatter;
- case ORE_SHEET:
- return new OreSheet;
- //case ORE_CLAYLIKE: //TODO: implement this!
- // return new OreClaylike;
- default:
- return NULL;
+ size_t nplaced = 0;
+
+ for (size_t i = 0; i != m_elements.size(); i++) {
+ Ore *ore = (Ore *)m_elements[i];
+ if (!ore)
+ continue;
+
+ nplaced += ore->placeOre(mg, seed, nmin, nmax);
+ seed++;
}
+
+ return nplaced;
}
+///////////////////////////////////////////////////////////////////////////////
+
+Ore::Ore()
+{
+ c_ore = CONTENT_IGNORE;
+ np = NULL;
+ noise = NULL;
+}
+
Ore::~Ore()
{
delete np;
@@ -56,7 +70,13 @@ Ore::~Ore()
}
-void Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
+std::string Ore::getName()
+{
+ return name;
+}
+
+
+size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
{
int in_range = 0;
@@ -64,7 +84,7 @@ void Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
if (flags & OREFLAG_ABSHEIGHT)
in_range |= (nmin.Y >= -height_max && nmax.Y <= -height_min) << 1;
if (!in_range)
- return;
+ return 0;
int ymin, ymax;
if (in_range & ORE_RANGE_MIRROR) {
@@ -75,11 +95,13 @@ void Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
ymax = MYMIN(nmax.Y, height_max);
}
if (clust_size >= ymax - ymin + 1)
- return;
+ return 0;
nmin.Y = ymin;
nmax.Y = ymax;
generate(mg->vm, mg->seed, blockseed, nmin, nmax);
+
+ return 0;
}