Misc. cleanup and minor fixes
authorkwolekr <mirrorisim@gmail.com>
Sun, 17 Feb 2013 07:46:08 +0000 (02:46 -0500)
committerkwolekr <mirrorisim@gmail.com>
Tue, 26 Feb 2013 04:08:33 +0000 (23:08 -0500)
src/emerge.cpp
src/emerge.h
src/map.cpp
src/map.h
src/mapgen_v6.cpp

index ee6650f9cd53ae4a4f5304601641abfe8a7e5962..ac654f36811f770ed65c922e5bde96b197e87dc2 100644 (file)
@@ -48,6 +48,8 @@ EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef) {
        this->biomedef = bdef ? bdef : new BiomeDefManager(gamedef);
        this->params   = NULL;
        
+       mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
+       
        qlimit_total    = g_settings->getU16("emergequeue_limit_total");
        qlimit_diskonly = g_settings->getU16("emergequeue_limit_diskonly");
        qlimit_generate = g_settings->getU16("emergequeue_limit_generate");
@@ -209,7 +211,7 @@ u32 EmergeManager::getBlockSeed(v3s16 p) {
        return (u32)(params->seed & 0xFFFFFFFF) +
                p.Z * 38134234 +
                p.Y * 42123 +
-               p.Y * 23;
+               p.X * 23;
 }
 
 
@@ -331,10 +333,6 @@ private:
 
 #if 1
 
-#define EMERGE_DBG_OUT(x) \
-       { if (enable_mapgen_debug_info) \
-       infostream << "EmergeThread: " x << std::endl; }
-
 bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b, 
                                                                        BlockMakeData *data, bool allow_gen) {
        v2s16 p2d(p.X, p.Z);
@@ -356,8 +354,8 @@ bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
        // start generation inside this same envlock
        if (allow_gen && (block == NULL || !block->isGenerated())) {
                EMERGE_DBG_OUT("generating");
-               map->initBlockMake(data, p);
-               return true;
+               *b = block;
+               return map->initBlockMake(data, p);
        }
        
        *b = block;
@@ -377,14 +375,14 @@ void *EmergeThread::Thread() {
        
        map    = (ServerMap *)&(m_server->m_env->getMap());
        emerge = m_server->m_emerge;
-       mapgen = emerge->mapgen[id]; //emerge->getMapgen();
+       mapgen = emerge->mapgen[id];
+       enable_mapgen_debug_info = emerge->mapgen_debug_info;
        
        while (getRun())
        try {
-               while (!popBlockEmerge(&p, &flags)) {
+               if (!popBlockEmerge(&p, &flags)) {
                        qevent.wait();
-                       if (!getRun())
-                               goto exit_emerge_loop;
+                       continue;
                }
 
                last_tried_pos = p;
@@ -489,7 +487,6 @@ void *EmergeThread::Thread() {
        }
        
        END_DEBUG_EXCEPTION_HANDLER(errorstream)
-exit_emerge_loop:
        log_deregister_thread();
        return NULL;
 }
index 7e0cc4850b39f633b96c511b9e83f5edd6fc1144..e5014df589e416555db47dc5b4a2ed36da58bf11 100644 (file)
@@ -7,6 +7,10 @@
 
 #define BLOCK_EMERGE_ALLOWGEN (1<<0)
 
+#define EMERGE_DBG_OUT(x) \
+       { if (enable_mapgen_debug_info) \
+       infostream << "EmergeThread: " x << std::endl; }
+
 class Mapgen;
 class MapgenParams;
 class MapgenFactory;
@@ -18,7 +22,6 @@ class ManualMapVoxelManipulator;
 #include "server.h"
 
 struct BlockMakeData {
-       bool no_op;
        ManualMapVoxelManipulator *vmanip;
        u64 seed;
        v3s16 blockpos_min;
@@ -28,7 +31,6 @@ struct BlockMakeData {
        INodeDefManager *nodedef;
 
        BlockMakeData():
-               no_op(false),
                vmanip(NULL),
                seed(0),
                nodedef(NULL)
@@ -51,6 +53,7 @@ public:
        
        //settings
        MapgenParams *params;
+       bool mapgen_debug_info;
        u16 qlimit_total;
        u16 qlimit_diskonly;
        u16 qlimit_generate;
@@ -104,7 +107,6 @@ public:
                mapgen(NULL),
                id(ethreadid)
        {
-               enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
        }
 
        void *Thread();
index a8928d86465d28146d05a4be372c153d6a839571..3f2f8d1d35c034e2da9640c2584a077c920f8e79 100644 (file)
@@ -2143,14 +2143,10 @@ ServerMap::~ServerMap()
 #endif
 }
 
-void ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
+bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
 {
-       bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
-       if(enable_mapgen_debug_info)
-               infostream<<"initBlockMake(): "
-                               <<"("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<") - "
-                               <<"("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<")"
-                               <<std::endl;
+       bool enable_mapgen_debug_info = m_emerge->mapgen_debug_info;
+       EMERGE_DBG_OUT("initBlockMake(): " PP(blockpos) " - " PP(blockpos));
 
        //s16 chunksize = 3;
        //v3s16 chunk_offset(-1,-1,-1);
@@ -2170,12 +2166,8 @@ void ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
        // Do nothing if not inside limits (+-1 because of neighbors)
        if(blockpos_over_limit(blockpos_min - extra_borders) ||
                blockpos_over_limit(blockpos_max + extra_borders))
-       {
-               data->no_op = true;
-               return;
-       }
+               return false;
 
-       data->no_op = false;
        data->seed = m_seed;
        data->blockpos_min = blockpos_min;
        data->blockpos_max = blockpos_max;
@@ -2263,6 +2255,7 @@ void ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
        }
 
        // Data is ready now.
+       return true;
 }
 
 MapBlock* ServerMap::finishBlockMake(BlockMakeData *data,
@@ -2277,13 +2270,7 @@ MapBlock* ServerMap::finishBlockMake(BlockMakeData *data,
 
        v3s16 extra_borders(1,1,1);
 
-       if(data->no_op)
-       {
-               //infostream<<"finishBlockMake(): no-op"<<std::endl;
-               return NULL;
-       }
-
-       bool enable_mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
+       bool enable_mapgen_debug_info = m_emerge->mapgen_debug_info;
 
        /*infostream<<"Resulting vmanip:"<<std::endl;
        data->vmanip.print(infostream);*/
@@ -2311,9 +2298,7 @@ MapBlock* ServerMap::finishBlockMake(BlockMakeData *data,
                data->vmanip->blitBackAll(&changed_blocks);
        }
 
-       if(enable_mapgen_debug_info)
-               infostream<<"finishBlockMake: changed_blocks.size()="
-                               <<changed_blocks.size()<<std::endl;
+       EMERGE_DBG_OUT("finishBlockMake: changed_blocks.size()=" << changed_blocks.size());
 
        /*
                Copy transforming liquid information
index 1062f8301dc51b261e17f5e002cde5e516d0c44a..1d25b636bcdac41b78770c2b88fcaa4be1409378 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -379,7 +379,7 @@ public:
        /*
                Blocks are generated by using these and makeBlock().
        */
-       void initBlockMake(BlockMakeData *data, v3s16 blockpos);
+       bool initBlockMake(BlockMakeData *data, v3s16 blockpos);
        MapBlock *finishBlockMake(BlockMakeData *data,
                        core::map<v3s16, MapBlock*> &changed_blocks);
 
index ef2cf5f523bdc6e3a54a8ab45cab442c43168da3..d5405876eae3ac247e65ff884dff849146e845ac 100644 (file)
@@ -432,12 +432,6 @@ int MapgenV6::getGroundLevelAtPoint(v2s16 p) {
 
 void MapgenV6::makeChunk(BlockMakeData *data)
 {
-       if(data->no_op)
-       {
-               //dstream<<"makeBlock: no-op"<<std::endl;
-               return;
-       }
-
        this->generating = true;
 
        assert(data->vmanip);
@@ -1436,4 +1430,5 @@ void MapgenV6::makeChunk(BlockMakeData *data)
                vmanip.spreadLight(bank, light_sources, ndef);
        }
        }
+       this->generating = false;
 }