#include "mapgen_v7.h"
#include "cavegen.h"
+NoiseParams nparams_caveliquids =
+ {0, 1, v3f(150.0, 150.0, 150.0), 776, 3, 0.6};
+
+
+///////////////////////////////////////////////////////////////////////////////
+
CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_cave) {
this->mg = mg;
this->ps = ps;
this->c_water_source = mg->c_water_source;
this->c_lava_source = mg->c_lava_source;
+ this->np_caveliquids = &nparams_caveliquids;
dswitchint = ps->range(1, 14);
flooded = ps->range(1, 2) == 2;
// Allow a bit more
//(this should be more than the maximum radius of the tunnel)
s16 insure = 10;
- s16 more = MAP_BLOCKSIZE - max_tunnel_diameter / 2 - insure;
+ s16 more = MYMAX(MAP_BLOCKSIZE - max_tunnel_diameter / 2 - insure, 1);
ar += v3s16(1,0,1) * more * 2;
of -= v3s16(1,0,1) * more;
MapNode airnode(CONTENT_AIR);
MapNode waternode(c_water_source);
MapNode lavanode(c_lava_source);
- MapNode liquidnode = ps->range(0, 4) ? lavanode : waternode;
v3s16 startp(orp.X, orp.Y, orp.Z);
startp += of;
+ float nval = NoisePerlin3D(np_caveliquids, startp.X,
+ startp.Y, startp.Z, mg->seed);
+ MapNode liquidnode = nval < 0.40 ? lavanode : waternode;
+
v3f fp = orp + vec * f;
fp.X += 0.1 * ps->range(-10, 10);
fp.Z += 0.1 * ps->range(-10, 10);
v3s16 p(cp.X + x0, cp.Y + y0, cp.Z + z0);
p += of;
+
+ if (!is_ravine && mg->heightmap) {
+ int maplen = node_max.X - node_min.X + 1;
+ int idx = (p.Z - node_min.Z) * maplen + (p.X - node_min.X);
+ if (p.Y >= mg->heightmap[idx])
+ continue;
+ }
if (vm->m_area.contains(p) == false)
continue;