}
-GenElement *GenElementManager::getByName(const char *name)
+GenElement *GenElementManager::getByName(const std::string &name)
{
for (size_t i = 0; i != m_elements.size(); i++) {
GenElement *elem = m_elements[i];
- if (elem && !strcmp(elem->name.c_str(), name))
+ if (elem && name == elem->name)
return elem;
}
return NULL;
}
-GenElement *GenElementManager::getByName(std::string &name)
-{
- return getByName(name.c_str());
-}
-
GenElement *GenElementManager::update(u32 id, GenElement *elem)
{
{
return update(id, NULL);
}
+
+
+void GenElementManager::clear()
+{
+ m_elements.clear();
+}
///////////////////////////////////////////////////////////////////////////////
-
BiomeManager::BiomeManager(IGameDef *gamedef)
{
- NodeResolver *resolver = gamedef->getNodeDefManager()->getResolver();
-
+ m_resolver = gamedef->getNodeDefManager()->getResolver();
np_heat = &nparams_biome_def_heat;
np_humidity = &nparams_biome_def_humidity;
b->heat_point = 0.0;
b->humidity_point = 0.0;
- resolver->addNode("air", "", CONTENT_AIR, &b->c_top);
- resolver->addNode("air", "", CONTENT_AIR, &b->c_filler);
- resolver->addNode("mapgen_stone", "", CONTENT_AIR, &b->c_stone);
- resolver->addNode("mapgen_water_source", "", CONTENT_AIR, &b->c_water);
- resolver->addNode("air", "", CONTENT_AIR, &b->c_dust);
- resolver->addNode("mapgen_water_source", "", CONTENT_AIR, &b->c_dust_water);
+ m_resolver->addNode("air", "", CONTENT_AIR, &b->c_top);
+ m_resolver->addNode("air", "", CONTENT_AIR, &b->c_filler);
+ m_resolver->addNode("mapgen_stone", "", CONTENT_AIR, &b->c_stone);
+ m_resolver->addNode("mapgen_water_source", "", CONTENT_AIR, &b->c_water);
+ m_resolver->addNode("air", "", CONTENT_AIR, &b->c_dust);
+ m_resolver->addNode("mapgen_water_source", "", CONTENT_AIR, &b->c_dust_water);
add(b);
}
biome_closest = b;
}
}
-
+
return biome_closest ? biome_closest : (Biome *)m_elements[0];
}
+void BiomeManager::clear()
+{
+ for (size_t i = 1; i < m_elements.size(); i++) {
+ Biome *b = (Biome *)m_elements[i];
+ if (!b)
+ continue;
+
+ m_resolver->cancelNode(&b->c_top);
+ m_resolver->cancelNode(&b->c_filler);
+ m_resolver->cancelNode(&b->c_stone);
+ m_resolver->cancelNode(&b->c_water);
+ m_resolver->cancelNode(&b->c_dust);
+ m_resolver->cancelNode(&b->c_dust_water);
+ }
+ m_elements.resize(1);
+}
+