aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/emerge.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/emerge.cpp b/src/emerge.cpp
index be64d744a..619b1fa8e 100644
--- a/src/emerge.cpp
+++ b/src/emerge.cpp
@@ -633,12 +633,14 @@ MapBlock *EmergeThread::finishGen(v3s16 pos, BlockMakeData *bmdata,
m_server->setAsyncFatalError(e);
}
+ EMERGE_DBG_OUT("ended up with: " << analyze_block(block));
+
/*
- Clear generate notifier events
+ Clear mapgen state
*/
+ assert(!m_mapgen->generating);
m_mapgen->gennotify.clearEvents();
-
- EMERGE_DBG_OUT("ended up with: " << analyze_block(block));
+ m_mapgen->vm = nullptr;
/*
Activate the block
@@ -654,19 +656,19 @@ void *EmergeThread::run()
BEGIN_DEBUG_EXCEPTION_HANDLER
v3s16 pos;
+ std::map<v3s16, MapBlock *> modified_blocks;
- m_map = (ServerMap *)&(m_server->m_env->getMap());
+ m_map = &m_server->m_env->getServerMap();
m_emerge = m_server->m_emerge;
m_mapgen = m_emerge->m_mapgens[id];
enable_mapgen_debug_info = m_emerge->enable_mapgen_debug_info;
try {
while (!stopRequested()) {
- std::map<v3s16, MapBlock *> modified_blocks;
BlockEmergeData bedata;
BlockMakeData bmdata;
EmergeAction action;
- MapBlock *block;
+ MapBlock *block = nullptr;
if (!popBlockEmerge(&pos, &bedata)) {
m_queue_event.wait();
@@ -689,6 +691,8 @@ void *EmergeThread::run()
}
block = finishGen(pos, &bmdata, &modified_blocks);
+ if (!block)
+ action = EMERGE_ERRORED;
}
runCompletionCallbacks(pos, action, bedata.callbacks);
@@ -698,6 +702,7 @@ void *EmergeThread::run()
if (!modified_blocks.empty())
m_server->SetBlocksNotSent(modified_blocks);
+ modified_blocks.clear();
}
} catch (VersionMismatchException &e) {
std::ostringstream err;