diff options
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r-- | src/mapnode.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp index bf7e79a71..dcf1f6d6e 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -584,7 +584,7 @@ u8 MapNode::getMaxLevel(const NodeDefManager *nodemgr) const if( f.liquid_type == LIQUID_FLOWING || f.param_type_2 == CPT2_FLOWINGLIQUID) return LIQUID_LEVEL_MAX; if(f.leveled || f.param_type_2 == CPT2_LEVELED) - return LEVELED_MAX; + return f.leveled_max; return 0; } @@ -603,14 +603,15 @@ u8 MapNode::getLevel(const NodeDefManager *nodemgr) const if (level) return level; } - if (f.leveled > LEVELED_MAX) - return LEVELED_MAX; + // Return static value from nodedef if param2 isn't used for level + if (f.leveled > f.leveled_max) + return f.leveled_max; return f.leveled; } -u8 MapNode::setLevel(const NodeDefManager *nodemgr, s8 level) +s8 MapNode::setLevel(const NodeDefManager *nodemgr, s16 level) { - u8 rest = 0; + s8 rest = 0; const ContentFeatures &f = nodemgr->get(*this); if (f.param_type_2 == CPT2_FLOWINGLIQUID || f.liquid_type == LIQUID_FLOWING @@ -621,28 +622,28 @@ u8 MapNode::setLevel(const NodeDefManager *nodemgr, s8 level) } if (level >= LIQUID_LEVEL_SOURCE) { rest = level - LIQUID_LEVEL_SOURCE; - setContent(nodemgr->getId(f.liquid_alternative_source)); + setContent(f.liquid_alternative_source_id); setParam2(0); } else { - setContent(nodemgr->getId(f.liquid_alternative_flowing)); + setContent(f.liquid_alternative_flowing_id); setParam2((level & LIQUID_LEVEL_MASK) | (getParam2() & ~LIQUID_LEVEL_MASK)); } } else if (f.param_type_2 == CPT2_LEVELED) { if (level < 0) { // zero means default for a leveled nodebox rest = level; level = 0; - } else if (level > LEVELED_MAX) { - rest = level - LEVELED_MAX; - level = LEVELED_MAX; + } else if (level > f.leveled_max) { + rest = level - f.leveled_max; + level = f.leveled_max; } setParam2((level & LEVELED_MASK) | (getParam2() & ~LEVELED_MASK)); } return rest; } -u8 MapNode::addLevel(const NodeDefManager *nodemgr, s8 add) +s8 MapNode::addLevel(const NodeDefManager *nodemgr, s16 add) { - s8 level = getLevel(nodemgr); + s16 level = getLevel(nodemgr); level += add; return setLevel(nodemgr, level); } |