ABM and liquid overload skip
authorPerttu Ahola <celeron55@gmail.com>
Fri, 27 Jul 2012 10:45:49 +0000 (13:45 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Fri, 27 Jul 2012 10:45:49 +0000 (13:45 +0300)
src/environment.cpp
src/environment.h
src/map.cpp

index 571980498da615808c7dd14a6304d15d211e3f30..e3e6210650d9bf786b62a637eee17f50d277e7c9 100644 (file)
@@ -326,6 +326,7 @@ ServerEnvironment::ServerEnvironment(ServerMap *map, lua_State *L,
        m_emerger(emerger),
        m_random_spawn_timer(3),
        m_send_recommended_timer(0),
+       m_active_block_interval_overload_skip(0),
        m_game_time(0),
        m_game_time_fraction_counter(0)
 {
@@ -1095,7 +1096,12 @@ void ServerEnvironment::step(float dtime)
        
        const float abm_interval = 1.0;
        if(m_active_block_modifier_interval.step(dtime, abm_interval))
-       {
+       do{ // breakable
+               if(m_active_block_interval_overload_skip > 0){
+                       ScopeProfiler sp(g_profiler, "SEnv: ABM overload skips");
+                       m_active_block_interval_overload_skip--;
+                       break;
+               }
                ScopeProfiler sp(g_profiler, "SEnv: modify in blocks avg /1s", SPT_AVG);
                TimeTaker timer("modify in active blocks");
                
@@ -1128,8 +1134,9 @@ void ServerEnvironment::step(float dtime)
                        infostream<<"WARNING: active block modifiers took "
                                        <<time_ms<<"ms (longer than "
                                        <<max_time_ms<<"ms)"<<std::endl;
+                       m_active_block_interval_overload_skip = (time_ms / max_time_ms) + 1;
                }
-       }
+       }while(0);
        
        /*
                Step script environment (run global on_step())
index 6c52b003d7b34fb47286c64b3612d12d4d176e7c..bb1da2461e7baa2c55b28dbe2cce78efd5b24b0e 100644 (file)
@@ -360,6 +360,7 @@ private:
        IntervalLimiter m_active_blocks_management_interval;
        IntervalLimiter m_active_block_modifier_interval;
        IntervalLimiter m_active_blocks_nodemetadata_interval;
+       int m_active_block_interval_overload_skip;
        // Time from the beginning of the game in seconds.
        // Incremented in step().
        u32 m_game_time;
index 8aa73efbe70d60a19994388fdbcb705dd0743fcb..f8f0d017f9fb75deaadf4d250afbc7f6931e2992 100644 (file)
@@ -1636,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 >= 1000)
                        break;
                loopcount++;