summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorMillersMan <millersman@users.noreply.github.com>2016-11-27 21:46:14 +0100
committerparamat <mat.gregory@virginmedia.com>2016-12-07 03:54:32 +0000
commitcc36f5e99ae46cf2fd370dde8311f139169a4c43 (patch)
treef1f82971a48ff9570b6601e301ce18a1e7b7c331 /src/map.cpp
parent2829742ae8869276f000bdb64a9f14977e70038b (diff)
downloadminetest-cc36f5e99ae46cf2fd370dde8311f139169a4c43.tar.gz
minetest-cc36f5e99ae46cf2fd370dde8311f139169a4c43.tar.bz2
minetest-cc36f5e99ae46cf2fd370dde8311f139169a4c43.zip
Liquids: Preserve flow state if 'ignore' is a neighbour
Prevent waterfalls from falling down or streams from flowing away when the source node is in an unloaded block - Nodes near a CONTENT_IGNORE node will be interpreted as if the ignored node is a liquid node that just supports the current state of the nodes in question.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/map.cpp b/src/map.cpp
index 3c135cd48..28d650276 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1309,6 +1309,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks)
NodeNeighbor neutrals[6]; // nodes that are solid or another kind of liquid
int num_neutrals = 0;
bool flowing_down = false;
+ bool ignored_sources = false;
for (u16 i = 0; i < 6; i++) {
NeighborType nt = NEIGHBOR_SAME_LEVEL;
switch (i) {
@@ -1336,10 +1337,15 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks)
flowing_down = true;
} else {
neutrals[num_neutrals++] = nb;
- // If neutral below is ignore prevent water spreading outwards
- if (nb.t == NEIGHBOR_LOWER &&
- nb.n.getContent() == CONTENT_IGNORE)
- flowing_down = true;
+ if (nb.n.getContent() == CONTENT_IGNORE) {
+ // If node below is ignore prevent water from
+ // spreading outwards and otherwise prevent from
+ // flowing away as ignore node might be the source
+ if (nb.t == NEIGHBOR_LOWER)
+ flowing_down = true;
+ else
+ ignored_sources = true;
+ }
}
break;
case LIQUID_SOURCE:
@@ -1392,6 +1398,11 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks)
new_node_content = liquid_kind;
else
new_node_content = floodable_node;
+ } else if (ignored_sources && liquid_level >= 0) {
+ // Maybe there are neighbouring sources that aren't loaded yet
+ // so prevent flowing away.
+ new_node_level = liquid_level;
+ new_node_content = liquid_kind;
} else {
// no surrounding sources, so get the maximum level that can flow into this node
for (u16 i = 0; i < num_flows; i++) {