示例#1
0
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, &params, this);
		m_mapgens.push_back(mg);
	}
}
示例#2
0
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);
}
示例#3
0
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);
}