aboutsummaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorJude Melton-Houghton <jwmhjwmh@gmail.com>2022-10-18 18:03:05 -0400
committerGitHub <noreply@github.com>2022-10-18 18:03:05 -0400
commitdafdb3edb4b65db144d72cd2274a657af671bdd1 (patch)
tree8234b9b09c311b05bf2a42c48ca9c1082164aae3 /src/map.cpp
parentb38ffdec279bcded98e34f5116c8d676aa9f73a7 (diff)
downloadminetest-dafdb3edb4b65db144d72cd2274a657af671bdd1.tar.xz
Check for falling `float` nodes in liquid transform (#12862)
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/map.cpp b/src/map.cpp
index f4d9871af..10a0c3543 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -533,6 +533,8 @@ void ServerMap::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
std::vector<std::pair<v3s16, MapNode> > changed_nodes;
+ std::vector<v3s16> check_for_falling;
+
u32 liquid_loop_max = g_settings->getS32("liquid_loop_max");
u32 loop_max = liquid_loop_max;
@@ -595,6 +597,7 @@ void ServerMap::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
int num_neutrals = 0;
bool flowing_down = false;
bool ignored_sources = false;
+ bool floating_node_above = false;
for (u16 i = 0; i < 6; i++) {
NeighborType nt = NEIGHBOR_SAME_LEVEL;
switch (i) {
@@ -610,7 +613,9 @@ void ServerMap::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
v3s16 npos = p0 + liquid_6dirs[i];
NodeNeighbor nb(getNode(npos), nt, npos);
const ContentFeatures &cfnb = m_nodedef->get(nb.n);
- switch (m_nodedef->get(nb.n.getContent()).liquid_type) {
+ if (nt == NEIGHBOR_UPPER && cfnb.floats)
+ floating_node_above = true;
+ switch (cfnb.liquid_type) {
case LIQUID_NONE:
if (cfnb.floodable) {
airs[num_airs++] = nb;
@@ -752,6 +757,11 @@ void ServerMap::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
== flowing_down)))
continue;
+ /*
+ check if there is a floating node above that needs to be updated.
+ */
+ if (floating_node_above && new_node_content == CONTENT_AIR)
+ check_for_falling.push_back(p0);
/*
update the current node
@@ -836,6 +846,11 @@ void ServerMap::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
m_transforming_liquid.push_back(iter);
voxalgo::update_lighting_nodes(this, changed_nodes, modified_blocks);
+
+ for (const v3s16 &p : check_for_falling) {
+ env->getScriptIface()->check_for_falling(p);
+ }
+
env->getScriptIface()->on_liquid_transformed(changed_nodes);
/* ----------------------------------------------------------------------