Collect information about current node
*/
s8 liquid_level = -1;
- u8 liquid_kind;
+ u8 liquid_kind = CONTENT_IGNORE;
LiquidType liquid_type = content_features(n0.d).liquid_type;
switch (liquid_type) {
case LIQUID_SOURCE:
int num_flows = 0;
NodeNeighbor airs[6]; // surrounding air
int num_airs = 0;
- NodeNeighbor neutrals[6]; // nodes that are solid, another kind of liquid
+ NodeNeighbor neutrals[6]; // nodes that are solid or another kind of liquid
int num_neutrals = 0;
bool flowing_down = false;
for (u16 i = 0; i < 6; i++) {
case LIQUID_NONE:
if (nb.n.d == CONTENT_AIR) {
airs[num_airs++] = nb;
- // if the current nodes happens to be a flowing node, it will start to flow down here.
+ // if the current node happens to be a flowing node, it will start to flow down here.
if (nb.t == NEIGHBOR_LOWER)
flowing_down = true;
} else {
break;
case LIQUID_FLOWING:
// if this node is not (yet) of a liquid type, choose the first liquid type we encounter
- // (while ignoring flowing liquids at the lowest level, which cannot flow into this node)
- if (liquid_kind == CONTENT_AIR && ((nb.n.param2 & LIQUID_LEVEL_MASK) > 0))
+ if (liquid_kind == CONTENT_AIR)
liquid_kind = content_features(nb.n.d).liquid_alternative_flowing;
if (content_features(nb.n.d).liquid_alternative_flowing != liquid_kind) {
neutrals[num_neutrals++] = nb;
} else {
- // order flowing neighbors by liquid level descending
- u16 insert_at = 0;
- while (insert_at < num_flows && ((flows[insert_at].n.param2 & LIQUID_LEVEL_MASK) >
- (nb.n.param2 & LIQUID_LEVEL_MASK))) {
- insert_at++;
- }
- for (u16 j = insert_at; j < num_flows; j++)
- flows[j + 1] = flows[j];
- flows[insert_at] = nb;
- num_flows++;
+ flows[num_flows++] = nb;
if (nb.t == NEIGHBOR_LOWER)
flowing_down = true;
}
n0.d = new_node_content;
if (content_features(n0.d).liquid_type == LIQUID_FLOWING) {
// set level to last 3 bits, flowing down bit to 4th bit
- n0.param2 = (flowing_down ? LIQUID_FLOW_DOWN_MASK : 0x00) | (new_node_level & LIQUID_LEVEL_MASK);
+ n0.param2 = (flowing_down ? LIQUID_FLOW_DOWN_MASK : 0x00) | (new_node_level & LIQUID_LEVEL_MASK);
} else {
n0.param2 = 0;
}
loopcount++;
//if(loopcount >= 100000)
- if(loopcount >= initial_size * 1) {
+ if(loopcount >= initial_size * 10) {
break;
}
}
for(s16 y=-1; y<=1; y++)
{
- MapBlock *block = createBlock(blockpos);
+ //MapBlock *block = createBlock(blockpos);
+ // 1) get from memory, 2) load from disk
+ MapBlock *block = emergeBlock(blockpos, false);
+ // 3) create a blank one
+ if(block == NULL)
+ block = createBlock(blockpos);
- // Lighting won't be calculated
+ // Lighting will not be valid after make_chunk is called
block->setLightingExpired(true);
// Lighting will be calculated
//block->setLightingExpired(false);
TimeTaker t("finishBlockMake lighting update");
core::map<v3s16, MapBlock*> lighting_update_blocks;
+#if 1
// Center block
lighting_update_blocks.insert(block->getPos(), block);
- #if 0
+#endif
+#if 0
// All modified blocks
+ // NOTE: Should this be done? If this is not done, then the lighting
+ // of the others will be updated in a different place, one by one, i
+ // think... or they might not? Well, at least they are left marked as
+ // "lighting expired"; it seems that is not handled at all anywhere,
+ // so enabling this will slow it down A LOT because otherwise it
+ // would not do this at all. This causes the black trees.
for(core::map<v3s16, MapBlock*>::Iterator
i = changed_blocks.getIterator();
i.atEnd() == false; i++)
lighting_update_blocks.insert(i.getNode()->getKey(),
i.getNode()->getValue());
}
- #endif
+#endif
updateLighting(lighting_update_blocks, changed_blocks);
if(enable_mapgen_debug_info == false)