diff options
author | Lars <larsh@apache.org> | 2020-08-12 16:02:07 -0700 |
---|---|---|
committer | lhofhansl <larsh@apache.org> | 2020-08-18 16:04:32 -0700 |
commit | 649211bf272df2dc7057347992c2653cf1c3a6fb (patch) | |
tree | 765e0d88b305f802c3f59448df376bfe570024ad | |
parent | 7242de1d4bdb4cc98fce723044b2c8c5d9861c8b (diff) | |
download | minetest-649211bf272df2dc7057347992c2653cf1c3a6fb.tar.gz minetest-649211bf272df2dc7057347992c2653cf1c3a6fb.tar.bz2 minetest-649211bf272df2dc7057347992c2653cf1c3a6fb.zip |
Allow the ABM time budget to be configurable.
-rw-r--r-- | builtin/settingtypes.txt | 4 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 1 | ||||
-rw-r--r-- | src/environment.cpp | 1 | ||||
-rw-r--r-- | src/environment.h | 1 | ||||
-rw-r--r-- | src/serverenvironment.cpp | 4 |
5 files changed, 9 insertions, 2 deletions
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 1f71e4cb9..af4dc1def 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -1282,6 +1282,10 @@ active_block_mgmt_interval (Active block management interval) float 2.0 # Length of time between Active Block Modifier (ABM) execution cycles abm_interval (ABM interval) float 1.0 +# The time budget allowed for ABMs to execute on each step +# (as a fraction of the ABM Interval) +abm_time_budget (ABM time budget) float 0.2 0.1 0.9 + # Length of time between NodeTimer execution cycles nodetimer_interval (NodeTimer interval) float 0.2 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 8b6de0412..87c272630 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -403,6 +403,7 @@ void set_default_settings(Settings *settings) settings->setDefault("dedicated_server_step", "0.09"); settings->setDefault("active_block_mgmt_interval", "2.0"); settings->setDefault("abm_interval", "1.0"); + settings->setDefault("abm_time_budget", "0.2"); settings->setDefault("nodetimer_interval", "0.2"); settings->setDefault("ignore_world_load_errors", "false"); settings->setDefault("remote_media", ""); diff --git a/src/environment.cpp b/src/environment.cpp index 6751f39e4..06f2b8bf9 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -36,6 +36,7 @@ Environment::Environment(IGameDef *gamedef): 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"); + m_cache_abm_time_budget = g_settings->getFloat("abm_time_budget"); m_time_of_day = g_settings->getU32("world_start_time"); m_time_of_day_f = (float)m_time_of_day / 24000.0f; diff --git a/src/environment.h b/src/environment.h index 91c33ba15..b4884fdb3 100644 --- a/src/environment.h +++ b/src/environment.h @@ -147,6 +147,7 @@ protected: float m_cache_active_block_mgmt_interval; float m_cache_abm_interval; float m_cache_nodetimer_interval; + float m_cache_abm_time_budget; IGameDef *m_gamedef; diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index ad2ffc9a4..320042e19 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -1354,8 +1354,8 @@ void ServerEnvironment::step(float dtime) std::shuffle(output.begin(), output.end(), m_rgen); int i = 0; - // The time budget for ABMs is 20%. - u32 max_time_ms = m_cache_abm_interval * 1000 / 5; + // determine the time budget for ABMs + u32 max_time_ms = m_cache_abm_interval * 1000 * m_cache_abm_time_budget; for (const v3s16 &p : output) { MapBlock *block = m_map->getBlockNoCreateNoEx(p); if (!block) |