aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen.cpp
diff options
context:
space:
mode:
authorkwolekr <mirrorisim@gmail.com>2013-02-13 22:43:15 -0500
committerkwolekr <mirrorisim@gmail.com>2013-02-25 22:56:18 -0500
commitb9d8e59bbf727fcc1a073bbf27e5d1703b9490ef (patch)
tree629dba18aab743e66b88858f5385cf4ba36d0328 /src/mapgen.cpp
parent6d0ea26c2d62c3774ff384cf1bfc2a3372b49a3b (diff)
downloadminetest-b9d8e59bbf727fcc1a073bbf27e5d1703b9490ef.tar.gz
minetest-b9d8e59bbf727fcc1a073bbf27e5d1703b9490ef.tar.bz2
minetest-b9d8e59bbf727fcc1a073bbf27e5d1703b9490ef.zip
Add emerge.cpp, initial EmergeThread changes
- Neatly placed all emerge related code into a new file, emerge.cpp - Greatly cleaned up the code in EmergeThread::Thread() - Reworked Emerge queue. Now an actual std::queue of v3s16 block positions - Removed the completely unnecessary map of peer ids requesting blocks
Diffstat (limited to 'src/mapgen.cpp')
-rw-r--r--src/mapgen.cpp153
1 files changed, 0 insertions, 153 deletions
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 73fe63318..ef5da6bf1 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -46,144 +46,6 @@ FlagDesc flagdesc_mapgen[] = {
};
///////////////////////////////////////////////////////////////////////////////
-/////////////////////////////// Emerge Manager ////////////////////////////////
-
-
-EmergeManager::EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef) {
- //register built-in mapgens
- registerMapgen("v6", new MapgenFactoryV6());
-
- //the order of these assignments is pretty important
- this->biomedef = bdef ? bdef : new BiomeDefManager(gamedef);
- this->params = NULL;
- this->mapgen = NULL;
-}
-
-
-EmergeManager::~EmergeManager() {
- delete biomedef;
- delete mapgen;
- delete params;
-}
-
-
-void EmergeManager::initMapgens(MapgenParams *mgparams) {
- if (mapgen)
- return;
-
- this->params = mgparams;
- this->mapgen = getMapgen(); //only one mapgen for now!
-}
-
-
-Mapgen *EmergeManager::getMapgen() {
- if (!mapgen) {
- mapgen = createMapgen(params->mg_name, 0, params, this);
- if (!mapgen) {
- infostream << "EmergeManager: falling back to mapgen v6" << std::endl;
- delete params;
- params = createMapgenParams("v6");
- mapgen = createMapgen("v6", 0, params, this);
- }
- }
- return mapgen;
-}
-
-void EmergeManager::addBlockToQueue() {
- //STUB
-}
-
-
-int EmergeManager::getGroundLevelAtPoint(v2s16 p) {
- if (!mapgen)
- return 0;
- return mapgen->getGroundLevelAtPoint(p);
-}
-
-
-bool EmergeManager::isBlockUnderground(v3s16 blockpos) {
- /*
- v2s16 p = v2s16((blockpos.X * MAP_BLOCKSIZE) + MAP_BLOCKSIZE / 2,
- (blockpos.Y * MAP_BLOCKSIZE) + MAP_BLOCKSIZE / 2);
- int ground_level = getGroundLevelAtPoint(p);
- return blockpos.Y * (MAP_BLOCKSIZE + 1) <= min(water_level, ground_level);
- */
-
- //yuck, but then again, should i bother being accurate?
- //the height of the nodes in a single block is quite variable
- return blockpos.Y * (MAP_BLOCKSIZE + 1) <= params->water_level;
-}
-
-
-u32 EmergeManager::getBlockSeed(v3s16 p) {
- return (u32)(params->seed & 0xFFFFFFFF) +
- p.Z * 38134234 +
- p.Y * 42123 +
- p.Y * 23;
-}
-
-
-Mapgen *EmergeManager::createMapgen(std::string mgname, int mgid,
- MapgenParams *mgparams, EmergeManager *emerge) {
- std::map<std::string, MapgenFactory *>::const_iterator iter = mglist.find(mgname);
- if (iter == mglist.end()) {
- errorstream << "EmergeManager; mapgen " << mgname <<
- " not registered" << std::endl;
- return NULL;
- }
-
- MapgenFactory *mgfactory = iter->second;
- return mgfactory->createMapgen(mgid, mgparams, emerge);
-}
-
-
-MapgenParams *EmergeManager::createMapgenParams(std::string mgname) {
- std::map<std::string, MapgenFactory *>::const_iterator iter = mglist.find(mgname);
- if (iter == mglist.end()) {
- errorstream << "EmergeManager: mapgen " << mgname <<
- " not registered" << std::endl;
- return NULL;
- }
-
- MapgenFactory *mgfactory = iter->second;
- return mgfactory->createMapgenParams();
-}
-
-
-MapgenParams *EmergeManager::getParamsFromSettings(Settings *settings) {
- std::string mg_name = settings->get("mg_name");
- MapgenParams *mgparams = createMapgenParams(mg_name);
-
- mgparams->mg_name = mg_name;
- mgparams->seed = settings->getU64(settings == g_settings ? "fixed_map_seed" : "seed");
- mgparams->water_level = settings->getS16("water_level");
- mgparams->chunksize = settings->getS16("chunksize");
- mgparams->flags = settings->getFlagStr("mg_flags", flagdesc_mapgen);
-
- if (!mgparams->readParams(settings)) {
- delete mgparams;
- return NULL;
- }
- return mgparams;
-}
-
-
-void EmergeManager::setParamsToSettings(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);
-
- params->writeParams(settings);
-}
-
-
-void EmergeManager::registerMapgen(std::string mgname, MapgenFactory *mgfactory) {
- mglist.insert(std::make_pair(mgname, mgfactory));
- infostream << "EmergeManager: registered mapgen " << mgname << std::endl;
-}
-
/////////////////////
@@ -2986,18 +2848,3 @@ void make_block(BlockMakeData *data)
#endif ///BIG COMMENT
-BlockMakeData::BlockMakeData():
- no_op(false),
- vmanip(NULL),
- seed(0),
- nodedef(NULL)
-{}
-
-BlockMakeData::~BlockMakeData()
-{
- delete vmanip;
-}
-
-//}; // namespace mapgen
-
-