Fix liquids refusing to flow in X+ or Z+ in some cases (#9874)
Applies when a different: - falling liquid is neighboring - liquid is belowmaster
parent
ba553e22e4
commit
58f523e363
29
src/map.cpp
29
src/map.cpp
|
@ -478,6 +478,16 @@ void Map::PrintInfo(std::ostream &out)
|
||||||
|
|
||||||
#define WATER_DROP_BOOST 4
|
#define WATER_DROP_BOOST 4
|
||||||
|
|
||||||
|
const static v3s16 liquid_6dirs[6] = {
|
||||||
|
// order: upper before same level before lower
|
||||||
|
v3s16( 0, 1, 0),
|
||||||
|
v3s16( 0, 0, 1),
|
||||||
|
v3s16( 1, 0, 0),
|
||||||
|
v3s16( 0, 0,-1),
|
||||||
|
v3s16(-1, 0, 0),
|
||||||
|
v3s16( 0,-1, 0)
|
||||||
|
};
|
||||||
|
|
||||||
enum NeighborType : u8 {
|
enum NeighborType : u8 {
|
||||||
NEIGHBOR_UPPER,
|
NEIGHBOR_UPPER,
|
||||||
NEIGHBOR_SAME_LEVEL,
|
NEIGHBOR_SAME_LEVEL,
|
||||||
|
@ -587,7 +597,6 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
|
||||||
/*
|
/*
|
||||||
Collect information about the environment
|
Collect information about the environment
|
||||||
*/
|
*/
|
||||||
const v3s16 *dirs = g_6dirs;
|
|
||||||
NodeNeighbor sources[6]; // surrounding sources
|
NodeNeighbor sources[6]; // surrounding sources
|
||||||
int num_sources = 0;
|
int num_sources = 0;
|
||||||
NodeNeighbor flows[6]; // surrounding flowing liquid nodes
|
NodeNeighbor flows[6]; // surrounding flowing liquid nodes
|
||||||
|
@ -601,16 +610,16 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
|
||||||
for (u16 i = 0; i < 6; i++) {
|
for (u16 i = 0; i < 6; i++) {
|
||||||
NeighborType nt = NEIGHBOR_SAME_LEVEL;
|
NeighborType nt = NEIGHBOR_SAME_LEVEL;
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 1:
|
case 0:
|
||||||
nt = NEIGHBOR_UPPER;
|
nt = NEIGHBOR_UPPER;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 5:
|
||||||
nt = NEIGHBOR_LOWER;
|
nt = NEIGHBOR_LOWER;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
v3s16 npos = p0 + dirs[i];
|
v3s16 npos = p0 + liquid_6dirs[i];
|
||||||
NodeNeighbor nb(getNode(npos), nt, npos);
|
NodeNeighbor nb(getNode(npos), nt, npos);
|
||||||
const ContentFeatures &cfnb = m_nodedef->get(nb.n);
|
const ContentFeatures &cfnb = m_nodedef->get(nb.n);
|
||||||
switch (m_nodedef->get(nb.n.getContent()).liquid_type) {
|
switch (m_nodedef->get(nb.n.getContent()).liquid_type) {
|
||||||
|
@ -646,14 +655,18 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks,
|
||||||
neutrals[num_neutrals++] = nb;
|
neutrals[num_neutrals++] = nb;
|
||||||
} else {
|
} else {
|
||||||
// Do not count bottom source, it will screw things up
|
// Do not count bottom source, it will screw things up
|
||||||
if(dirs[i].Y != -1)
|
if(nt != NEIGHBOR_LOWER)
|
||||||
sources[num_sources++] = nb;
|
sources[num_sources++] = nb;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LIQUID_FLOWING:
|
case LIQUID_FLOWING:
|
||||||
// if this node is not (yet) of a liquid type, choose the first liquid type we encounter
|
if (nb.t != NEIGHBOR_SAME_LEVEL ||
|
||||||
if (liquid_kind == CONTENT_AIR)
|
(nb.n.param2 & LIQUID_FLOW_DOWN_MASK) != LIQUID_FLOW_DOWN_MASK) {
|
||||||
liquid_kind = cfnb.liquid_alternative_flowing_id;
|
// if this node is not (yet) of a liquid type, choose the first liquid type we encounter
|
||||||
|
// but exclude falling liquids on the same level, they cannot flow here anyway
|
||||||
|
if (liquid_kind == CONTENT_AIR)
|
||||||
|
liquid_kind = cfnb.liquid_alternative_flowing_id;
|
||||||
|
}
|
||||||
if (cfnb.liquid_alternative_flowing_id != liquid_kind) {
|
if (cfnb.liquid_alternative_flowing_id != liquid_kind) {
|
||||||
neutrals[num_neutrals++] = nb;
|
neutrals[num_neutrals++] = nb;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue