diff options
author | paramat <mat.gregory@virginmedia.com> | 2015-03-16 01:22:37 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2015-03-19 10:18:42 +0000 |
commit | d03c2999daafaff5b48948bb97a5854f5fb56484 (patch) | |
tree | 0078dd908cb180acd7ff6af6299e876d691d2a7a /src | |
parent | 2676d289d9ac46a3145f3740c75e5078480ff858 (diff) | |
download | minetest-d03c2999daafaff5b48948bb97a5854f5fb56484.tar.gz minetest-d03c2999daafaff5b48948bb97a5854f5fb56484.tar.bz2 minetest-d03c2999daafaff5b48948bb97a5854f5fb56484.zip |
Mgv5/mgv7: Sprinkle dust from full_node_max.Y if chunk above is generated
Mgv5: Add large_cave_depth constant
Diffstat (limited to 'src')
-rw-r--r-- | src/mapgen_v5.cpp | 33 | ||||
-rw-r--r-- | src/mapgen_v5.h | 2 | ||||
-rw-r--r-- | src/mapgen_v7.cpp | 30 |
3 files changed, 49 insertions, 16 deletions
diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp index 6adfac55b..9086acc37 100644 --- a/src/mapgen_v5.cpp +++ b/src/mapgen_v5.cpp @@ -501,7 +501,7 @@ void MapgenV5::generateCaves(int max_stone_y) index2d = index2d + ystride; } - if (node_max.Y > -256) + if (node_max.Y > LARGE_CAVE_DEPTH) return; PseudoRandom ps(blockseed + 21343); @@ -528,9 +528,28 @@ void MapgenV5::dustTopNodes() if (biome->c_dust == CONTENT_IGNORE) continue; - s16 y = node_max.Y + 1; - u32 vi = vm->m_area.index(x, y, z); - for (; y >= node_min.Y; y--) { + s16 y_full_max = full_node_max.Y; + u32 vi_full_max = vm->m_area.index(x, y_full_max, z); + content_t c_full_max = vm->m_data[vi_full_max].getContent(); + s16 y_start; + + if (c_full_max == CONTENT_AIR) { + y_start = y_full_max - 1; + } else if (c_full_max == CONTENT_IGNORE) { + s16 y_max = node_max.Y; + u32 vi_max = vm->m_area.index(x, y_max, z); + content_t c_max = vm->m_data[vi_max].getContent(); + + if (c_max == CONTENT_AIR) + y_start = y_max - 1; + else + continue; + } else { + continue; + } + + u32 vi = vm->m_area.index(x, y_start, z); + for (s16 y = y_start; y >= node_min.Y - 1; y--) { if (vm->m_data[vi].getContent() != CONTENT_AIR) break; @@ -538,11 +557,7 @@ void MapgenV5::dustTopNodes() } content_t c = vm->m_data[vi].getContent(); - if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE - && c != biome->c_dust) { - if (y == node_max.Y + 1) - continue; - + if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE && c != biome->c_dust) { vm->m_area.add_y(em, vi, 1); vm->m_data[vi] = MapNode(biome->c_dust); } diff --git a/src/mapgen_v5.h b/src/mapgen_v5.h index 8dd52cc9e..e679bdec2 100644 --- a/src/mapgen_v5.h +++ b/src/mapgen_v5.h @@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapgen.h" +#define LARGE_CAVE_DEPTH -256 + /////////////////// Mapgen V5 flags //#define MGV5_ 0x01 diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index 65e43decb..5e6e15ad0 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -691,9 +691,28 @@ void MapgenV7::dustTopNodes() if (biome->c_dust == CONTENT_IGNORE) continue; - s16 y = node_max.Y; - u32 vi = vm->m_area.index(x, y, z); - for (; y >= node_min.Y; y--) { + s16 y_full_max = full_node_max.Y; + u32 vi_full_max = vm->m_area.index(x, y_full_max, z); + content_t c_full_max = vm->m_data[vi_full_max].getContent(); + s16 y_start; + + if (c_full_max == CONTENT_AIR) { + y_start = y_full_max - 1; + } else if (c_full_max == CONTENT_IGNORE) { + s16 y_max = node_max.Y; + u32 vi_max = vm->m_area.index(x, y_max, z); + content_t c_max = vm->m_data[vi_max].getContent(); + + if (c_max == CONTENT_AIR) + y_start = y_max - 1; + else + continue; + } else { + continue; + } + + u32 vi = vm->m_area.index(x, y_start, z); + for (s16 y = y_start; y >= node_min.Y - 1; y--) { if (vm->m_data[vi].getContent() != CONTENT_AIR) break; @@ -701,10 +720,7 @@ void MapgenV7::dustTopNodes() } content_t c = vm->m_data[vi].getContent(); - if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE) { - if (y == node_max.Y) - continue; - + if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE && c != biome->c_dust) { vm->m_area.add_y(em, vi, 1); vm->m_data[vi] = MapNode(biome->c_dust); } |