Skip to content

Commit 413f0d0

Browse files
PilzAdamRealBadAngel
authored andcommittedJul 20, 2013
Add liquid_range to nodedef
1 parent cba90d4 commit 413f0d0

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed
 

‎doc/lua_api.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,7 @@ Node definition (register_node)
19471947
liquid_alternative_source = "", -- Source version of flowing liquid
19481948
liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
19491949
liquid_renewable = true, -- Can new liquid source be created by placing
1950+
liquid_range = 8, -- number of flowing nodes arround source (max. 8)
19501951
drowning = true, -- Player will drown in these
19511952
two or more sources nearly?
19521953
light_source = 0, -- Amount of light emitted by node

‎src/content_mapblock.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ 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);
399+
398400
// Neighbor liquid levels (key = relative position)
399401
// Includes current node
400402
std::map<v3s16, f32> neighbor_levels;
@@ -426,9 +428,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
426428

427429
if(n2.getContent() == c_source)
428430
level = (-0.5+node_liquid_level) * BS;
429-
else if(n2.getContent() == c_flowing)
430-
level = (-0.5 + ((float)(n2.param2&LIQUID_LEVEL_MASK)
431-
+ 0.5) / (float)LIQUID_LEVEL_SOURCE * node_liquid_level) * BS;
431+
else if(n2.getContent() == c_flowing){
432+
u8 liquid_level = (n2.param2&LIQUID_LEVEL_MASK) - (LIQUID_LEVEL_MAX+1-range);
433+
level = (-0.5 + ((float)liquid_level+ 0.5) / (float)range * node_liquid_level) * BS;
434+
}
432435

433436
// Check node above neighbor.
434437
// NOTE: This doesn't get executed if neighbor

‎src/map.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks)
21662166
} else
21672167
new_node_level = max_node_level;
21682168

2169-
if (new_node_level >= 0)
2169+
u8 range = rangelim(nodemgr->get(liquid_kind).liquid_range, 0, LIQUID_LEVEL_MAX+1);
2170+
if (new_node_level >= (LIQUID_LEVEL_MAX+1-range))
21702171
new_node_content = liquid_kind;
21712172
else
21722173
new_node_content = CONTENT_AIR;

‎src/nodedef.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ void ContentFeatures::reset()
213213
liquid_alternative_source = "";
214214
liquid_viscosity = 0;
215215
liquid_renewable = true;
216+
liquid_range = LIQUID_LEVEL_MAX+1;
216217
drowning = true;
217218
light_source = 0;
218219
damage_per_second = 0;
@@ -284,6 +285,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
284285
// the protocol version
285286
writeU8(os, drowning);
286287
writeU8(os, leveled);
288+
writeU8(os, liquid_range);
287289
}
288290

289291
void ContentFeatures::deSerialize(std::istream &is)
@@ -350,6 +352,7 @@ void ContentFeatures::deSerialize(std::istream &is)
350352
// otherwise changes the protocol version
351353
drowning = readU8(is);
352354
leveled = readU8(is);
355+
liquid_range = readU8(is);
353356
}catch(SerializationError &e) {};
354357
}
355358

‎src/nodedef.h

+2
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ struct ContentFeatures
224224
u8 liquid_viscosity;
225225
// Is liquid renewable (new liquid source will be created between 2 existing)
226226
bool liquid_renewable;
227+
// Number of flowing liquids surrounding source
228+
u8 liquid_range;
227229
bool drowning;
228230
// Amount of light the node emits
229231
u8 light_source;

‎src/script/common/c_content.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ ContentFeatures read_content_features(lua_State *L, int index)
391391
// the slowest possible
392392
f.liquid_viscosity = getintfield_default(L, index,
393393
"liquid_viscosity", f.liquid_viscosity);
394+
f.liquid_range = getintfield_default(L, index,
395+
"liquid_range", f.liquid_range);
394396
f.leveled = getintfield_default(L, index, "leveled", f.leveled);
395397

396398
getboolfield(L, index, "liquid_renewable", f.liquid_renewable);

0 commit comments

Comments
 (0)
Please sign in to comment.