]> git.lizzy.rs Git - minetest.git/blobdiff - src/map.cpp
Make m_media_fetch_threads to contain MediaFetchThread* instead of MediaFetchThread
[minetest.git] / src / map.cpp
index 853693049cbc28ef3a79e87cf460fe75d83d5719..2845f3a67de7ed93228982da25769242ee9f5f2e 100644 (file)
@@ -1468,8 +1468,8 @@ void Map::timerUpdate(float dtime, float unload_timeout,
                        MapBlock *block = (*i);
                        
                        block->incrementUsageTimer(dtime);
-                       
-                       if(block->getUsageTimer() > unload_timeout)
+
+                       if(block->refGet() == 0 && block->getUsageTimer() > unload_timeout)
                        {
                                v3s16 p = block->getPos();
 
@@ -1621,12 +1621,6 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
        DSTACK(__FUNCTION_NAME);
        //TimeTaker timer("transformLiquids()");
 
-       /*
-               If something goes wrong, liquids are to blame
-               NOTE: Do not track liquids; it causes huge amounts of rollback log
-       */
-       //RollbackScopeActor rollback_scope(m_gamedef->rollback(), "liquid");
-
        u32 loopcount = 0;
        u32 initial_size = m_transforming_liquid.size();
 
@@ -1642,7 +1636,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
        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++;
 
@@ -1752,12 +1746,12 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
                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;
@@ -1830,21 +1824,29 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
                        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);
                MapBlock *block = getBlockNoCreateNoEx(blockpos);