summaryrefslogtreecommitdiff
path: root/src/environment.cpp
diff options
context:
space:
mode:
authorAuke Kok <sofar@foo-projects.org>2016-03-01 23:14:26 -0800
committerparamat <mat.gregory@virginmedia.com>2016-03-19 17:56:26 +0000
commitc5c727d62735e334ec64f07c557a2896d6d66d9f (patch)
tree1393fff1723a92fcf522ef24fe520a9533ce0bd6 /src/environment.cpp
parentd915ca11249050fd67a87ebee16ca2b2f67f93d5 (diff)
downloadminetest-c5c727d62735e334ec64f07c557a2896d6d66d9f.tar.gz
minetest-c5c727d62735e334ec64f07c557a2896d6d66d9f.tar.bz2
minetest-c5c727d62735e334ec64f07c557a2896d6d66d9f.zip
Allow NodeTimer, ABM and block mgmt interval changes.
ABM's are hardcoded to run every 1.0s, NodeTimers are hard coded to run at every 1.0s. Block mgmt is running every 2.0sec. However, these timers can be better tuned for both higher and lower values by server owners. Some server owners want to, and have the resources to send more packets per second to clients, and so they may wish to send smaller updates sooner. Right now all ABM's are coalesced into 1.0 second intervals, resulting in large send queues to all clients. By reducing the amount of possible timers, one can get a far better response rate and lower the perception of lag. On the other side of the camp, some servers may want to increase these values, which again isn't easily doable. The global settings abm_interval and nodetimer_interval are set to current values by default. I've tested with 0.2/0.5 type values and noticed a greatly improved response and better scattering of nodetimers, as well as enjoying not faceplanting into doors with pressure plates anymore.
Diffstat (limited to 'src/environment.cpp')
-rw-r--r--src/environment.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 1de44e755..902e2bda4 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -59,6 +59,9 @@ Environment::Environment():
m_day_night_ratio_override(0.0f)
{
m_cache_enable_shaders = g_settings->getBool("enable_shaders");
+ m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval");
+ m_cache_abm_interval = g_settings->getFloat("abm_interval");
+ m_cache_nodetimer_interval = g_settings->getFloat("nodetimer_interval");
}
Environment::~Environment()
@@ -1322,9 +1325,8 @@ void ServerEnvironment::step(float dtime)
/*
Manage active block list
*/
- if(m_active_blocks_management_interval.step(dtime, 2.0))
- {
- ScopeProfiler sp(g_profiler, "SEnv: manage act. block list avg /2s", SPT_AVG);
+ if (m_active_blocks_management_interval.step(dtime, m_cache_active_block_mgmt_interval)) {
+ ScopeProfiler sp(g_profiler, "SEnv: manage act. block list avg per interval", SPT_AVG);
/*
Get player block positions
*/
@@ -1399,11 +1401,10 @@ void ServerEnvironment::step(float dtime)
/*
Mess around in active blocks
*/
- if(m_active_blocks_nodemetadata_interval.step(dtime, 1.0))
- {
- ScopeProfiler sp(g_profiler, "SEnv: mess in act. blocks avg /1s", SPT_AVG);
+ if (m_active_blocks_nodemetadata_interval.step(dtime, m_cache_nodetimer_interval)) {
+ ScopeProfiler sp(g_profiler, "SEnv: mess in act. blocks avg per interval", SPT_AVG);
- float dtime = 1.0;
+ float dtime = m_cache_nodetimer_interval;
for(std::set<v3s16>::iterator
i = m_active_blocks.m_list.begin();
@@ -1446,19 +1447,18 @@ void ServerEnvironment::step(float dtime)
}
}
- const float abm_interval = 1.0;
- if(m_active_block_modifier_interval.step(dtime, abm_interval))
+ if (m_active_block_modifier_interval.step(dtime, m_cache_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");
+ ScopeProfiler sp(g_profiler, "SEnv: modify in blocks avg per interval", SPT_AVG);
+ TimeTaker timer("modify in active blocks per interval");
// Initialize handling of ActiveBlockModifiers
- ABMHandler abmhandler(m_abms, abm_interval, this, true);
+ ABMHandler abmhandler(m_abms, m_cache_abm_interval, this, true);
for(std::set<v3s16>::iterator
i = m_active_blocks.m_list.begin();