diff options
Diffstat (limited to 'src/emerge.cpp')
-rw-r--r-- | src/emerge.cpp | 83 |
1 files changed, 17 insertions, 66 deletions
diff --git a/src/emerge.cpp b/src/emerge.cpp index a697bcb07..d6bda731a 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "environment.h" #include "util/container.h" #include "util/thread.h" -#include "main.h" #include "constants.h" #include "voxel.h" #include "config.h" @@ -166,7 +165,7 @@ EmergeManager::~EmergeManager() void EmergeManager::loadMapgenParams() { - loadParamsFromSettings(g_settings); + params.load(*g_settings); } @@ -344,9 +343,9 @@ Mapgen *EmergeManager::createMapgen(const std::string &mgname, int mgid, MapgenSpecificParams *EmergeManager::createMapgenParams(const std::string &mgname) { u32 i; - for (i = 0; i != ARRLEN(reg_mapgens) && mgname != reg_mapgens[i].name; i++); + for (i = 0; i < ARRLEN(reg_mapgens) && mgname != reg_mapgens[i].name; i++); if (i == ARRLEN(reg_mapgens)) { - errorstream << "EmergeManager; mapgen " << mgname << + errorstream << "EmergeManager: Mapgen " << mgname << " not registered" << std::endl; return NULL; } @@ -356,56 +355,6 @@ MapgenSpecificParams *EmergeManager::createMapgenParams(const std::string &mgnam } -void EmergeManager::loadParamsFromSettings(Settings *settings) -{ - std::string seed_str; - const char *setname = (settings == g_settings) ? "fixed_map_seed" : "seed"; - - if (!settings->getNoEx("seed", seed_str)) { - g_settings->getNoEx(setname, seed_str); - } - if (!seed_str.empty()) { - params.seed = read_seed(seed_str.c_str()); - } else { - params.seed = - ((u64)(myrand() & 0xffff) << 0) | - ((u64)(myrand() & 0xffff) << 16) | - ((u64)(myrand() & 0xffff) << 32) | - ((u64)(myrand() & 0xffff) << 48); - } - - settings->getNoEx("mg_name", params.mg_name); - settings->getS16NoEx("water_level", params.water_level); - settings->getS16NoEx("chunksize", params.chunksize); - settings->getFlagStrNoEx("mg_flags", params.flags, flagdesc_mapgen); - settings->getNoiseParams("mg_biome_np_heat", params.np_biome_heat); - settings->getNoiseParams("mg_biome_np_humidity", params.np_biome_humidity); - - delete params.sparams; - params.sparams = createMapgenParams(params.mg_name); - - if (params.sparams) { - params.sparams->readParams(g_settings); - params.sparams->readParams(settings); - } -} - - -void EmergeManager::saveParamsToSettings(Settings *settings) -{ - settings->set("mg_name", params.mg_name); - settings->setU64("seed", params.seed); - settings->setS16("water_level", params.water_level); - settings->setS16("chunksize", params.chunksize); - settings->setFlagStr("mg_flags", params.flags, flagdesc_mapgen, (u32)-1); - settings->setNoiseParams("mg_biome_np_heat", params.np_biome_heat); - settings->setNoiseParams("mg_biome_np_humidity", params.np_biome_humidity); - - if (params.sparams) - params.sparams->writeParams(settings); -} - - ////////////////////////////// Emerge Thread ////////////////////////////////// bool EmergeThread::popBlockEmerge(v3s16 *pos, u8 *flags) @@ -545,8 +494,8 @@ void *EmergeThread::Thread() try { // takes about 90ms with -O1 on an e3-1230v2 m_server->getScriptIface()->environment_OnGenerated( minp, maxp, mapgen->blockseed); - } catch(LuaError &e) { - m_server->setAsyncFatalError(e.what()); + } catch (LuaError &e) { + m_server->setAsyncFatalError("Lua: " + std::string(e.what())); } EMERGE_DBG_OUT("ended up with: " << analyze_block(block)); @@ -569,20 +518,22 @@ void *EmergeThread::Thread() } catch (VersionMismatchException &e) { std::ostringstream err; - err << "World data version mismatch in MapBlock "<<PP(last_tried_pos)<<std::endl; - err << "----"<<std::endl; - err << "\""<<e.what()<<"\""<<std::endl; - err << "See debug.txt."<<std::endl; - err << "World probably saved by a newer version of Minetest."<<std::endl; + err << "World data version mismatch in MapBlock " << PP(last_tried_pos) << std::endl + << "----" << std::endl + << "\"" << e.what() << "\"" << std::endl + << "See debug.txt." << std::endl + << "World probably saved by a newer version of " PROJECT_NAME_C "." + << std::endl; m_server->setAsyncFatalError(err.str()); } catch (SerializationError &e) { std::ostringstream err; - err << "Invalid data in MapBlock "<<PP(last_tried_pos)<<std::endl; - err << "----"<<std::endl; - err << "\""<<e.what()<<"\""<<std::endl; - err << "See debug.txt."<<std::endl; - err << "You can ignore this using [ignore_world_load_errors = true]."<<std::endl; + err << "Invalid data in MapBlock " << PP(last_tried_pos) << std::endl + << "----" << std::endl + << "\"" << e.what() << "\"" << std::endl + << "See debug.txt." << std::endl + << "You can ignore this using [ignore_world_load_errors = true]." + << std::endl; m_server->setAsyncFatalError(err.str()); } |