void EmergeManager::initMapgens() { if (m_mapgens.size()) return; MapgenFactory *mgfactory = getMapgenFactory(params.mg_name); if (!mgfactory) { errorstream << "EmergeManager: mapgen " << params.mg_name << " not registered; falling back to " << DEFAULT_MAPGEN << std::endl; params.mg_name = DEFAULT_MAPGEN; mgfactory = getMapgenFactory(params.mg_name); FATAL_ERROR_IF(mgfactory == NULL, "Couldn't use any mapgen!"); } if (!params.sparams) { params.sparams = mgfactory->createMapgenParams(); params.sparams->readParams(g_settings); } for (u32 i = 0; i != m_threads.size(); i++) { Mapgen *mg = mgfactory->createMapgen(i, ¶ms, this); m_mapgens.push_back(mg); } }
MapgenSpecificParams *EmergeManager::createMapgenParams(std::string mgname) { std::map<std::string, MapgenFactory *>::const_iterator iter; 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(); }
Mapgen *EmergeManager::createMapgen(std::string mgname, int mgid, MapgenParams *mgparams) { std::map<std::string, MapgenFactory *>::const_iterator iter; 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, this); }
MapgenSpecificParams *EmergeManager::createMapgenParams(const std::string &mgname) { u32 i; for (i = 0; i < ARRLEN(reg_mapgens) && mgname != reg_mapgens[i].name; i++); if (i == ARRLEN(reg_mapgens)) { errorstream << "EmergeManager: Mapgen " << mgname << " not registered" << std::endl; return NULL; } MapgenFactory *mgfactory = reg_mapgens[i].factory; return mgfactory->createMapgenParams(); }
Mapgen *EmergeManager::createMapgen(const std::string &mgname, int mgid, MapgenParams *mgparams) { u32 i; for (i = 0; i != ARRLEN(reg_mapgens) && mgname != reg_mapgens[i].name; i++); if (i == ARRLEN(reg_mapgens)) { errorstream << "EmergeManager; mapgen " << mgname << " not registered" << std::endl; return NULL; } MapgenFactory *mgfactory = reg_mapgens[i].factory; return mgfactory->createMapgen(mgid, mgparams, this); }