Skip to content

Commit 0d35350

Browse files
committedNov 2, 2013
Fix liquid_range
* Prevent graphical glitches on old servers * Fix flowing of liquids with viscosity != 1 and range != 8 * Fix range = 0, no flowing nodes will appear
1 parent 2bf9aba commit 0d35350

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
 

‎src/content_mapblock.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
395395
l = getInteriorLight(n, 0, data);
396396
video::SColor c = MapBlock_LightColor(f.alpha, l, decode_light(f.light_source));
397397

398-
u8 range = rangelim(nodedef->get(c_flowing).liquid_range, 0, 8);
398+
u8 range = rangelim(nodedef->get(c_flowing).liquid_range, 1, 8);
399399

400400
// Neighbor liquid levels (key = relative position)
401401
// Includes current node
@@ -429,7 +429,11 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
429429
if(n2.getContent() == c_source)
430430
level = (-0.5+node_liquid_level) * BS;
431431
else if(n2.getContent() == c_flowing){
432-
u8 liquid_level = (n2.param2&LIQUID_LEVEL_MASK) - (LIQUID_LEVEL_MAX+1-range);
432+
u8 liquid_level = (n2.param2&LIQUID_LEVEL_MASK);
433+
if (liquid_level <= LIQUID_LEVEL_MAX+1-range)
434+
liquid_level = 0;
435+
else
436+
liquid_level -= (LIQUID_LEVEL_MAX+1-range);
433437
level = (-0.5 + ((float)liquid_level+ 0.5) / (float)range * node_liquid_level) * BS;
434438
}
435439

‎src/map.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -2136,6 +2136,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
21362136
content_t new_node_content;
21372137
s8 new_node_level = -1;
21382138
s8 max_node_level = -1;
2139+
u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
21392140
if ((num_sources >= 2 && nodemgr->get(liquid_kind).liquid_renewable) || liquid_type == LIQUID_SOURCE) {
21402141
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
21412142
// or the flowing alternative of the first of the surrounding sources (if it's air), so
@@ -2145,6 +2146,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
21452146
// liquid_kind is set properly, see above
21462147
new_node_content = liquid_kind;
21472148
max_node_level = new_node_level = LIQUID_LEVEL_MAX;
2149+
if (new_node_level < (LIQUID_LEVEL_MAX+1-range))
2150+
new_node_content = CONTENT_AIR;
21482151
} else {
21492152
// no surrounding sources, so get the maximum level that can flow into this node
21502153
for (u16 i = 0; i < num_flows; i++) {
@@ -2185,8 +2188,7 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
21852188
} else
21862189
new_node_level = max_node_level;
21872190

2188-
u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
2189-
if (new_node_level >= (LIQUID_LEVEL_MAX+1-range))
2191+
if (max_node_level >= (LIQUID_LEVEL_MAX+1-range))
21902192
new_node_content = liquid_kind;
21912193
else
21922194
new_node_content = CONTENT_AIR;

0 commit comments

Comments
 (0)