Fix segfault when generating stuff on world boundaries
authorPerttu Ahola <celeron55@gmail.com>
Sun, 1 Jan 2012 19:01:55 +0000 (21:01 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 1 Jan 2012 19:01:55 +0000 (21:01 +0200)
src/server.cpp

index 68a84b2486521a76b1fa9762790f5ffe6a215eb5..4a0e952a8715e9eb9e5bc3993afa780b52cf7e45 100644 (file)
@@ -249,7 +249,7 @@ void * EmergeThread::Thread()
                                        t.stop(true); // Hide output
                        }
                        
-                       {
+                       do{ // enable break
                                // Lock environment again to access the map
                                JMutexAutoLock envlock(m_server->m_env_mutex);
                                
@@ -262,6 +262,11 @@ void * EmergeThread::Thread()
 
                                // Get central block
                                block = map.getBlockNoCreateNoEx(p);
+                               
+                               // If block doesn't exist, don't try doing anything with it
+                               // This happens if the block is not in generation boundaries
+                               if(!block)
+                                       break;
 
                                /*
                                        Do some post-generate stuff
@@ -285,7 +290,7 @@ void * EmergeThread::Thread()
                                
                                // Activate objects and stuff
                                m_server->m_env->activateBlock(block, 0);
-                       }
+                       }while(false);
                }
 
                if(block == NULL)