Skip to content

Instantly share code, notes, and snippets.

@sapier
Created July 6, 2014 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sapier/3db8d19cfac358446294 to your computer and use it in GitHub Desktop.
Save sapier/3db8d19cfac358446294 to your computer and use it in GitHub Desktop.
@@ -429,7 +429,7 @@ bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
BlockMakeData *data, bool allow_gen) {
v2s16 p2d(p.X, p.Z);
//envlock: usually takes <=1ms, sometimes 90ms or ~400ms to acquire
- JMutexAutoLock envlock(m_server->m_env_mutex);
+ //JMutexAutoLock envlock(m_server->m_env_mutex);
// Load sector if it isn't loaded
if (map->getSectorNoGenerateNoEx(p2d) == NULL)
@@ -437,11 +437,27 @@ bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
// Attempt to load block
MapBlock *block = map->getBlockNoCreateNoEx(p);
- if (!block || block->isDummy() || !block->isGenerated()) {
+ bool isdummy = false;
+ bool isgenerated = false;
+ if (block) {
+ isdummy = block->isDummy();
+ isgenerated = block->isGenerated();
+ }
+ if (!block || isdummy || !isgenerated) {
EMERGE_DBG_OUT("not in memory, attempting to load from disk");
+ std::stringstream out;
+ out << "Pos: " << PP(p) << " Block not found in memory: "
+ "block: " << (block != 0 ? "true" : "false")
+ << " isDummy=" << (isdummy ? "true" : "false")
+ << " isGenerated=" << ( isgenerated ? "true" : "false") << std::endl;
+ errorstream << out.str();
block = map->loadBlock(p);
if (block && block->isGenerated())
map->prepareBlock(block);
+ out.clear();
+ out << "Pos: " << PP(p) << "block: " << (block != 0 ? "true" : "false")
+ << " isGenerated=" << ( isgenerated ? "true" : "false") << std::endl;
+ errorstream << out.str();
}
// If could not load and allowed to generate,
@@ -476,10 +492,12 @@ void *EmergeThread::Thread() {
while (!StopRequested())
try {
+
if (!popBlockEmerge(&p, &flags)) {
qevent.wait();
continue;
}
+ JMutexAutoLock envlock(m_server->m_env_mutex);
last_tried_pos = p;
if (blockpos_over_limit(p))
@@ -509,7 +527,7 @@ void *EmergeThread::Thread() {
{
//envlock: usually 0ms, but can take either 30 or 400ms to acquire
- JMutexAutoLock envlock(m_server->m_env_mutex);
+ //JMutexAutoLock envlock(m_server->m_env_mutex);
ScopeProfiler sp(g_profiler, "EmergeThread: after "
"Mapgen::makeChunk (envlock)", SPT_AVG);
@@ -547,8 +565,12 @@ void *EmergeThread::Thread() {
Set sent status of modified blocks on clients
*/
// Add the originally fetched block to the modified list
- if (block)
+ if ( block && block->isGenerated()) {
modified_blocks[p] = block;
+ }
+ else {
+ errorstream << "Block not generated after emerge?! BlockPos: " << PP(p) << std::endl;
+ }
if (modified_blocks.size() > 0) {
m_server->SetBlocksNotSent(modified_blocks);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment