From f392d5f6fe96e5b761b1acdc3ff8564ffcd2d038 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sat, 5 Feb 2011 02:51:56 +0000 Subject: [PATCH] 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 --- src/graphics/particle_kind_manager.cpp | 2 +- src/graphics/particle_kind_manager.hpp | 2 +- src/tracks/track.cpp | 35 ++++++++++---------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/graphics/particle_kind_manager.cpp b/src/graphics/particle_kind_manager.cpp index bdbd3bcf5..da611fcb5 100644 --- a/src/graphics/particle_kind_manager.cpp +++ b/src/graphics/particle_kind_manager.cpp @@ -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::iterator i; diff --git a/src/graphics/particle_kind_manager.hpp b/src/graphics/particle_kind_manager.hpp index 200deba54..08859833f 100644 --- a/src/graphics/particle_kind_manager.hpp +++ b/src/graphics/particle_kind_manager.hpp @@ -44,7 +44,7 @@ public: virtual ~ParticleKindManager(); - ParticleKind* getParticles(const char* name); + ParticleKind* getParticles(const std::string &name); void cleanUpTrackSpecificGfx(); diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index d281d5719..6e49c6ee1 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -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