summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-05 16:24:22 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-05 16:24:22 +0300
commit82359612155bd99dc2a629a4ad665252b571c122 (patch)
tree4d7ce90fda2224ac3b5db9745d52448e60cd19c9
parentc0c3782473479460273f1d6e8e0e3e7564ecff89 (diff)
downloadmv-82359612155bd99dc2a629a4ad665252b571c122.tar.gz
mv-82359612155bd99dc2a629a4ad665252b571c122.tar.bz2
mv-82359612155bd99dc2a629a4ad665252b571c122.tar.xz
mv-82359612155bd99dc2a629a4ad665252b571c122.zip
Remove duplicate code in actorsprite.
-rw-r--r--src/being/actorsprite.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index 1a5a93404..8c414b83f 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -43,6 +43,17 @@
#include "debug.h"
+#define for_each_cursors() \
+ for (int size = TargetCursorSize::SMALL; \
+ size < TargetCursorSize::NUM_TC; \
+ size ++) \
+ { \
+ for (int type = TargetCursorType::NORMAL; \
+ type < TargetCursorType::NUM_TCT; \
+ type ++) \
+
+#define end_foreach }
+
AnimatedSprite *ActorSprite::targetCursor[TargetCursorType::NUM_TCT]
[TargetCursorSize::NUM_TC];
bool ActorSprite::loaded = false;
@@ -363,35 +374,23 @@ void ActorSprite::initTargetCursor()
static const std::string targetCursorFile("target-cursor-%s-%s.xml");
// Load target cursors
- for (int size = TargetCursorSize::SMALL;
- size < TargetCursorSize::NUM_TC;
- size ++)
+ for_each_cursors()
{
- for (int type = TargetCursorType::NORMAL;
- type < TargetCursorType::NUM_TCT;
- type ++)
- {
- targetCursor[type][size] = AnimatedSprite::load(
- Theme::resolveThemePath(strprintf(
- targetCursorFile.c_str(),
- cursorType(type),
- cursorSize(size))));
- }
+ targetCursor[type][size] = AnimatedSprite::load(
+ Theme::resolveThemePath(strprintf(
+ targetCursorFile.c_str(),
+ cursorType(type),
+ cursorSize(size))));
}
+ end_foreach
}
void ActorSprite::cleanupTargetCursors()
{
- for (int size = TargetCursorSize::SMALL;
- size < TargetCursorSize::NUM_TC;
- size ++)
+ for_each_cursors()
{
- for (int type = TargetCursorType::NORMAL;
- type < TargetCursorType::NUM_TCT;
- type ++)
- {
- if (targetCursor[type][size])
- delete2(targetCursor[type][size])
- }
+ if (targetCursor[type][size])
+ delete2(targetCursor[type][size])
}
+ end_foreach
}