@@ -1654,10 +1654,10 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1654
1654
loop_max *= m_transforming_liquid_loop_count_multiplier;
1655
1655
#endif
1656
1656
1657
- while (m_transforming_liquid.size () != 0 )
1657
+ while (m_transforming_liquid.size () != 0 )
1658
1658
{
1659
1659
// This should be done here so that it is done when continue is used
1660
- if (loopcount >= initial_size || loopcount >= loop_max)
1660
+ if (loopcount >= initial_size || loopcount >= loop_max)
1661
1661
break ;
1662
1662
loopcount++;
1663
1663
@@ -1674,21 +1674,24 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1674
1674
*/
1675
1675
s8 liquid_level = -1 ;
1676
1676
content_t liquid_kind = CONTENT_IGNORE;
1677
- LiquidType liquid_type = nodemgr->get (n0).liquid_type ;
1677
+ content_t floodable_node = CONTENT_AIR;
1678
+ ContentFeatures cf = nodemgr->get (n0);
1679
+ LiquidType liquid_type = cf.liquid_type ;
1678
1680
switch (liquid_type) {
1679
1681
case LIQUID_SOURCE:
1680
1682
liquid_level = LIQUID_LEVEL_SOURCE;
1681
- liquid_kind = nodemgr->getId (nodemgr-> get (n0) .liquid_alternative_flowing );
1683
+ liquid_kind = nodemgr->getId (cf .liquid_alternative_flowing );
1682
1684
break ;
1683
1685
case LIQUID_FLOWING:
1684
1686
liquid_level = (n0.param2 & LIQUID_LEVEL_MASK);
1685
1687
liquid_kind = n0.getContent ();
1686
1688
break ;
1687
1689
case LIQUID_NONE:
1688
- // if this is an air node , it *could* be transformed into a liquid. otherwise,
1689
- // continue with the next node.
1690
- if (n0. getContent () != CONTENT_AIR )
1690
+ // if this node is 'floodable' , it *could* be transformed
1691
+ // into a liquid, otherwise, continue with the next node.
1692
+ if (!cf. floodable )
1691
1693
continue ;
1694
+ floodable_node = n0.getContent ();
1692
1695
liquid_kind = CONTENT_AIR;
1693
1696
break ;
1694
1697
}
@@ -1718,9 +1721,10 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1718
1721
}
1719
1722
v3s16 npos = p0 + dirs[i];
1720
1723
NodeNeighbor nb (getNodeNoEx (npos), nt, npos);
1724
+ ContentFeatures cfnb = nodemgr->get (nb.n );
1721
1725
switch (nodemgr->get (nb.n .getContent ()).liquid_type ) {
1722
1726
case LIQUID_NONE:
1723
- if (nb. n . getContent () == CONTENT_AIR ) {
1727
+ if (cfnb. floodable ) {
1724
1728
airs[num_airs++] = nb;
1725
1729
// if the current node is a water source the neighbor
1726
1730
// should be enqueded for transformation regardless of whether the
@@ -1738,8 +1742,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1738
1742
case LIQUID_SOURCE:
1739
1743
// if this node is not (yet) of a liquid type, choose the first liquid type we encounter
1740
1744
if (liquid_kind == CONTENT_AIR)
1741
- liquid_kind = nodemgr->getId (nodemgr-> get (nb. n ) .liquid_alternative_flowing );
1742
- if (nodemgr->getId (nodemgr-> get (nb. n ) .liquid_alternative_flowing ) != liquid_kind) {
1745
+ liquid_kind = nodemgr->getId (cfnb .liquid_alternative_flowing );
1746
+ if (nodemgr->getId (cfnb .liquid_alternative_flowing ) != liquid_kind) {
1743
1747
neutrals[num_neutrals++] = nb;
1744
1748
} else {
1745
1749
// Do not count bottom source, it will screw things up
@@ -1750,8 +1754,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1750
1754
case LIQUID_FLOWING:
1751
1755
// if this node is not (yet) of a liquid type, choose the first liquid type we encounter
1752
1756
if (liquid_kind == CONTENT_AIR)
1753
- liquid_kind = nodemgr->getId (nodemgr-> get (nb. n ) .liquid_alternative_flowing );
1754
- if (nodemgr->getId (nodemgr-> get (nb. n ) .liquid_alternative_flowing ) != liquid_kind) {
1757
+ liquid_kind = nodemgr->getId (cfnb .liquid_alternative_flowing );
1758
+ if (nodemgr->getId (cfnb .liquid_alternative_flowing ) != liquid_kind) {
1755
1759
neutrals[num_neutrals++] = nb;
1756
1760
} else {
1757
1761
flows[num_flows++] = nb;
@@ -1770,8 +1774,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1770
1774
s8 max_node_level = -1 ;
1771
1775
1772
1776
u8 range = nodemgr->get (liquid_kind).liquid_range ;
1773
- if (range > LIQUID_LEVEL_MAX+ 1 )
1774
- range = LIQUID_LEVEL_MAX+ 1 ;
1777
+ if (range > LIQUID_LEVEL_MAX + 1 )
1778
+ range = LIQUID_LEVEL_MAX + 1 ;
1775
1779
1776
1780
if ((num_sources >= 2 && nodemgr->get (liquid_kind).liquid_renewable ) || liquid_type == LIQUID_SOURCE) {
1777
1781
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
@@ -1780,10 +1784,11 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1780
1784
new_node_content = nodemgr->getId (nodemgr->get (liquid_kind).liquid_alternative_source );
1781
1785
} else if (num_sources >= 1 && sources[0 ].t != NEIGHBOR_LOWER) {
1782
1786
// liquid_kind is set properly, see above
1783
- new_node_content = liquid_kind;
1784
1787
max_node_level = new_node_level = LIQUID_LEVEL_MAX;
1785
- if (new_node_level < (LIQUID_LEVEL_MAX+1 -range))
1786
- new_node_content = CONTENT_AIR;
1788
+ if (new_node_level >= (LIQUID_LEVEL_MAX + 1 - range))
1789
+ new_node_content = liquid_kind;
1790
+ else
1791
+ new_node_content = floodable_node;
1787
1792
} else {
1788
1793
// no surrounding sources, so get the maximum level that can flow into this node
1789
1794
for (u16 i = 0 ; i < num_flows; i++) {
@@ -1794,16 +1799,16 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1794
1799
max_node_level = LIQUID_LEVEL_MAX;
1795
1800
if (nb_liquid_level + WATER_DROP_BOOST < LIQUID_LEVEL_MAX)
1796
1801
max_node_level = nb_liquid_level + WATER_DROP_BOOST;
1797
- } else if (nb_liquid_level > max_node_level)
1802
+ } else if (nb_liquid_level > max_node_level) {
1798
1803
max_node_level = nb_liquid_level;
1804
+ }
1799
1805
break ;
1800
1806
case NEIGHBOR_LOWER:
1801
1807
break ;
1802
1808
case NEIGHBOR_SAME_LEVEL:
1803
1809
if ((flows[i].n .param2 & LIQUID_FLOW_DOWN_MASK) != LIQUID_FLOW_DOWN_MASK &&
1804
- nb_liquid_level > 0 && nb_liquid_level - 1 > max_node_level) {
1810
+ nb_liquid_level > 0 && nb_liquid_level - 1 > max_node_level)
1805
1811
max_node_level = nb_liquid_level - 1 ;
1806
- }
1807
1812
break ;
1808
1813
}
1809
1814
}
@@ -1821,23 +1826,25 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1821
1826
new_node_level = liquid_level + 1 ;
1822
1827
if (new_node_level != max_node_level)
1823
1828
must_reflow.push_back (p0);
1824
- } else
1829
+ } else {
1825
1830
new_node_level = max_node_level;
1831
+ }
1826
1832
1827
- if (max_node_level >= (LIQUID_LEVEL_MAX+ 1 - range))
1833
+ if (max_node_level >= (LIQUID_LEVEL_MAX + 1 - range))
1828
1834
new_node_content = liquid_kind;
1829
1835
else
1830
- new_node_content = CONTENT_AIR ;
1836
+ new_node_content = floodable_node ;
1831
1837
1832
1838
}
1833
1839
1834
1840
/*
1835
1841
check if anything has changed. if not, just continue with the next node.
1836
1842
*/
1837
- if (new_node_content == n0.getContent () && (nodemgr->get (n0.getContent ()).liquid_type != LIQUID_FLOWING ||
1838
- ((n0.param2 & LIQUID_LEVEL_MASK) == (u8)new_node_level &&
1839
- ((n0.param2 & LIQUID_FLOW_DOWN_MASK) == LIQUID_FLOW_DOWN_MASK)
1840
- == flowing_down)))
1843
+ if (new_node_content == n0.getContent () &&
1844
+ (nodemgr->get (n0.getContent ()).liquid_type != LIQUID_FLOWING ||
1845
+ ((n0.param2 & LIQUID_LEVEL_MASK) == (u8)new_node_level &&
1846
+ ((n0.param2 & LIQUID_FLOW_DOWN_MASK) == LIQUID_FLOW_DOWN_MASK)
1847
+ == flowing_down)))
1841
1848
continue ;
1842
1849
1843
1850
@@ -1857,11 +1864,10 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1857
1864
1858
1865
// Find out whether there is a suspect for this action
1859
1866
std::string suspect;
1860
- if (m_gamedef->rollback ()) {
1867
+ if (m_gamedef->rollback ())
1861
1868
suspect = m_gamedef->rollback ()->getSuspect (p0, 83 , 1 );
1862
- }
1863
1869
1864
- if (m_gamedef->rollback () && !suspect.empty ()){
1870
+ if (m_gamedef->rollback () && !suspect.empty ()) {
1865
1871
// Blame suspect
1866
1872
RollbackScopeActor rollback_scope (m_gamedef->rollback (), suspect, true );
1867
1873
// Get old node for rollback
@@ -1880,10 +1886,10 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
1880
1886
1881
1887
v3s16 blockpos = getNodeBlockPos (p0);
1882
1888
MapBlock *block = getBlockNoCreateNoEx (blockpos);
1883
- if (block != NULL ) {
1889
+ if (block != NULL ) {
1884
1890
modified_blocks[blockpos] = block;
1885
1891
// If new or old node emits light, MapBlock requires lighting update
1886
- if (nodemgr->get (n0).light_source != 0 ||
1892
+ if (nodemgr->get (n0).light_source != 0 ||
1887
1893
nodemgr->get (n00).light_source != 0 )
1888
1894
lighting_modified_blocks[block->getPos ()] = block;
1889
1895
}
0 commit comments