From 7452d5399b9c7516abfc9f97bf5db70aff2ce0fa Mon Sep 17 00:00:00 2001 From: paramat Date: Wed, 31 Dec 2014 00:19:05 +0000 Subject: MgV5/6/7: Generate dungeons above water level Use/add stone_surface_max_y to speed-optimise/guide dungeon generation MgV7: Don't let mountain terrain chop dungeons at mapchunk borders Make mountain terrain update stone_surface_max_y for caves in mountains --- src/mapgen_v7.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/mapgen_v7.cpp') diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index d9e928006..3b7c20b96 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -241,7 +241,7 @@ void MapgenV7::makeChunk(BlockMakeData *data) if (flags & MG_CAVES) generateCaves(stone_surface_max_y); - if (flags & MG_DUNGEONS) { + if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) { DungeonGen dgen(this, NULL); dgen.generate(blockseed, full_node_min, full_node_max); } @@ -405,7 +405,7 @@ int MapgenV7::generateTerrain() int ymax = generateBaseTerrain(); if (spflags & MGV7_MOUNTAINS) - generateMountainTerrain(); + ymax = generateMountainTerrain(ymax); if (spflags & MGV7_RIDGES) generateRidgeTerrain(); @@ -453,10 +453,10 @@ int MapgenV7::generateBaseTerrain() } -void MapgenV7::generateMountainTerrain() +int MapgenV7::generateMountainTerrain(int ymax) { if (node_max.Y <= water_level) - return; + return ymax; MapNode n_stone(c_stone); u32 j = 0; @@ -466,14 +466,21 @@ void MapgenV7::generateMountainTerrain() u32 vi = vm->m_area.index(node_min.X, y, z); for (s16 x = node_min.X; x <= node_max.X; x++) { int index = (z - node_min.Z) * csize.X + (x - node_min.X); + content_t c = vm->m_data[vi].getContent(); - if (getMountainTerrainFromMap(j, index, y)) + if (getMountainTerrainFromMap(j, index, y) + && (c == CONTENT_AIR || c == c_water_source)) { vm->m_data[vi] = n_stone; + if (y > ymax) + ymax = y; + } vi++; j++; } } + + return ymax; } -- cgit v1.2.3