From 67c59645ecd76cbf7a8186d0850ab5950e9ea22a Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sun, 17 Feb 2013 02:46:08 -0500 Subject: [PATCH] Misc. cleanup and minor fixes --- src/emerge.cpp | 21 +++++++++------------ src/emerge.h | 8 +++++--- src/map.cpp | 29 +++++++---------------------- src/map.h | 2 +- src/mapgen_v6.cpp | 7 +------ 5 files changed, 23 insertions(+), 44 deletions(-) diff --git a/src/emerge.cpp b/src/emerge.cpp index ee6650f9..ac654f36 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -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; } diff --git a/src/emerge.h b/src/emerge.h index 7e0cc485..e5014df5 100644 --- a/src/emerge.h +++ b/src/emerge.h @@ -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(); diff --git a/src/map.cpp b/src/map.cpp index a8928d86..3f2f8d1d 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -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(): " - <<"("<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"<getBool("enable_mapgen_debug_info"); + bool enable_mapgen_debug_info = m_emerge->mapgen_debug_info; /*infostream<<"Resulting vmanip:"<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()=" - <generating = true; assert(data->vmanip); @@ -1436,4 +1430,5 @@ void MapgenV6::makeChunk(BlockMakeData *data) vmanip.spreadLight(bank, light_sources, ndef); } } + this->generating = false; }