Fix unnecessary block loading (#4847)
authorDániel Juhász <juhdanad@gmail.com>
Sun, 18 Dec 2016 09:20:23 +0000 (10:20 +0100)
committerZeno- <kde.psych@gmail.com>
Sun, 18 Dec 2016 09:20:23 +0000 (19:20 +1000)
This commit makes the game load blocks only if they are not in the
memory.

src/emerge.cpp

index bdb5e0729f5825f195119d3bb673b1f63fd8673b..25b2e924b03f182be0939d81c5d039ab54e098c8 100644 (file)
@@ -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))