Cavegen: Rename CaveV6 to CavesV6

- Add comment explaining why it exists
- Remove unused 'flooded' variable
- Rename shadowed variable
- Fix some code style
This commit is contained in:
kwolekr 2016-05-10 00:10:59 -04:00
parent 1bb5eb1da2
commit bf25837617
3 changed files with 41 additions and 29 deletions

@ -277,10 +277,12 @@ void CavesRandomWalk::carveRoute(v3f vec, float f, bool randomize_xz)
}
///////////////////////////////////////// Caves V6
////
//// CavesV6
////
CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_cave)
CavesV6::CavesV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2,
bool is_large_cave)
{
this->mg = mg;
this->vm = mg->vm;
@ -295,7 +297,6 @@ CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_
min_tunnel_diameter = 2;
max_tunnel_diameter = ps->range(2, 6);
dswitchint = ps->range(1, 14);
flooded = true;
if (large_cave) {
part_max_length_rs = ps->range(2, 4);
@ -311,7 +312,7 @@ CaveV6::CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool is_large_
}
void CaveV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height)
void CavesV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height)
{
node_min = nmin;
node_max = nmax;
@ -339,12 +340,12 @@ void CaveV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height)
route_y_max = rangelim(route_y_max, 0, ar.Y - 1);
if (large_cave) {
s16 min = 0;
s16 minpos = 0;
if (node_min.Y < water_level && node_max.Y > water_level) {
min = water_level - max_tunnel_diameter/3 - of.Y;
minpos = water_level - max_tunnel_diameter / 3 - of.Y;
route_y_max = water_level + max_tunnel_diameter / 3 - of.Y;
}
route_y_min = ps->range(min, min + max_tunnel_diameter);
route_y_min = ps->range(minpos, minpos + max_tunnel_diameter);
route_y_min = rangelim(route_y_min, 0, route_y_max);
}
@ -379,7 +380,7 @@ void CaveV6::makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height)
}
void CaveV6::makeTunnel(bool dirswitch)
void CavesV6::makeTunnel(bool dirswitch)
{
if (dirswitch && !large_cave) {
main_direction = v3f(
@ -496,7 +497,8 @@ void CaveV6::makeTunnel(bool dirswitch)
}
void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz, bool tunnel_above_ground)
void CavesV6::carveRoute(v3f vec, float f, bool randomize_xz,
bool tunnel_above_ground)
{
MapNode airnode(CONTENT_AIR);
MapNode waternode(c_water_source);
@ -547,11 +549,10 @@ void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz, bool tunnel_above_g
int full_ymin = node_min.Y - MAP_BLOCKSIZE;
int full_ymax = node_max.Y + MAP_BLOCKSIZE;
if (flooded && full_ymin < water_level &&
full_ymax > water_level) {
if (full_ymin < water_level && full_ymax > water_level) {
vm->m_data[i] = (p.Y <= water_level) ?
waternode : airnode;
} else if (flooded && full_ymax < water_level) {
} else if (full_ymax < water_level) {
vm->m_data[i] = (p.Y < startp.Y - 2) ?
lavanode : airnode;
} else {

@ -72,7 +72,20 @@ public:
void carveRoute(v3f vec, float f, bool randomize_xz);
};
class CaveV6 {
/*
CavesV6 is the original version of caves used with Mapgen V6.
Though it uses the same fundamental algorithm as CavesRandomWalk, it is made
separate to preserve the exact sequence of PseudoRandom calls - any change
to this ordering results in the output being radically different.
Because caves in Mapgen V6 are responsible for a large portion of the basic
terrain shape, modifying this will break our contract of reverse
compatibility for a 'stable' mapgen such as V6.
tl;dr,
*** DO NOT TOUCH THIS CLASS UNLESS YOU KNOW WHAT YOU ARE DOING ***
*/
class CavesV6 {
public:
MapgenV6 *mg;
MMVManip *vm;
@ -86,7 +99,6 @@ public:
bool large_cave;
bool large_cave_is_flat;
bool flooded;
s16 max_stone_y;
v3s16 node_min;
@ -109,8 +121,7 @@ public:
int water_level;
CaveV6() {}
CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool large_cave);
CavesV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool large_cave);
void makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height);
void makeTunnel(bool dirswitch);
void carveRoute(v3f vec, float f, bool randomize_xz, bool tunnel_above_ground);

@ -1067,7 +1067,7 @@ void MapgenV6::generateCaves(int max_stone_y)
for (u32 i = 0; i < caves_count + bruises_count; i++) {
bool large_cave = (i >= caves_count);
CaveV6 cave(this, &ps, &ps2, large_cave);
CavesV6 cave(this, &ps, &ps2, large_cave);
cave.makeCave(node_min, node_max, max_stone_y);
}