It seems I successfully devised an interim solution at least for Minetest 0.4.13, by reworking the following code in cavegen.cpp:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
CaveV7::CaveV7(MapgenV7 *mg, PseudoRandom *ps)
{
this->mg = mg;
this->vm = mg->vm;
this->ndef = mg->ndef;
this->water_level = mg->water_level;
// SK fix begin
this->surface_level = mg->terrain_surface_level;
// SK fix end
:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
void CaveV7::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height) {
:
// SK fix begin
// Allow tunnel radius to project above surface
route_y_max = -of.Y + max_stone_y + max_tunnel_diameter / 2;
// Limit maximum to area
route_y_max = rangelim(route_y_max, 0, ar.Y - 1);
// Limit maximum to area
route_y_max = rangelim(route_y_max, 0, ar.Y - 1);
s16 min = 0;
if (node_min.Y < surface_level && node_max.Y > surface_level) {
min = surface_level - max_tunnel_diameter/3 - of.Y;
route_y_max = surface_level + max_tunnel_diameter/3 - of.Y;
}
// SK fix end
:
I also defined "surface_level" and "terrain_surface_level" within the appropriate structs and classes of cavegen.h and mapgen.h. And, of course, I added "terrain_surface_level" to mapgen.cpp, as a user-definable parameter.
I was hoping to implement a "terrain_bedrock_level" as a counterpart to "terrain_surface_level" thereby setting the minimum cave generation range, but that would have required far more substantial changes to cavegen.cpp (as it stands, the upper limit was already conditional on "mg->water_level", so that was an easy enough replacement.) Since I'm fairly unfamiliar with the mapgen logic, I didn't venture much further for fear of breaking something important.
This of course is just a quick and dirty fix. Ideally there would be a formalized specification for cavegen parameters, maybe in a future release I hope :)