Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix crash when exiting server during running mapgen
easily reproducible with a high num_emerge_threads and /emergeblocks
  • Loading branch information
sfan5 committed May 5, 2020
1 parent f3e87c5 commit cb159f8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/emerge.cpp
Expand Up @@ -255,8 +255,9 @@ Mapgen *EmergeManager::getCurrentMapgen()
return nullptr;

for (u32 i = 0; i != m_threads.size(); i++) {
if (m_threads[i]->isCurrentThread())
return m_threads[i]->m_mapgen;
EmergeThread *t = m_threads[i];
if (t->isRunning() && t->isCurrentThread())
return t->m_mapgen;
}

return nullptr;
Expand Down Expand Up @@ -642,8 +643,7 @@ MapBlock *EmergeThread::finishGen(v3s16 pos, BlockMakeData *bmdata,
/*
Clear generate notifier events
*/
Mapgen *mg = m_emerge->getCurrentMapgen();
mg->gennotify.clearEvents();
m_mapgen->gennotify.clearEvents();

EMERGE_DBG_OUT("ended up with: " << analyze_block(block));

Expand Down

0 comments on commit cb159f8

Please sign in to comment.