diff options
author | Jude Melton-Houghton <jwmhjwmh@gmail.com> | 2022-11-27 15:55:10 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-27 15:55:10 -0500 |
commit | 3fd5bff128cacb068c0758d0b33b425dc88beed7 (patch) | |
tree | 9e63bba68cc14bbe1d62feb25648612fad0ba886 | |
parent | 40a45b8c995e12778c4478011583c08447da88eb (diff) | |
download | minetest-3fd5bff128cacb068c0758d0b33b425dc88beed7.tar.xz |
Abort active ABM iteration when content changes (#12998)
-rw-r--r-- | src/serverenvironment.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index 9a58074b1..045f05994 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -888,7 +888,7 @@ public: for(p0.Y=0; p0.Y<MAP_BLOCKSIZE; p0.Y++) for(p0.Z=0; p0.Z<MAP_BLOCKSIZE; p0.Z++) { - const MapNode &n = block->getNodeNoCheck(p0); + MapNode n = block->getNodeNoCheck(p0); content_t c = n.getContent(); // Cache content types as we go if (!block->contents_cached && !block->do_not_cache_contents) { @@ -950,6 +950,11 @@ public: active_object_count = countObjects(block, map, active_object_count_wider); m_env->m_added_objects = 0; } + + // Update and check node after possible modification + n = block->getNodeNoCheck(p0); + if (n.getContent() != c) + break; } } block->contents_cached = !block->do_not_cache_contents; @@ -1436,6 +1441,9 @@ void ServerEnvironment::step(float dtime) ScopeProfiler sp(g_profiler, "SEnv: modify in blocks avg per interval", SPT_AVG); TimeTaker timer("modify in active blocks per interval"); + // Shuffle to prevent persistent artifacts of ordering + std::shuffle(m_abms.begin(), m_abms.end(), m_rgen); + // Initialize handling of ActiveBlockModifiers ABMHandler abmhandler(m_abms, m_cache_abm_interval, this, true); |