aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mg_ore.cpp32
-rw-r--r--src/mg_ore.h2
-rw-r--r--src/script/lua_api/l_mapgen.cpp4
3 files changed, 25 insertions, 13 deletions
diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp
index 4f4c9c711..979135ed4 100644
--- a/src/mg_ore.cpp
+++ b/src/mg_ore.cpp
@@ -433,14 +433,16 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
PcgRandom pr(blockseed + 4234);
MapNode n_ore(c_ore, 0, ore_param2);
- 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);
+ if (flags & OREFLAG_USE_NOISE) {
+ if (!(noise && noise_stratum_thickness)) {
+ 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);
+ noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
}
- noise->perlinMap2D(nmin.X, nmin.Z);
- noise_stratum_thickness->perlinMap2D(nmin.X, nmin.Z);
size_t index = 0;
@@ -452,10 +454,18 @@ void OreStratum::generate(MMVManip *vm, int mapseed, u32 blockseed,
continue;
}
- float nmid = noise->result[index];
- float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
- int y0 = MYMAX(nmin.Y, nmid - nhalfthick);
- int y1 = MYMIN(nmax.Y, nmid + nhalfthick);
+ int y0;
+ int y1;
+
+ if (flags & OREFLAG_USE_NOISE) {
+ float nmid = noise->result[index];
+ float nhalfthick = noise_stratum_thickness->result[index] / 2.0f;
+ y0 = MYMAX(nmin.Y, nmid - nhalfthick);
+ y1 = MYMIN(nmax.Y, nmid + nhalfthick);
+ } else {
+ y0 = nmin.Y;
+ y1 = nmax.Y;
+ }
for (int y = y0; y <= y1; y++) {
if (pr.range(1, clust_scarcity) != 1)
diff --git a/src/mg_ore.h b/src/mg_ore.h
index 4801b152e..e715f348b 100644
--- a/src/mg_ore.h
+++ b/src/mg_ore.h
@@ -135,7 +135,7 @@ public:
class OreStratum : public Ore {
public:
- static const bool NEEDS_NOISE = true;
+ static const bool NEEDS_NOISE = false;
NoiseParams np_stratum_thickness;
Noise *noise_stratum_thickness = nullptr;
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index 7757ea80c..b179ac407 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -1156,7 +1156,9 @@ int ModApiMapgen::l_register_ore(lua_State *L)
OreStratum *orestratum = (OreStratum *)ore;
lua_getfield(L, index, "np_stratum_thickness");
- read_noiseparams(L, -1, &orestratum->np_stratum_thickness);
+ // If thickness noise missing unset 'use noise' flag
+ if (!read_noiseparams(L, -1, &orestratum->np_stratum_thickness))
+ ore->flags &= ~OREFLAG_USE_NOISE;
lua_pop(L, 1);
break;