diff options
Diffstat (limited to 'src/resources/spritedef.cpp')
-rw-r--r-- | src/resources/spritedef.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index ee823c3f..3f95b3ec 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -51,7 +51,6 @@ SpriteDef::getAction(SpriteAction action) const SpriteDef *SpriteDef::load(std::string const &animationFile, int variant) { - int size; ResourceManager *resman = ResourceManager::getInstance(); std::string::size_type pos = animationFile.find('|'); @@ -59,29 +58,18 @@ SpriteDef *SpriteDef::load(std::string const &animationFile, int variant) if (pos != std::string::npos) palettes = animationFile.substr(pos + 1); - char *data = (char*) resman->loadFile - (animationFile.substr(0, pos).c_str(), size); + XML::Document doc(animationFile.substr(0, pos)); + xmlNodePtr rootNode = doc.rootNode(); - if (!data && animationFile != "graphics/sprites/error.xml") - { - return load("graphics/sprites/error.xml", 0); - } - - xmlDocPtr doc = xmlParseMemory(data, size); - free(data); - - if (!doc) - { - logger->log("Error, failed to parse %s.", animationFile.c_str()); - return NULL; - } - - xmlNodePtr rootNode = xmlDocGetRootElement(doc); if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite")) { - logger->log("Error, failed to parse %s.", animationFile.c_str()); - xmlFreeDoc(doc); - return NULL; + logger->log("Error, failed to parse %s", animationFile.c_str()); + + if (animationFile != "graphics/sprites/error.xml") { + return load("graphics/sprites/error.xml", 0); + } else { + return NULL; + } } // Get the variant @@ -111,8 +99,6 @@ SpriteDef *SpriteDef::load(std::string const &animationFile, int variant) } } - xmlFreeDoc(doc); - def->substituteActions(); return def; } @@ -279,7 +265,7 @@ SpriteDef::loadAnimation(xmlNodePtr animationNode, void SpriteDef::includeSprite(xmlNodePtr includeNode) { - std::string filename = XML::getProperty(includeNode, "file", ""); + const std::string filename = XML::getProperty(includeNode, "file", ""); ResourceManager *resman = ResourceManager::getInstance(); SpriteDef *sprite = resman->getSprite("graphics/sprites/" + filename); |