summaryrefslogtreecommitdiff
path: root/src/resources/sprite/spritedef.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-10 23:17:36 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-10 23:17:36 +0300
commit3fbf1226888aa6b8cafcf05d06d3016b1aa058f4 (patch)
tree52ad266d05a2162188331be50dca7b3d865dc5a1 /src/resources/sprite/spritedef.cpp
parentd5f02c215c0f1a2950a09aef411cb957a48157ea (diff)
downloadmanaplus-3fbf1226888aa6b8cafcf05d06d3016b1aa058f4.tar.gz
manaplus-3fbf1226888aa6b8cafcf05d06d3016b1aa058f4.tar.bz2
manaplus-3fbf1226888aa6b8cafcf05d06d3016b1aa058f4.tar.xz
manaplus-3fbf1226888aa6b8cafcf05d06d3016b1aa058f4.zip
Use xml loader in spritedef.
Diffstat (limited to 'src/resources/sprite/spritedef.cpp')
-rw-r--r--src/resources/sprite/spritedef.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp
index f46eebfba..037936dc3 100644
--- a/src/resources/sprite/spritedef.cpp
+++ b/src/resources/sprite/spritedef.cpp
@@ -39,6 +39,7 @@
#include "resources/dye/dye.h"
#include "resources/loaders/imagesetloader.h"
+#include "resources/loaders/xmlloader.h"
#include "resources/sprite/spritereference.h"
@@ -93,10 +94,12 @@ SpriteDef *SpriteDef::load(const std::string &animationFile,
if (pos != std::string::npos)
palettes = animationFile.substr(pos + 1);
- XML::Document doc(animationFile.substr(0, pos),
+ XML::Document *const doc = Loader::getXml(animationFile.substr(0, pos),
UseResman_true,
SkipError_false);
- XmlNodePtrConst rootNode = doc.rootNode();
+ if (!doc)
+ return nullptr;
+ XmlNodePtrConst rootNode = doc->rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "sprite"))
{
@@ -105,6 +108,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile,
const std::string errorFile = paths.getStringValue("sprites").append(
paths.getStringValue("spriteErrorFile"));
BLOCK_END("SpriteDef::load")
+ doc->decRef();
if (animationFile != errorFile)
return load(errorFile, 0, prot);
else
@@ -123,6 +127,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile,
def->incRef();
def->setProtected(true);
}
+ doc->decRef();
BLOCK_END("SpriteDef::load")
return def;
}
@@ -470,18 +475,24 @@ void SpriteDef::includeSprite(const XmlNodePtr includeNode, const int variant)
}
mProcessedFiles.insert(filename);
- XML::Document doc(filename, UseResman_true, SkipError_false);
- const XmlNodePtr rootNode = doc.rootNode();
+ XML::Document *const doc = Loader::getXml(filename,
+ UseResman_true,
+ SkipError_false);
+ if (!doc)
+ return;
+ const XmlNodePtr rootNode = doc->rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "sprite"))
{
reportAlways("%s: No sprite root node in %s",
mSource.c_str(),
filename.c_str());
+ doc->decRef();
return;
}
loadSprite(rootNode, variant);
+ doc->decRef();
}
SpriteDef::~SpriteDef()