Support for weather effects stored in a separate xml node (track format 5).

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7617 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-02-05 02:51:56 +00:00
parent f3663e4f90
commit f392d5f6fe
3 changed files with 15 additions and 24 deletions

View File

@ -67,7 +67,7 @@ void ParticleKindManager::cleanUpTrackSpecificGfx()
// ----------------------------------------------------------------------------
ParticleKind* ParticleKindManager::getParticles(const char* name)
ParticleKind* ParticleKindManager::getParticles(const std::string &name)
{
Track* t = track_manager->getTrack(race_manager->getTrackName());
std::map<std::string, ParticleKind*>::iterator i;

View File

@ -44,7 +44,7 @@ public:
virtual ~ParticleKindManager();
ParticleKind* getParticles(const char* name);
ParticleKind* getParticles(const std::string &name);
void cleanUpTrackSpecificGfx();

View File

@ -880,6 +880,19 @@ void Track::loadTrackModel(World* parent, unsigned int mode_id)
{
Camera::readEndCamera(*node);
}
else if(name=="weather")
{
std::string sky_particles;
node->get("particles", &sky_particles);
if (sky_particles.size() ==0)
{
fprintf(stderr,
"Warning: no weather particles found - ignored.\n");
continue;
}
m_sky_particles =
ParticleKindManager::get()->getParticles(sky_particles);
}
else
{
fprintf(stderr, "Warning: while loading track '%s', element '%s' was met but is unknown.\n",
@ -1037,14 +1050,6 @@ void Track::handleSky(const XMLNode &xml_node, const std::string &filename)
xml_node.get("texture-percent", &m_sky_texture_percent);
xml_node.get("speed-x", &m_sky_dx );
xml_node.get("speed-y", &m_sky_dy);
std::string sky_particles;
xml_node.get("particles", &sky_particles);
if (sky_particles.size() > 0)
{
m_sky_particles = ParticleKindManager::get()->getParticles(sky_particles.c_str());
}
} // if sky-dome
else if(xml_node.getName()=="sky-box")
{
@ -1062,25 +1067,11 @@ void Track::handleSky(const XMLNode &xml_node, const std::string &filename)
{
m_sky_type = SKY_BOX;
}
std::string sky_particles;
xml_node.get("particles", &sky_particles);
if (sky_particles.size() > 0)
{
m_sky_particles = ParticleKindManager::get()->getParticles(sky_particles.c_str());
}
}
else if (xml_node.getName() == "sky-color")
{
m_sky_type = SKY_COLOR;
xml_node.get("rgb", &m_sky_color);
std::string sky_particles;
xml_node.get("particles", &sky_particles);
if (sky_particles.size() > 0)
{
m_sky_particles = ParticleKindManager::get()->getParticles(sky_particles.c_str());
}
} // if sky-box
} // handleSky