summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-05-11 21:38:45 +0300
committerAndrei Karas <akaras@inbox.ru>2016-05-11 21:38:45 +0300
commitc82a88a8fcb448ee1d16ce47bb3c67f72b252a93 (patch)
tree31ff8a3d21136cf42960d6e0ed065194f0bad877 /src
parentb9cb3b1e94a16425025dd251955f57ca7da5f637 (diff)
downloadmanaverse-c82a88a8fcb448ee1d16ce47bb3c67f72b252a93.tar.gz
manaverse-c82a88a8fcb448ee1d16ce47bb3c67f72b252a93.tar.bz2
manaverse-c82a88a8fcb448ee1d16ce47bb3c67f72b252a93.tar.xz
manaverse-c82a88a8fcb448ee1d16ce47bb3c67f72b252a93.zip
Add asserts into SpriteDef.
Diffstat (limited to 'src')
-rw-r--r--src/resources/sprite/spritedef.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp
index 0662ef7bf..5fde19c17 100644
--- a/src/resources/sprite/spritedef.cpp
+++ b/src/resources/sprite/spritedef.cpp
@@ -30,6 +30,8 @@
#include "const/resources/map/map.h"
+#include "utils/checkutils.h"
+
#include "resources/action.h"
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
@@ -98,7 +100,8 @@ SpriteDef *SpriteDef::load(const std::string &animationFile,
if (!rootNode || !xmlNameEqual(rootNode, "sprite"))
{
- logger->log("Error, failed to parse %s", animationFile.c_str());
+ logger->log("Error, failed to parse sprite %s", animationFile.c_str());
+ reportAlways("Error, failed to parse sprite %s", animationFile.c_str());
const std::string errorFile = paths.getStringValue("sprites").append(
paths.getStringValue("spriteErrorFile"));
@@ -145,7 +148,7 @@ void SpriteDef::substituteAction(const std::string &restrict complete,
FOR_EACH (ActionsConstIter, it, mActions)
{
ActionMap *const d = (*it).second;
- if (!d)
+ if (reportTrue(d == nullptr))
continue;
if (d->find(complete) == d->end())
{
@@ -242,6 +245,7 @@ void SpriteDef::loadImageSet(const XmlNodePtr node,
if (!imageSet)
{
logger->log1("Couldn't load imageset!");
+ reportAlways("Couldn't load imageset!");
return;
}
@@ -265,6 +269,8 @@ void SpriteDef::loadAction(const XmlNodePtr node,
{
logger->log("Warning: imageset \"%s\" not defined in %s",
imageSetName.c_str(), getIdPath().c_str());
+ reportAlways("Warning: imageset \"%s\" not defined in %s",
+ imageSetName.c_str(), getIdPath().c_str());
return;
}
const ImageSet *const imageSet = si->second;
@@ -273,6 +279,8 @@ void SpriteDef::loadAction(const XmlNodePtr node,
{
logger->log("Warning: Unknown action \"%s\" defined in %s",
actionName.c_str(), getIdPath().c_str());
+ reportAlways("Warning: Unknown action \"%s\" defined in %s",
+ actionName.c_str(), getIdPath().c_str());
return;
}
Action *const action = new Action(actionName);
@@ -313,6 +321,8 @@ void SpriteDef::loadAnimation(const XmlNodePtr animationNode,
{
logger->log("Warning: Unknown direction \"%s\" used in %s",
directionName.c_str(), getIdPath().c_str());
+ reportAlways("Warning: Unknown direction \"%s\" used in %s",
+ directionName.c_str(), getIdPath().c_str());
return;
}
@@ -445,6 +455,8 @@ void SpriteDef::includeSprite(const XmlNodePtr includeNode, const int variant)
{
logger->log("Error, Tried to include %s which already is included.",
filename.c_str());
+ reportAlways("Error, Tried to include %s which already is included.",
+ filename.c_str());
return;
}
mProcessedFiles.insert(filename);
@@ -455,6 +467,7 @@ void SpriteDef::includeSprite(const XmlNodePtr includeNode, const int variant)
if (!rootNode || !xmlNameEqual(rootNode, "sprite"))
{
logger->log("Error, no sprite root node in %s", filename.c_str());
+ reportAlways("Error, no sprite root node in %s", filename.c_str());
return;
}
@@ -540,6 +553,7 @@ bool SpriteDef::addSequence(const int start,
if (start < 0 || end < 0)
{
logger->log1("No valid value for 'start' or 'end'");
+ reportAlways("No valid value for 'start' or 'end'");
return true;
}
@@ -556,6 +570,8 @@ bool SpriteDef::addSequence(const int start,
{
logger->log("No image at index %d",
pos + variant_offset);
+ reportAlways("No image at index %d",
+ pos + variant_offset);
pos ++;
continue;
}
@@ -580,6 +596,8 @@ bool SpriteDef::addSequence(const int start,
{
logger->log("No image at index %d",
pos + variant_offset);
+ reportAlways("No image at index %d",
+ pos + variant_offset);
pos ++;
continue;
}