aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen/mg_ore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapgen/mg_ore.cpp')
-rw-r--r--src/mapgen/mg_ore.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/mapgen/mg_ore.cpp b/src/mapgen/mg_ore.cpp
index f83933ed1..6f27b91ac 100644
--- a/src/mapgen/mg_ore.cpp
+++ b/src/mapgen/mg_ore.cpp
@@ -371,17 +371,23 @@ void OreVein::generate(MMVManip *vm, int mapseed, u32 blockseed,
PcgRandom pr(blockseed + 520);
MapNode n_ore(c_ore, 0, ore_param2);
- u32 sizex = (nmax.X - nmin.X + 1);
-
- if (!noise) {
- int sx = nmax.X - nmin.X + 1;
- int sy = nmax.Y - nmin.Y + 1;
- int sz = nmax.Z - nmin.Z + 1;
- noise = new Noise(&np, mapseed, sx, sy, sz);
- noise2 = new Noise(&np, mapseed + 436, sx, sy, sz);
+ int sizex = nmax.X - nmin.X + 1;
+ int sizey = nmax.Y - nmin.Y + 1;
+ // Because this ore uses 3D noise the perlinmap Y size can be different in
+ // different mapchunks due to ore Y limits. So recreate the noise objects
+ // if Y size has changed.
+ // Because these noise objects are created multiple times for this ore type
+ // it is necessary to 'delete' them here.
+ if (!noise || sizey != sizey_prev) {
+ delete noise;
+ delete noise2;
+ int sizez = nmax.Z - nmin.Z + 1;
+ noise = new Noise(&np, mapseed, sizex, sizey, sizez);
+ noise2 = new Noise(&np, mapseed + 436, sizex, sizey, sizez);
+ sizey_prev = sizey;
}
- bool noise_generated = false;
+ bool noise_generated = false;
size_t index = 0;
for (int z = nmin.Z; z <= nmax.Z; z++)
for (int y = nmin.Y; y <= nmax.Y; y++)