summaryrefslogtreecommitdiff
path: root/src/particle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/particle.cpp')
-rw-r--r--src/particle.cpp30
1 files changed, 5 insertions, 25 deletions
diff --git a/src/particle.cpp b/src/particle.cpp
index dcb2eed3..ba5386f6 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -217,35 +217,17 @@ Particle::addEffect(const std::string &particleEffectFile,
{
Particle *newParticle = NULL;
- // XML parser initialisation stuff
- int size;
- ResourceManager *resman = ResourceManager::getInstance();
- char *data = (char*) resman->loadFile(particleEffectFile.c_str(), size);
-
- if (!data) {
- logger->log("Warning: Particle engine could not find %s !",
- particleEffectFile.c_str());
- return NULL;
- }
-
- xmlDocPtr doc = xmlParseMemory(data, size);
- free(data);
+ XML::Document doc(particleEffectFile);
+ xmlNodePtr rootNode = doc.rootNode();
- if (!doc) {
- logger->log("Warning: Particle engine found syntax error in %s!",
- particleEffectFile.c_str());
- return NULL;
- }
-
- xmlNodePtr rootNode = xmlDocGetRootElement(doc);
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "effect"))
{
- logger->log("Warning: %s is not a valid particle effect definition file!",
- particleEffectFile.c_str());
- xmlFreeDoc(doc);
+ logger->log("Error loading particle: %s", particleEffectFile.c_str());
return NULL;
}
+ ResourceManager *resman = ResourceManager::getInstance();
+
// Parse particles
for_each_xml_child_node(effectChildNode, rootNode)
{
@@ -302,8 +284,6 @@ Particle::addEffect(const std::string &particleEffectFile,
mChildParticles.push_back(newParticle);
}
- xmlFreeDoc(doc);
-
return newParticle;
}