Skip to content

Commit 493a298

Browse files
committedMar 21, 2016
Mgv7/flat/fractal: Stop tunnel-floor biome nodes being placed everywhere
A bool for 'in or under tunnel' was missing 1-node-deep stone ledges were being replaced with biome surface material
1 parent 9388704 commit 493a298

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
 

Diff for: ‎src/mapgen_flat.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ void MapgenFlat::generateCaves(s16 max_stone_y)
565565
for (s16 z = node_min.Z; z <= node_max.Z; z++)
566566
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
567567
bool column_is_open = false; // Is column open to overground
568+
bool is_tunnel = false; // Is tunnel or tunnel floor
568569
u32 vi = vm->m_area.index(x, node_max.Y + 1, z);
569570
u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride +
570571
(x - node_min.X);
@@ -591,13 +592,16 @@ void MapgenFlat::generateCaves(s16 max_stone_y)
591592
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
592593
// In tunnel and ground content, excavate
593594
vm->m_data[vi] = MapNode(CONTENT_AIR);
594-
} else if (column_is_open &&
595+
is_tunnel = true;
596+
} else if (is_tunnel && column_is_open &&
595597
(c == biome->c_filler || c == biome->c_stone)) {
596598
// Tunnel entrance floor
597599
vm->m_data[vi] = MapNode(biome->c_top);
598600
column_is_open = false;
601+
is_tunnel = false;
599602
} else {
600603
column_is_open = false;
604+
is_tunnel = false;
601605
}
602606
}
603607
}

Diff for: ‎src/mapgen_fractal.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ void MapgenFractal::generateCaves(s16 max_stone_y)
693693
for (s16 z = node_min.Z; z <= node_max.Z; z++)
694694
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
695695
bool column_is_open = false; // Is column open to overground
696+
bool is_tunnel = false; // Is tunnel or tunnel floor
696697
u32 vi = vm->m_area.index(x, node_max.Y + 1, z);
697698
u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride +
698699
(x - node_min.X);
@@ -719,13 +720,16 @@ void MapgenFractal::generateCaves(s16 max_stone_y)
719720
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
720721
// In tunnel and ground content, excavate
721722
vm->m_data[vi] = MapNode(CONTENT_AIR);
722-
} else if (column_is_open &&
723+
is_tunnel = true;
724+
} else if (is_tunnel && column_is_open &&
723725
(c == biome->c_filler || c == biome->c_stone)) {
724726
// Tunnel entrance floor
725727
vm->m_data[vi] = MapNode(biome->c_top);
726728
column_is_open = false;
729+
is_tunnel = false;
727730
} else {
728731
column_is_open = false;
732+
is_tunnel = false;
729733
}
730734
}
731735
}

Diff for: ‎src/mapgen_v7.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ void MapgenV7::generateCaves(s16 max_stone_y)
875875
for (s16 z = node_min.Z; z <= node_max.Z; z++)
876876
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
877877
bool column_is_open = false; // Is column open to overground
878+
bool is_tunnel = false; // Is tunnel or tunnel floor
878879
u32 vi = vm->m_area.index(x, node_max.Y + 1, z);
879880
u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride +
880881
(x - node_min.X);
@@ -901,13 +902,16 @@ void MapgenV7::generateCaves(s16 max_stone_y)
901902
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
902903
// In tunnel and ground content, excavate
903904
vm->m_data[vi] = MapNode(CONTENT_AIR);
904-
} else if (column_is_open &&
905+
is_tunnel = true;
906+
} else if (is_tunnel && column_is_open &&
905907
(c == biome->c_filler || c == biome->c_stone)) {
906908
// Tunnel entrance floor
907909
vm->m_data[vi] = MapNode(biome->c_top);
908910
column_is_open = false;
911+
is_tunnel = false;
909912
} else {
910913
column_is_open = false;
914+
is_tunnel = false;
911915
}
912916
}
913917
}

0 commit comments

Comments
 (0)