Cavegen: Respect is_ground_content MapNode setting; fix some code formatting issues

This commit is contained in:
kwolekr 2013-11-29 20:54:04 -05:00
parent d19a69cd0d
commit 747bc40840
3 changed files with 29 additions and 25 deletions

@ -236,6 +236,9 @@ void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz) {
continue; continue;
u32 i = vm->m_area.index(p); u32 i = vm->m_area.index(p);
content_t c = vm->m_data[i].getContent();
if (!ndef->get(c).is_ground_content)
continue;
if (large_cave) { if (large_cave) {
int full_ymin = node_min.Y - MAP_BLOCKSIZE; int full_ymin = node_min.Y - MAP_BLOCKSIZE;
@ -250,7 +253,6 @@ void CaveV6::carveRoute(v3f vec, float f, bool randomize_xz) {
} }
} else { } else {
// Don't replace air or water or lava or ignore // Don't replace air or water or lava or ignore
content_t c = vm->m_data[i].getContent();
if (c == CONTENT_IGNORE || c == CONTENT_AIR || if (c == CONTENT_IGNORE || c == CONTENT_AIR ||
c == c_water_source || c == c_lava_source) c == c_water_source || c == c_lava_source)
continue; continue;
@ -530,8 +532,8 @@ void CaveV7::carveRoute(v3f vec, float f, bool randomize_xz, bool is_ravine) {
// Don't replace air, water, lava, or ice // Don't replace air, water, lava, or ice
content_t c = vm->m_data[i].getContent(); content_t c = vm->m_data[i].getContent();
if (c == CONTENT_AIR || c == c_water_source || if (!ndef->get(c).is_ground_content || c == CONTENT_AIR ||
c == c_lava_source || c == c_ice) c == c_water_source || c == c_lava_source || c == c_ice)
continue; continue;
if (large_cave) { if (large_cave) {

@ -383,8 +383,10 @@ u8 MapNode::getLevel(INodeDefManager *nodemgr) const
return getParam2() & LIQUID_LEVEL_MASK; return getParam2() & LIQUID_LEVEL_MASK;
if(f.leveled || f.param_type_2 == CPT2_LEVELED) { if(f.leveled || f.param_type_2 == CPT2_LEVELED) {
u8 level = getParam2() & LEVELED_MASK; u8 level = getParam2() & LEVELED_MASK;
if(level) return level; if(level)
if(f.leveled > LEVELED_MAX) return LEVELED_MAX; return level;
if(f.leveled > LEVELED_MAX)
return LEVELED_MAX;
return f.leveled; //default return f.leveled; //default
} }
return 0; return 0;
@ -487,8 +489,7 @@ void MapNode::deSerialize(u8 *source, u8 version)
param0 = readU16(source+0); param0 = readU16(source+0);
param1 = readU8(source+2); param1 = readU8(source+2);
param2 = readU8(source+3); param2 = readU8(source+3);
} }else{
else{
param0 = readU8(source+0); param0 = readU8(source+0);
param1 = readU8(source+1); param1 = readU8(source+1);
param2 = readU8(source+2); param2 = readU8(source+2);

@ -405,6 +405,7 @@ public:
f.pointable = false; f.pointable = false;
f.diggable = false; f.diggable = false;
f.buildable_to = true; f.buildable_to = true;
f.is_ground_content = true;
// Insert directly into containers // Insert directly into containers
content_t c = CONTENT_AIR; content_t c = CONTENT_AIR;
m_content_features[c] = f; m_content_features[c] = f;
@ -422,8 +423,8 @@ public:
f.walkable = false; f.walkable = false;
f.pointable = false; f.pointable = false;
f.diggable = false; f.diggable = false;
// A way to remove accidental CONTENT_IGNOREs f.buildable_to = true; // A way to remove accidental CONTENT_IGNOREs
f.buildable_to = true; f.is_ground_content = true;
// Insert directly into containers // Insert directly into containers
content_t c = CONTENT_IGNORE; content_t c = CONTENT_IGNORE;
m_content_features[c] = f; m_content_features[c] = f;