From 82359612155bd99dc2a629a4ad665252b571c122 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 5 Jun 2014 16:24:22 +0300 Subject: Remove duplicate code in actorsprite. --- src/being/actorsprite.cpp | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'src/being/actorsprite.cpp') 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 } -- cgit v1.2.3-70-g09d2