summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/resources/spritedef.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 6b856c5d3..082e528e7 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -39,6 +39,7 @@
#include "debug.h"
+std::set<std::string> processedFiles;
SpriteReference *SpriteReference::Empty = nullptr;
Action *SpriteDef::getAction(std::string action, unsigned num) const
@@ -85,6 +86,9 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
if (pos != std::string::npos)
palettes = animationFile.substr(pos + 1);
+ processedFiles.clear();
+ processedFiles.insert(animationFile);
+
XML::Document doc(animationFile.substr(0, pos));
xmlNodePtr rootNode = doc.rootNode();
@@ -350,14 +354,21 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode,
void SpriteDef::includeSprite(xmlNodePtr includeNode)
{
- // TODO: Perform circular dependency check, since it's easy to crash the
- // client this way.
- const std::string filename = XML::getProperty(includeNode, "file", "");
+ std::string filename = XML::getProperty(includeNode, "file", "");
if (filename.empty())
return;
+ filename = paths.getStringValue("sprites") + filename;
+
+ if (processedFiles.find(filename) != processedFiles.end())
+ {
+ logger->log("Error, Tried to include %s which already is included.",
+ filename.c_str());
+ return;
+ }
+ processedFiles.insert(filename);
- XML::Document doc(paths.getStringValue("sprites") + filename);
+ XML::Document doc(filename);
xmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite"))