aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapgen')
-rw-r--r--src/mapgen/mg_ore.cpp19
-rw-r--r--src/mapgen/mg_ore.h2
2 files changed, 16 insertions, 5 deletions
diff --git a/src/mapgen/mg_ore.cpp b/src/mapgen/mg_ore.cpp
index 979135ed4..297472420 100644
--- a/src/mapgen/mg_ore.cpp
+++ b/src/mapgen/mg_ore.cpp
@@ -434,13 +434,20 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
MapNode n_ore(c_ore, 0, ore_param2);
if (flags & OREFLAG_USE_NOISE) {
- if (!(noise && noise_stratum_thickness)) {
+ if (!noise) {
int sx = nmax.X - nmin.X + 1;
int sz = nmax.Z - nmin.Z + 1;
noise = new Noise(&np, 0, sx, sz);
- noise_stratum_thickness = new Noise(&np_stratum_thickness, 0, sx, sz);
}
noise->perlinMap2D(nmin.X, nmin.Z);
+ }
+
+ if (flags & OREFLAG_USE_NOISE2) {
+ if (!noise_stratum_thickness) {
+ int sx = nmax.X - nmin.X + 1;
+ int sz = nmax.Z - nmin.Z + 1;
+ noise_stratum_thickness = new Noise(&np_stratum_thickness, 0, sx, sz);
+ }
noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
}
@@ -458,11 +465,13 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
int y1;
if (flags & OREFLAG_USE_NOISE) {
+ float nhalfthick = ((flags & OREFLAG_USE_NOISE2) ?
+ noise_stratum_thickness->result[index] : (float)stratum_thickness) /
+ 2.0f;
float nmid = noise->result[index];
- float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
- y0 = MYMAX(nmin.Y, nmid - nhalfthick);
+ y0 = MYMAX(nmin.Y, ceil(nmid - nhalfthick));
y1 = MYMIN(nmax.Y, nmid + nhalfthick);
- } else {
+ } else { // Simple horizontal stratum
y0 = nmin.Y;
y1 = nmax.Y;
}
diff --git a/src/mapgen/mg_ore.h b/src/mapgen/mg_ore.h
index e715f348b..2bbc8c578 100644
--- a/src/mapgen/mg_ore.h
+++ b/src/mapgen/mg_ore.h
@@ -35,6 +35,7 @@ class MMVManip;
#define OREFLAG_PUFF_CLIFFS 0x02
#define OREFLAG_PUFF_ADDITIVE 0x04
#define OREFLAG_USE_NOISE 0x08
+#define OREFLAG_USE_NOISE2 0x10
enum OreType {
ORE_SCATTER,
@@ -139,6 +140,7 @@ public:
NoiseParams np_stratum_thickness;
Noise *noise_stratum_thickness = nullptr;
+ u16 stratum_thickness;
OreStratum() = default;
virtual ~OreStratum();