summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-08-16 06:00:40 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-08-16 06:42:11 +0200
commit708f1c336ef8214e380791b69213a3e3ddd873e2 (patch)
treebdc811a1b4bdbb4d9d542c0162b7d257835670b1 /src/map.cpp
parentdc4ac0b96fc11d4620f04d6068e681ab793a5d92 (diff)
downloadminetest-708f1c336ef8214e380791b69213a3e3ddd873e2.tar.gz
minetest-708f1c336ef8214e380791b69213a3e3ddd873e2.tar.bz2
minetest-708f1c336ef8214e380791b69213a3e3ddd873e2.zip
transformLiquid: small optimization and whitespace cleanup
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 9d67c8282..a540860bc 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1575,7 +1575,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
v3s16 p0 = m_transforming_liquid.pop_front();
MapNode n0 = getNodeNoEx(p0);
-
+
/*
Collect information about current node
*/
@@ -1599,18 +1599,11 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
liquid_kind = CONTENT_AIR;
break;
}
-
+
/*
Collect information about the environment
*/
- v3s16 dirs[6] = {
- v3s16( 0, 1, 0), // top
- v3s16( 0,-1, 0), // bottom
- v3s16( 1, 0, 0), // right
- v3s16(-1, 0, 0), // left
- v3s16( 0, 0, 1), // back
- v3s16( 0, 0,-1), // front
- };
+ const v3s16 *dirs = g_6dirs;
NodeNeighbor sources[6]; // surrounding sources
int num_sources = 0;
NodeNeighbor flows[6]; // surrounding flowing liquid nodes
@@ -1623,10 +1616,10 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
for (u16 i = 0; i < 6; i++) {
NeighborType nt = NEIGHBOR_SAME_LEVEL;
switch (i) {
- case 0:
+ case 1:
nt = NEIGHBOR_UPPER;
break;
- case 1:
+ case 4:
nt = NEIGHBOR_LOWER;
break;
}
@@ -1667,7 +1660,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
break;
}
}
-
+
/*
decide on the type (and possibly level) of the current node
*/
@@ -1717,13 +1710,13 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
if (!at_wall)
new_node_level -= 1;
}
-
+
if (new_node_level >= 0)
new_node_content = liquid_kind;
else
new_node_content = CONTENT_AIR;
}
-
+
/*
check if anything has changed. if not, just continue with the next node.
*/
@@ -1732,8 +1725,8 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
((n0.param2 & LIQUID_FLOW_DOWN_MASK) == LIQUID_FLOW_DOWN_MASK)
== flowing_down)))
continue;
-
-
+
+
/*
update the current node
*/
@@ -1751,7 +1744,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
MapBlock *block = getBlockNoCreateNoEx(blockpos);
if(block != NULL)
modified_blocks.insert(blockpos, block);
-
+
/*
enqueue neighbors for update if neccessary
*/