summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-16 18:06:33 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-16 18:06:33 +0300
commit933cfb877f43b25045ae129adff3144fd79ee3a1 (patch)
treecc222de03145f9b6eda4eb7402034b069b1492c8 /src
parent70d4f24f38a4036f84c1f71803173199e95ad675 (diff)
downloadmanaverse-933cfb877f43b25045ae129adff3144fd79ee3a1.tar.gz
manaverse-933cfb877f43b25045ae129adff3144fd79ee3a1.tar.bz2
manaverse-933cfb877f43b25045ae129adff3144fd79ee3a1.tar.xz
manaverse-933cfb877f43b25045ae129adff3144fd79ee3a1.zip
Add macro for for and iterators.
Diffstat (limited to 'src')
-rw-r--r--src/actorspritemanager.cpp29
-rw-r--r--src/localconsts.h3
2 files changed, 10 insertions, 22 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 4ccb2e347..5287019ab 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -273,10 +273,7 @@ void ActorSpriteManager::undelete(const ActorSprite *const actor)
if (!actor || actor == player_node)
return;
- ActorSpritesConstIterator it, it_end;
-
- for (it = mDeleteActors.begin(), it_end = mDeleteActors.end();
- it != it_end; ++it)
+ FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors)
{
if (*it == actor)
{
@@ -760,9 +757,7 @@ void ActorSpriteManager::logic()
}
BLOCK_START("ActorSpriteManager::logic 1")
- for (ActorSpritesConstIterator it = mDeleteActors.begin(),
- it_end = mDeleteActors.end();
- it != it_end; ++it)
+ FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors)
{
if (!*it)
continue;
@@ -785,9 +780,7 @@ void ActorSpriteManager::logic()
viewport->clearHover(*it);
}
- for (ActorSpritesConstIterator it = mDeleteActors.begin(),
- it_end = mDeleteActors.end();
- it != it_end; ++it)
+ FOR_EACH (ActorSpritesConstIterator, it, mDeleteActors)
{
mActors.erase(*it);
delete *it;
@@ -906,9 +899,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(const Being *const
{
std::vector<Being*> sortedBeings;
- for (ActorSprites::const_iterator i = mActors.begin(),
- i_end = mActors.end();
- i != i_end; ++i)
+ FOR_EACH (ActorSprites::const_iterator, i, mActors)
{
if (!*i)
continue;
@@ -1003,9 +994,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(const Being *const
int index = defaultPriorityIndex;
Being *closestBeing = nullptr;
- for (ActorSprites::const_iterator i = mActors.begin(),
- i_end = mActors.end();
- i != i_end; ++i)
+ FOR_EACH (ActorSprites::const_iterator, i, mActors)
{
if (!*i)
continue;
@@ -1294,9 +1283,7 @@ void ActorSpriteManager::printBeingsToChat(ActorSprites beings,
debugChatTab->chatLog("---------------------------------------");
debugChatTab->chatLog(header);
- std::set<ActorSprite*>::const_iterator it;
- const std::set<ActorSprite*>::const_iterator it_end = beings.end();
- for (it = beings.begin(); it != it_end; ++it)
+ FOR_EACH (std::set<ActorSprite*>::const_iterator, it, beings)
{
if (!*it)
continue;
@@ -1323,9 +1310,7 @@ void ActorSpriteManager::printBeingsToChat(std::vector<Being*> beings,
debugChatTab->chatLog("---------------------------------------");
debugChatTab->chatLog(header);
- std::vector<Being*>::const_iterator i;
- const std::vector<Being*>::const_iterator i_end = beings.end();
- for (i = beings.begin(); i != i_end; ++i)
+ FOR_EACH (std::vector<Being*>::const_iterator, i, beings)
{
if (!*i)
continue;
diff --git a/src/localconsts.h b/src/localconsts.h
index c73700824..7c6ac524b 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -56,6 +56,9 @@
#define gnu_printf printf
#endif
+#define FOR_EACH(type, iter, array) for (type iter = array.begin(), \
+ iter##_end = array.end(); iter != iter##_end; ++ iter)
+
//#define DEBUG_CONFIG 1
//#define DEBUG_BIND_TEXTURE 1
//#define DISABLE_RESOURCE_CACHING 1