Skip to content

Commit

Permalink
Fix unnecessary block loading (#4847)
Browse files Browse the repository at this point in the history
This commit makes the game load blocks only if they are not in the
memory.
  • Loading branch information
juhdanad authored and Zeno- committed Dec 18, 2016
1 parent 78bf7c4 commit 6d4e7f2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/emerge.cpp
Expand Up @@ -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))
Expand Down

0 comments on commit 6d4e7f2

Please sign in to comment.