- recursion_depth++;
-
- v3s16 p;
- bool from_ocean = false;
-
- // Randomize horizontal order
- static s32 cs = 0;
- if(cs < 3)
- cs++;
- else
- cs = 0;
- s16 s1 = (cs & 1) ? 1 : -1;
- s16 s2 = (cs & 2) ? 1 : -1;
- //dstream<<"s1="<<s1<<", s2="<<s2<<std::endl;
-
- {
- TimeTaker timer1("flowWater pre", g_device, &flowwater_pre_time);
-
- // Load neighboring nodes
- emerge(VoxelArea(removed_pos - v3s16(1,1,1), removed_pos + v3s16(1,1,1)), 4);
-
- // Ignore incorrect removed_pos
- {
- u8 f = m_flags[m_area.index(removed_pos)];
- // Ignore inexistent or checked node
- if(f & (VOXELFLAG_INEXISTENT | VOXELFLAG_CHECKED))
- return false;
- MapNode &n = m_data[m_area.index(removed_pos)];
- // Water can move only to air
- if(n.d != MATERIAL_AIR)
- return false;
- }
-
- s32 i;
- for(i=0; i<6; i++)
- {
- p = removed_pos + v3s16(s1*dirs[i].X, dirs[i].Y, s2*dirs[i].Z);
-
- u8 f = m_flags[m_area.index(p)];
- // Inexistent or checked nodes can't move
- if(f & (VOXELFLAG_INEXISTENT | VOXELFLAG_CHECKED))
- continue;
- MapNode &n = m_data[m_area.index(p)];
- // Only liquid nodes can move
- if(material_liquid(n.d) == false)
- continue;
- // If block is at top, select it always
- if(i == 0)
- {
- break;
- }
- // If block is at bottom, select it if it has enough pressure
- if(i == 5)
- {
- //if(n.pressure >= PRESERVE_WATER_VOLUME ? 3 : 2)
- if(n.pressure >= 3)
- break;
- continue;
- }
- // Else block is at some side. Select it if it has enough pressure
- //if(n.pressure >= PRESERVE_WATER_VOLUME ? 2 : 1)
- if(n.pressure >= 2)
- {
- break;
- }
- }