summaryrefslogtreecommitdiff
path: root/src/resources/spritedef.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-05-21 21:44:27 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-05-21 21:44:27 +0000
commit0ac3b58c4c5079f22e6bf4b0efba7f5fe99565cd (patch)
tree6b2a208fac407cf5cf4ddcab2c5e1ebc2b9723dc /src/resources/spritedef.cpp
parent0c869fc47a30616967cb8b69af9ec772566d7076 (diff)
downloadmana-client-0ac3b58c4c5079f22e6bf4b0efba7f5fe99565cd.tar.gz
mana-client-0ac3b58c4c5079f22e6bf4b0efba7f5fe99565cd.tar.bz2
mana-client-0ac3b58c4c5079f22e6bf4b0efba7f5fe99565cd.tar.xz
mana-client-0ac3b58c4c5079f22e6bf4b0efba7f5fe99565cd.zip
Merged revisions 4013,4027,4043,4174,4250,4254 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/trunk ........ r4013 | crush_tmw | 2008-04-01 01:18:19 +0200 (Di, 01 Apr 2008) | 1 line Implemented NPC XML database which maps NPC IDs to one or more animation files and thus enables animated NPCs. ........ r4027 | crush_tmw | 2008-04-02 01:34:14 +0200 (Mi, 02 Apr 2008) | 1 line misspelled filename ........ r4043 | b_lindeijer | 2008-04-07 10:37:23 +0200 (Mo, 07 Apr 2008) | 3 lines Added XML::Document class which simplifies parsing an XML document and automatically cleans it up again. ........ r4174 | b_lindeijer | 2008-04-23 14:57:45 +0200 (Mi, 23 Apr 2008) | 2 lines Fixed svn:keywords properties and added header to guild.h. ........ r4250 | crush_tmw | 2008-05-19 18:18:38 +0200 (Mo, 19 Mai 2008) | 1 line Added the possibility to add particle effects to NPCs in npcs.xml. ........ r4254 | crush_tmw | 2008-05-20 15:58:26 +0200 (Di, 20 Mai 2008) | 1 line fixed some filename confusion messup in the last commit. ........ NOTE: This was my first commit using svnmerge. Please check if I did everything correctly.
Diffstat (limited to 'src/resources/spritedef.cpp')
-rw-r--r--src/resources/spritedef.cpp34
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);