MapBlock *block = (*i);
block->incrementUsageTimer(dtime);
-
- if(block->getUsageTimer() > unload_timeout)
+
+ if(block->refGet() == 0 && block->getUsageTimer() > unload_timeout)
{
v3s16 p = block->getPos();
DSTACK(__FUNCTION_NAME);
//TimeTaker timer("transformLiquids()");
- /*
- If something goes wrong, liquids are to blame
- */
- RollbackScopeActor rollback_scope(m_gamedef->rollback(), "liquid");
-
u32 loopcount = 0;
u32 initial_size = m_transforming_liquid.size();
while(m_transforming_liquid.size() != 0)
{
// This should be done here so that it is done when continue is used
- if(loopcount >= initial_size * 3)
+ if(loopcount >= initial_size || loopcount >= 10000)
break;
loopcount++;
content_t new_node_content;
s8 new_node_level = -1;
s8 max_node_level = -1;
- if (num_sources >= 2 || liquid_type == LIQUID_SOURCE) {
+ if ((num_sources >= 2 && nodemgr->get(liquid_kind).liquid_renewable) || liquid_type == LIQUID_SOURCE) {
// liquid_kind will be set to either the flowing alternative of the node (if it's a liquid)
// or the flowing alternative of the first of the surrounding sources (if it's air), so
// it's perfectly safe to use liquid_kind here to determine the new node content.
new_node_content = nodemgr->getId(nodemgr->get(liquid_kind).liquid_alternative_source);
- } else if (num_sources == 1 && sources[0].t != NEIGHBOR_LOWER) {
+ } else if (num_sources >= 1 && sources[0].t != NEIGHBOR_LOWER) {
// liquid_kind is set properly, see above
new_node_content = liquid_kind;
max_node_level = new_node_level = LIQUID_LEVEL_MAX;
n0.param2 = ~(LIQUID_LEVEL_MASK | LIQUID_FLOW_DOWN_MASK);
}
n0.setContent(new_node_content);
-
- // Get old node for rollback
- RollbackNode rollback_oldnode(this, p0, m_gamedef);
-
- // Set node
- setNode(p0, n0);
- // Report for rollback
- if(m_gamedef->rollback())
- {
+ // Find out whether there is a suspect for this action
+ std::string suspect;
+ if(m_gamedef->rollback()){
+ suspect = m_gamedef->rollback()->getSuspect(p0, 83, 1);
+ }
+
+ if(!suspect.empty()){
+ // Blame suspect
+ RollbackScopeActor rollback_scope(m_gamedef->rollback(), suspect, true);
+ // Get old node for rollback
+ RollbackNode rollback_oldnode(this, p0, m_gamedef);
+ // Set node
+ setNode(p0, n0);
+ // Report
RollbackNode rollback_newnode(this, p0, m_gamedef);
RollbackAction action;
action.setSetNode(p0, rollback_oldnode, rollback_newnode);
m_gamedef->rollback()->reportAction(action);
+ } else {
+ // Set node
+ setNode(p0, n0);
}
v3s16 blockpos = getNodeBlockPos(p0);