diff options
author | Dániel Juhász <juhdanad@gmail.com> | 2016-12-18 10:20:23 +0100 |
---|---|---|
committer | Zeno- <kde.psych@gmail.com> | 2016-12-18 19:20:23 +1000 |
commit | 6d4e7f223a8d79d820546ad750448ee4ecbb1e55 (patch) | |
tree | b3348b833f9720c9c5ff5cdd9b826b1ea93a10b8 | |
parent | 78bf7c46e5fe8845e9a9f65b98db32b0ff398ad3 (diff) | |
download | minetest-6d4e7f223a8d79d820546ad750448ee4ecbb1e55.tar.gz minetest-6d4e7f223a8d79d820546ad750448ee4ecbb1e55.tar.bz2 minetest-6d4e7f223a8d79d820546ad750448ee4ecbb1e55.zip |
Fix unnecessary block loading (#4847)
This commit makes the game load blocks only if they are not in the
memory.
-rw-r--r-- | src/emerge.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/emerge.cpp b/src/emerge.cpp index bdb5e0729..25b2e924b 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -508,13 +508,15 @@ EmergeAction EmergeThread::getBlockOrStartGen( // 1). Attempt to fetch block from memory *block = m_map->getBlockNoCreateNoEx(pos); - if (*block && !(*block)->isDummy() && (*block)->isGenerated()) - return EMERGE_FROM_MEMORY; - - // 2). Attempt to load block from disk - *block = m_map->loadBlock(pos); - if (*block && (*block)->isGenerated()) - return EMERGE_FROM_DISK; + if (*block && !(*block)->isDummy()) { + if ((*block)->isGenerated()) + return EMERGE_FROM_MEMORY; + } else { + // 2). Attempt to load block from disk if it was not in the memory + *block = m_map->loadBlock(pos); + if (*block && (*block)->isGenerated()) + return EMERGE_FROM_DISK; + } // 3). Attempt to start generation if (allow_gen && m_map->initBlockMake(pos, bmdata)) |