diff options
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 73 |
1 files changed, 20 insertions, 53 deletions
diff --git a/src/map.cpp b/src/map.cpp index 4d32ecdfe..075649f94 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2407,34 +2407,11 @@ s16 Map::getHumidity(v3s16 p) */ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef, EmergeManager *emerge): Map(dout_server, gamedef), - m_seed(0), + m_emerge(emerge), m_map_metadata_changed(true) { verbosestream<<__FUNCTION_NAME<<std::endl; - m_emerge = emerge; - m_mgparams = m_emerge->getParamsFromSettings(g_settings); - if (!m_mgparams) - m_mgparams = new MapgenV6Params(); - - m_seed = m_mgparams->seed; - - if (g_settings->get("fixed_map_seed").empty()) - { - m_seed = (((u64)(myrand() & 0xffff) << 0) - | ((u64)(myrand() & 0xffff) << 16) - | ((u64)(myrand() & 0xffff) << 32) - | ((u64)(myrand() & 0xffff) << 48)); - m_mgparams->seed = m_seed; - } - - /* - Experimental and debug stuff - */ - - { - } - /* Try to load map; if not found, create a new one. */ @@ -2496,7 +2473,7 @@ ServerMap::ServerMap(std::string savedir, IGameDef *gamedef, EmergeManager *emer infostream<<"ServerMap: Successfully loaded map " <<"metadata from "<<savedir <<", assuming valid save directory." - <<" seed="<<m_seed<<"." + <<" seed="<< m_emerge->params.seed <<"." <<std::endl; m_map_saving_enabled = true; @@ -2552,7 +2529,7 @@ ServerMap::~ServerMap() /* Close database if it was opened */ - delete(dbase); + delete dbase; #if 0 /* @@ -2565,8 +2542,16 @@ ServerMap::~ServerMap() delete chunk; } #endif +} + +u64 ServerMap::getSeed() +{ + return m_emerge->params.seed; +} - delete m_mgparams; +s16 ServerMap::getWaterLevel() +{ + return m_emerge->params.water_level; } bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos) @@ -2574,7 +2559,7 @@ bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos) bool enable_mapgen_debug_info = m_emerge->mapgen_debug_info; EMERGE_DBG_OUT("initBlockMake(): " PP(blockpos) " - " PP(blockpos)); - s16 chunksize = m_mgparams->chunksize; + s16 chunksize = m_emerge->params.chunksize; s16 coffset = -chunksize / 2; v3s16 chunk_offset(coffset, coffset, coffset); v3s16 blockpos_div = getContainerPos(blockpos - chunk_offset, chunksize); @@ -2590,7 +2575,7 @@ bool ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos) blockpos_over_limit(blockpos_max + extra_borders)) return false; - data->seed = m_seed; + data->seed = m_emerge->params.seed; data->blockpos_min = blockpos_min; data->blockpos_max = blockpos_max; data->blockpos_requested = blockpos; @@ -3451,7 +3436,7 @@ void ServerMap::saveMapMeta() Settings params; - m_emerge->setParamsToSettings(¶ms); + m_emerge->saveParamsToSettings(¶ms); params.writeLines(ss); ss<<"[end_of_params]\n"; @@ -3497,28 +3482,10 @@ void ServerMap::loadMapMeta() params.parseConfigLine(line); } - MapgenParams *mgparams; - try { - mgparams = m_emerge->getParamsFromSettings(¶ms); - } catch (SettingNotFoundException &e) { - infostream << "Couldn't get a setting from map_meta.txt: " - << e.what() << std::endl; - mgparams = NULL; - } - - if (mgparams) { - if (m_mgparams) - delete m_mgparams; - m_mgparams = mgparams; - m_seed = mgparams->seed; - } else { - if (params.exists("seed")) { - m_seed = read_seed(params.get("seed").c_str()); - m_mgparams->seed = m_seed; - } - } + m_emerge->loadParamsFromSettings(¶ms); - verbosestream<<"ServerMap::loadMapMeta(): "<<"seed="<<m_seed<<std::endl; + verbosestream<<"ServerMap::loadMapMeta(): seed=" + << m_emerge->params.seed<<std::endl; } void ServerMap::saveSectorMeta(ServerMapSector *sector) @@ -3940,7 +3907,7 @@ s16 ServerMap::updateBlockHeat(ServerEnvironment *env, v3s16 p, MapBlock *block) block = getBlockNoCreateNoEx(getNodeBlockPos(p)); } - f32 heat = m_emerge->biomedef->calcBlockHeat(p, m_seed, + f32 heat = m_emerge->biomedef->calcBlockHeat(p, getSeed(), env->getTimeOfDayF(), gametime * env->getTimeOfDaySpeed()); if(block) { @@ -3961,7 +3928,7 @@ s16 ServerMap::updateBlockHumidity(ServerEnvironment *env, v3s16 p, MapBlock *bl block = getBlockNoCreateNoEx(getNodeBlockPos(p)); } - f32 humidity = m_emerge->biomedef->calcBlockHumidity(p, m_seed, + f32 humidity = m_emerge->biomedef->calcBlockHumidity(p, getSeed(), env->getTimeOfDayF(), gametime * env->getTimeOfDaySpeed()); if(block) { |