summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-19 15:25:24 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-20 17:05:57 +0300
commit48071e171de41a23197c7328ba038331a936e0eb (patch)
tree73c7ef1da8e5dd76469d75c0336d88c3371e4263 /src
parentd07fba228b5251862ad670e1d4f079c9456fab4b (diff)
downloadmv-48071e171de41a23197c7328ba038331a936e0eb.tar.gz
mv-48071e171de41a23197c7328ba038331a936e0eb.tar.bz2
mv-48071e171de41a23197c7328ba038331a936e0eb.tar.xz
mv-48071e171de41a23197c7328ba038331a936e0eb.zip
Replace for to FOR_EACH in some classes.
Diffstat (limited to 'src')
-rw-r--r--src/actorsprite.cpp14
-rw-r--r--src/being.cpp20
-rw-r--r--src/channelmanager.cpp10
-rw-r--r--src/commands.cpp6
-rw-r--r--src/compoundsprite.cpp42
-rw-r--r--src/configuration.cpp16
-rw-r--r--src/effectmanager.cpp6
-rw-r--r--src/graphicsmanager.cpp4
-rw-r--r--src/inputmanager.cpp6
-rw-r--r--src/inventory.cpp5
-rw-r--r--src/joystick.cpp3
-rw-r--r--src/keyboardconfig.cpp3
-rw-r--r--src/localconsts.h3
-rw-r--r--src/localplayer.cpp5
-rw-r--r--src/map.cpp41
-rw-r--r--src/maplayer.cpp3
-rw-r--r--src/particle.cpp14
-rw-r--r--src/particlecontainer.cpp8
-rw-r--r--src/particleemitter.cpp18
-rw-r--r--src/playerinfo.cpp3
-rw-r--r--src/playerrelations.cpp27
-rw-r--r--src/textmanager.cpp13
-rw-r--r--src/touchmanager.cpp22
23 files changed, 90 insertions, 202 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index e266180ed..b0ed43b75 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -70,8 +70,7 @@ ActorSprite::~ActorSprite()
player_node->setTarget(nullptr);
// Notify listeners of the destruction.
- for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(),
- e = mActorSpriteListeners.end(); iter != e; ++iter)
+ FOR_EACH (ActorSpriteListenerIterator, iter, mActorSpriteListeners)
{
if (reportFalse(*iter))
(*iter)->actorSpriteDestroyed(*this);
@@ -120,8 +119,7 @@ void ActorSprite::logic()
if (mMustResetParticles)
{
mMustResetParticles = false;
- for (std::set<int>::const_iterator it = mStatusEffects.begin(),
- it_end = mStatusEffects.end(); it != it_end; ++it)
+ FOR_EACH (std::set<int>::const_iterator, it, mStatusEffects)
{
const StatusEffect *const effect
= StatusEffect::getStatusEffect(*it, true);
@@ -331,9 +329,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
{
clear();
- for (SpriteRefs it = display.sprites.begin(),
- it_end = display.sprites.end();
- it != it_end; ++it)
+ FOR_EACH (SpriteRefs, it, display.sprites)
{
if (!*it)
continue;
@@ -387,9 +383,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
//setup particle effects
if (Particle::enabled && particleEngine)
{
- for (StringVectCIter itr = display.particles.begin(),
- itr_end = display.particles.end();
- itr != itr_end; ++itr)
+ FOR_EACH (StringVectCIter, itr, display.particles)
{
Particle *const p = particleEngine->addEffect(*itr, 0, 0);
controlParticle(p);
diff --git a/src/being.cpp b/src/being.cpp
index 910feb936..633be5d53 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -190,7 +190,8 @@ bool Being::mEnableReorderSprites = true;
bool Being::mHideErased = false;
std::list<BeingCacheEntry*> beingInfoCache;
-
+typedef std::map<int, Guild*>::const_iterator GuildsMapCIter;
+typedef std::map<int, int>::const_iterator IntMapCIter;
// TODO: mWalkTime used by eAthena only
Being::Being(const int id, const Type type, const uint16_t subtype,
@@ -908,8 +909,7 @@ void Being::removeGuild(const int id)
Guild *Being::getGuild(const std::string &guildName) const
{
- for (std::map<int, Guild*>::const_iterator itr = mGuilds.begin(),
- itr_end = mGuilds.end(); itr != itr_end; ++itr)
+ FOR_EACH (GuildsMapCIter, itr, mGuilds)
{
Guild *const guild = itr->second;
if (guild && guild->getName() == guildName)
@@ -939,8 +939,7 @@ Guild *Being::getGuild() const
void Being::clearGuilds()
{
- for (std::map<int, Guild*>::const_iterator itr = mGuilds.begin(),
- itr_end = mGuilds.end(); itr != itr_end; ++itr)
+ FOR_EACH (GuildsMapCIter, itr, mGuilds)
{
Guild *const guild = itr->second;
@@ -2034,8 +2033,7 @@ void Being::addToCache() const
BeingCacheEntry* Being::getCacheEntry(const int id)
{
- for (std::list<BeingCacheEntry*>::iterator i = beingInfoCache.begin();
- i != beingInfoCache.end(); ++ i)
+ FOR_EACH (std::list<BeingCacheEntry*>::iterator, i, beingInfoCache)
{
if (!*i)
continue;
@@ -2346,8 +2344,7 @@ void Being::recalcSpritesOrder()
if (spriteToItems)
{
- for (SpriteToItemMapCIter itr = spriteToItems->begin(),
- itr_end = spriteToItems->end(); itr != itr_end; ++ itr)
+ FOR_EACHP (SpriteToItemMapCIter, itr, spriteToItems)
{
const int remSprite = itr->first;
const std::map<int, int> &itemReplacer = itr->second;
@@ -2392,10 +2389,7 @@ void Being::recalcSpritesOrder()
}
else
{ // slot unknown. Search for real slot, this can be slow
- for (std::map<int, int>::const_iterator
- repIt = itemReplacer.begin(),
- repIt_end = itemReplacer.end();
- repIt != repIt_end; ++ repIt)
+ FOR_EACH (IntMapCIter, repIt, itemReplacer)
{
for (unsigned slot2 = 0; slot2 < sz; slot2 ++)
{
diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp
index 31f87010e..48590891b 100644
--- a/src/channelmanager.cpp
+++ b/src/channelmanager.cpp
@@ -41,10 +41,7 @@ ChannelManager::~ChannelManager()
Channel *ChannelManager::findById(const int id) const
{
Channel *channel = nullptr;
- for (std::list<Channel*>::const_iterator itr = mChannels.begin(),
- end = mChannels.end();
- itr != end;
- ++itr)
+ FOR_EACH (std::list<Channel*>::const_iterator, itr, mChannels)
{
Channel *const c = (*itr);
if (!c)
@@ -63,10 +60,7 @@ Channel *ChannelManager::findByName(const std::string &name) const
Channel *channel = nullptr;
if (!name.empty())
{
- for (std::list<Channel*>::const_iterator itr = mChannels.begin(),
- end = mChannels.end();
- itr != end;
- ++itr)
+ FOR_EACH (std::list<Channel*>::const_iterator, itr, mChannels)
{
Channel *const c = (*itr);
if (!c)
diff --git a/src/commands.cpp b/src/commands.cpp
index 46a1e14f4..eeec00755 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1177,8 +1177,7 @@ void replaceVars(std::string &str)
StringVect names;
std::string newStr;
actorSpriteManager->getPlayerNames(names, false);
- for (StringVectCIter it = names.begin(), it_end = names.end();
- it != it_end; ++ it)
+ FOR_EACH (StringVectCIter, it, names)
{
if (*it != player_node->getName())
newStr += *it + ",";
@@ -1198,8 +1197,7 @@ void replaceVars(std::string &str)
if (player_node->isInParty() && (party = player_node->getParty()))
{
party->getNames(names);
- for (StringVectCIter it = names.begin(), it_end = names.end();
- it != it_end; ++ it)
+ FOR_EACH (StringVectCIter, it, names)
{
if (*it != player_node->getName())
newStr += *it + ",";
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 837d3830c..45c408b49 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -77,8 +77,7 @@ bool CompoundSprite::reset()
{
bool ret = false;
- for (SpriteIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteIterator, it, mSprites)
{
if (*it)
ret |= (*it)->reset();
@@ -92,8 +91,7 @@ bool CompoundSprite::play(std::string action)
{
bool ret = false;
- for (SpriteIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteIterator, it, mSprites)
{
if (*it)
ret |= (*it)->play(action);
@@ -107,8 +105,7 @@ bool CompoundSprite::update(int time)
{
bool ret = false;
- for (SpriteIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteIterator, it, mSprites)
{
if (*it)
ret |= (*it)->update(time);
@@ -147,8 +144,7 @@ bool CompoundSprite::draw(Graphics *graphics, int posX, int posY) const
void CompoundSprite::drawSprites(Graphics* graphics, int posX, int posY) const
{
- for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if (*it)
{
@@ -161,8 +157,7 @@ void CompoundSprite::drawSprites(Graphics* graphics, int posX, int posY) const
void CompoundSprite::drawSpritesSDL(Graphics* graphics,
int posX, int posY) const
{
- for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if (*it)
(*it)->draw(graphics, posX, posY);
@@ -173,8 +168,7 @@ int CompoundSprite::getWidth() const
{
const Sprite *base = nullptr;
- for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if ((base = *it))
{
@@ -190,8 +184,7 @@ int CompoundSprite::getHeight() const
{
const Sprite *base = nullptr;
- for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if ((base = *it))
{
@@ -212,8 +205,7 @@ bool CompoundSprite::setSpriteDirection(const SpriteDirection direction)
{
bool ret = false;
- for (SpriteIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteIterator, it, mSprites)
{
if (*it)
ret |= (*it)->setSpriteDirection(direction);
@@ -233,8 +225,7 @@ int CompoundSprite::getNumberOfLayers() const
unsigned int CompoundSprite::getCurrentFrame() const
{
- for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if (*it)
return (*it)->getCurrentFrame();
@@ -245,8 +236,7 @@ unsigned int CompoundSprite::getCurrentFrame() const
unsigned int CompoundSprite::getFrameCount() const
{
- for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if (*it)
return (*it)->getFrameCount();
@@ -424,8 +414,7 @@ void CompoundSprite::setAlpha(float alpha)
if (mEnableAlphaFix && size() > 3)
#endif
{
- for (SpriteConstIterator it = mSprites.begin(),
- it_end = mSprites.end(); it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if (*it)
(*it)->setAlpha(alpha);
@@ -496,8 +485,7 @@ bool CompoundSprite::updateFromCache() const
// (int)imagesCache.size(), hits, miss);
const size_t sz = size();
- for (ImagesCache::iterator it = imagesCache.begin(),
- it_end = imagesCache.end(); it != it_end; ++ it)
+ FOR_EACH (ImagesCache::iterator, it, imagesCache)
{
CompoundItem *const ic = *it;
if (ic && ic->data.size() == sz)
@@ -548,8 +536,7 @@ void CompoundSprite::initCurrentCacheItem() const
mCacheItem->alphaImage = mAlphaImage;
// mCacheItem->alpha = mAlpha;
- for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end();
- it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if (*it)
mCacheItem->data.push_back((*it)->getHash());
@@ -561,8 +548,7 @@ void CompoundSprite::initCurrentCacheItem() const
bool CompoundSprite::updateNumber(unsigned num)
{
bool res(false);
- for (SpriteConstIterator it = mSprites.begin(),
- it_end = mSprites.end(); it != it_end; ++ it)
+ FOR_EACH (SpriteConstIterator, it, mSprites)
{
if (*it)
{
diff --git a/src/configuration.cpp b/src/configuration.cpp
index cb9235c3f..1de179f6e 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -221,11 +221,8 @@ void Configuration::setValue(const std::string &key, const std::string &value)
if (list != mListenerMap.end())
{
Listeners listeners = list->second;
- for (ListenerIterator i = listeners.begin(), i_end = listeners.end();
- i != i_end; ++i)
- {
+ FOR_EACH (ListenerIterator, i, listeners)
(*i)->optionChanged(key);
- }
}
}
@@ -746,8 +743,7 @@ void Configuration::reInit()
void ConfigurationObject::writeToXML(const XmlTextWriterPtr writer)
{
- for (Options::const_iterator i = mOptions.begin(), i_end = mOptions.end();
- i != i_end; ++i)
+ FOR_EACH (Options::const_iterator, i, mOptions)
{
#ifdef DEBUG_CONFIG
if (mLogKeys)
@@ -772,8 +768,7 @@ void ConfigurationObject::writeToXML(const XmlTextWriterPtr writer)
XmlTextWriterWriteAttribute(writer, "name", name);
// recurse on all elements
- for (ConfigurationList::const_iterator elt_it = it->second.begin(),
- elt_it_end = it->second.end(); elt_it != elt_it_end; ++elt_it)
+ FOR_EACH (ConfigurationList::const_iterator, elt_it, it->second)
{
XmlTextWriterStartElement(writer, name);
if (*elt_it)
@@ -836,11 +831,8 @@ void Configuration::removeListener(const std::string &key,
void Configuration::removeListeners(ConfigListener *const listener)
{
- for (ListenerMapIterator it = mListenerMap.begin(),
- it_end = mListenerMap.end(); it != it_end; ++ it)
- {
+ FOR_EACH (ListenerMapIterator, it, mListenerMap)
(it->second).remove(listener);
- }
}
void Configuration::removeOldKeys()
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
index aea3fed3c..bdbcf051c 100644
--- a/src/effectmanager.cpp
+++ b/src/effectmanager.cpp
@@ -68,8 +68,7 @@ bool EffectManager::trigger(const int id, Being *const being,
return false;
bool rValue = false;
- for (std::vector<EffectDescription>::const_iterator i = mEffects.begin(),
- i_end = mEffects.end(); i != i_end; ++i)
+ FOR_EACH (std::vector<EffectDescription>::const_iterator, i, mEffects)
{
if ((*i).id == id)
{
@@ -95,8 +94,7 @@ bool EffectManager::trigger(const int id, const int x, const int y,
return false;
bool rValue = false;
- for (std::vector<EffectDescription>::const_iterator i = mEffects.begin(),
- i_end = mEffects.end(); i != i_end; ++i)
+ FOR_EACH (std::vector<EffectDescription>::const_iterator, i, mEffects)
{
if ((*i).id == id)
{
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index b6cb51455..ba3ca95ad 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -283,9 +283,7 @@ void GraphicsManager::setVideoMode()
std::string str = strprintf("%dx%d", width, height);
if (width != 0 && height != 0)
{
- for (StringVectCIter it = videoModes.begin(),
- it_end = videoModes.end();
- it != it_end; ++ it)
+ FOR_EACH (StringVectCIter, it, videoModes)
{
if (str == *it)
{
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp
index 29b2a87a8..38a743822 100644
--- a/src/inputmanager.cpp
+++ b/src/inputmanager.cpp
@@ -653,8 +653,7 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap,
}
keySorter.keys = &keyData[0];
- for (KeyToActionMapIter it = actionMap.begin(), it_end = actionMap.end();
- it != it_end; ++ it)
+ FOR_EACH (KeyToActionMapIter, it, actionMap)
{
KeysVector *const keys = &it->second;
if (keys && keys->size() > 1)
@@ -669,8 +668,7 @@ bool InputManager::triggerAction(const KeysVector *const ptrs)
// logger->log("ptrs: %d", (int)ptrs.size());
- for (KeysVectorCIter it = ptrs->begin(), it_end = ptrs->end();
- it != it_end; ++ it)
+ FOR_EACHP (KeysVectorCIter, it, ptrs)
{
const int keyNum = *it;
if (keyNum < 0 || keyNum >= Input::KEY_TOTAL)
diff --git a/src/inventory.cpp b/src/inventory.cpp
index c4416a002..a75a7a12e 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -202,11 +202,8 @@ void Inventory::removeInventoyListener(InventoryListener* const listener)
void Inventory::distributeSlotsChangedEvent()
{
- for (InventoryListenerList::const_iterator i = mInventoryListeners.begin(),
- i_end = mInventoryListeners.end(); i != i_end; ++i)
- {
+ FOR_EACH (InventoryListenerList::const_iterator, i, mInventoryListeners)
(*i)->slotsChanged(this);
- }
}
Item *Inventory::findItemBySprite(std::string spritePath,
diff --git a/src/joystick.cpp b/src/joystick.cpp
index 3b88e5668..42dd14bd1 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -334,8 +334,7 @@ bool Joystick::validate() const
void Joystick::handleRepeat(const int time)
{
- for (KeyTimeMapIter it = mKeyTimeMap.begin(), it_end = mKeyTimeMap.end();
- it != it_end; ++ it)
+ FOR_EACH (KeyTimeMapIter, it, mKeyTimeMap)
{
bool repeat(false);
const int key = (*it).first;
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 9e7931626..33c1e3237 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -194,8 +194,7 @@ void KeyboardConfig::handleDeActicateKey(const int key)
void KeyboardConfig::handleRepeat(const int time)
{
- for (KeyTimeMapIter it = mKeyTimeMap.begin(), it_end = mKeyTimeMap.end();
- it != it_end; ++ it)
+ FOR_EACH (KeyTimeMapIter, it, mKeyTimeMap)
{
bool repeat(false);
const int key = (*it).first;
diff --git a/src/localconsts.h b/src/localconsts.h
index bde91720a..ba803ca86 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -59,6 +59,9 @@
#define FOR_EACH(type, iter, array) for (type iter = array.begin(), \
iter##_end = array.end(); iter != iter##_end; ++ iter)
+#define FOR_EACHP(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
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 7fc7d725c..0a571b3f2 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -75,6 +75,8 @@
const short awayLimitTimer = 60;
+typedef std::map<int, Guild*>::const_iterator GuildMapCIter;
+
LocalPlayer *player_node = nullptr;
extern std::list<BeingCacheEntry*> beingInfoCache;
@@ -903,8 +905,7 @@ void LocalPlayer::inviteToGuild(Being *const being)
// TODO: Allow user to choose which guild to invite being to
// For now, just invite to the first guild you have permissions to invite with
- for (std::map<int, Guild*>::const_iterator itr = mGuilds.begin(),
- itr_end = mGuilds.end(); itr != itr_end; ++itr)
+ FOR_EACH (GuildMapCIter, itr, mGuilds)
{
if (itr->second && checkInviteRights(itr->second->getName()))
{
diff --git a/src/map.cpp b/src/map.cpp
index 899c0acbf..ec9c42e65 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -109,8 +109,7 @@ bool TileAnimation::update(const int ticks)
Image *const img = mAnimation->getCurrentImage();
if (img != mLastImage)
{
- for (TilePairVectorCIter i = mAffected.begin(),
- i_end = mAffected.end(); i != i_end; ++i)
+ FOR_EACH (TilePairVectorCIter, i, mAffected)
{
if (i->first)
i->first->setTile(i->second, img);
@@ -311,9 +310,7 @@ void Map::addTileset(Tileset *const tileset)
void Map::update(const int ticks)
{
// Update animated tiles
- for (TileAnimationMapCIter iAni = mTileAnimations.begin(),
- i_end = mTileAnimations.end();
- iAni != i_end; ++iAni)
+ FOR_EACH (TileAnimationMapCIter, iAni, mTileAnimations)
{
if (iAni->second && iAni->second->update(ticks))
mRedrawMap = true;
@@ -566,17 +563,11 @@ void Map::updateAmbientLayers(const float scrollX, const float scrollY)
const float dy = scrollY - mLastAScrollY;
const int timePassed = get_elapsed_time(lastTick);
- for (AmbientLayerVectorCIter i = mBackgrounds.begin(),
- i_end = mBackgrounds.end(); i != i_end; ++i)
- {
+ FOR_EACH (AmbientLayerVectorCIter, i, mBackgrounds)
(*i)->update(timePassed, dx, dy);
- }
- for (AmbientLayerVectorCIter i = mForegrounds.begin(),
- i_end = mForegrounds.end(); i != i_end; ++i)
- {
+ FOR_EACH (AmbientLayerVectorCIter, i, mForegrounds)
(*i)->update(timePassed, dx, dy);
- }
mLastAScrollX = scrollX;
mLastAScrollY = scrollY;
@@ -610,8 +601,7 @@ void Map::drawAmbientLayers(Graphics *const graphics, const LayerType type,
}
// Draw overlays
- for (AmbientLayerVectorCIter i = layers->begin(), i_end = layers->end();
- i != i_end; ++i)
+ FOR_EACHP (AmbientLayerVectorCIter, i, layers)
{
if (*i)
(*i)->draw(graphics, graphics->mWidth, graphics->mHeight);
@@ -1103,12 +1093,10 @@ void Map::initializeParticleEffects(Particle *const engine)
if (!engine)
return;
-
if (config.getBoolValue("particleeffects"))
{
- for (std::vector<ParticleEffectData>::const_iterator
- i = particleEffects.begin();
- i != particleEffects.end(); ++i)
+ FOR_EACH (std::vector<ParticleEffectData>::const_iterator,
+ i, particleEffects)
{
Particle *const p = engine->addEffect(i->file, i->x, i->y);
if (p && i->w > 0 && i->h > 0)
@@ -1288,8 +1276,7 @@ void Map::updatePortalTile(const std::string &name, const int type,
MapItem *Map::findPortalXY(const int x, const int y) const
{
- for (std::vector<MapItem*>::const_iterator it = mMapPortals.begin(),
- it_end = mMapPortals.end(); it != it_end; ++it)
+ FOR_EACH (std::vector<MapItem*>::const_iterator, it, mMapPortals)
{
if (!*it)
continue;
@@ -1372,9 +1359,7 @@ void Map::indexTilesets()
mTilesetsIndexed = true;
Tileset *s = nullptr;
- for (Tilesets::const_iterator it = mTilesets.begin(),
- it_end = mTilesets.end(); it < it_end;
- ++it)
+ FOR_EACH (Tilesets::const_iterator, it, mTilesets)
{
if (!s || s->getFirstGid() + s->size()
< (*it)->getFirstGid() + (*it)->size())
@@ -1395,9 +1380,7 @@ void Map::indexTilesets()
mIndexedTilesets = new Tileset*[size];
std::fill_n(mIndexedTilesets, size, static_cast<Tileset*>(nullptr));
- for (Tilesets::const_iterator it = mTilesets.begin(),
- it_end = mTilesets.end(); it < it_end;
- ++it)
+ FOR_EACH (Tilesets::const_iterator, it, mTilesets)
{
s = *it;
if (s)
@@ -1439,9 +1422,7 @@ void Map::reduce()
bool correct(true);
bool dontHaveAlpha(false);
- for (LayersCIter layeri = mLayers.begin(),
- layeri_end = mLayers.end();
- layeri != layeri_end; ++ layeri)
+ FOR_EACH (LayersCIter, layeri, mLayers)
{
const MapLayer *const layer = *layeri;
if (x >= layer->mWidth || y >= layer->mHeight)
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index 7f952060d..dcc9621d2 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -618,8 +618,7 @@ void SpecialLayer::setTile(const int x, const int y, const int type)
void SpecialLayer::addRoad(Path road)
{
- for (Path::const_iterator i = road.begin(), i_end = road.end();
- i != i_end; ++i)
+ FOR_EACH (Path::const_iterator, i, road)
{
const Position &pos = (*i);
MapItem *item = getTile(pos.x, pos.y);
diff --git a/src/particle.cpp b/src/particle.cpp
index 666821b93..a14fac698 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -204,12 +204,10 @@ bool Particle::update()
// Update child emitters
if ((mLifetimePast - 1) % Particle::emitterSkip == 0)
{
- for (EmitterConstIterator e = mChildEmitters.begin(),
- e2 = mChildEmitters.end(); e != e2; ++ e)
+ FOR_EACH (EmitterConstIterator, e, mChildEmitters)
{
Particles newParticles = (*e)->createParticles(mLifetimePast);
- for (ParticleConstIterator p = newParticles.begin(),
- p2 = newParticles.end(); p != p2; ++ p)
+ FOR_EACH (ParticleConstIterator, p, newParticles)
{
(*p)->moveBy(mPos);
mChildParticles.push_back (*p);
@@ -262,8 +260,7 @@ bool Particle::update()
void Particle::moveBy(const Vector &change)
{
mPos += change;
- for (ParticleConstIterator p = mChildParticles.begin(),
- p2 = mChildParticles.end(); p != p2; ++p)
+ FOR_EACH (ParticleConstIterator, p, mChildParticles)
{
if ((*p)->doesFollow())
(*p)->moveBy(change);
@@ -461,11 +458,8 @@ void Particle::adjustEmitterSize(const int w, const int h)
{
if (mAllowSizeAdjust)
{
- for (EmitterConstIterator e = mChildEmitters.begin(),
- e2 = mChildEmitters.end(); e != e2; ++e)
- {
+ FOR_EACH (EmitterConstIterator, e, mChildEmitters)
(*e)->adjustSize(w, h);
- }
}
}
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index 782b8fb24..4994ddadd 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -25,6 +25,9 @@
#include "debug.h"
+typedef std::list<Particle *>::iterator ParticleListIter;
+typedef std::list<Particle *>::const_iterator ParticleListCIter;
+
ParticleContainer::ParticleContainer(ParticleContainer *const parent,
const bool delParent):
mDelParent(delParent),
@@ -93,11 +96,8 @@ void ParticleList::removeLocally(const Particle *const particle)
void ParticleList::clearLocally()
{
- for (std::list<Particle *>::const_iterator it = mElements.begin(),
- it_end = mElements.end(); it != it_end; ++ it)
- {
+ FOR_EACH (ParticleListCIter, it, mElements)
(*it)->kill();
- }
mElements.clear();
}
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index 7f69afe83..0aea1eaca 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -38,6 +38,9 @@
static const float SIN45 = 0.707106781f;
static const float DEG_RAD_FACTOR = 0.017453293f;
+typedef std::vector<ImageSet*>::const_iterator ImageSetVectorCIter;
+typedef std::list<ParticleEmitter>::const_iterator ParticleEmitterListCIter;
+
ParticleEmitter::ParticleEmitter(const XmlNodePtr emitterNode,
Particle *const target,
Map *const map, const int rotation,
@@ -435,9 +438,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
mDeathEffect = o.mDeathEffect;
mTempSets = o.mTempSets;
- for (std::vector<ImageSet*>::const_iterator
- i = mTempSets.begin(), i_end = mTempSets.end();
- i != i_end; ++ i)
+ FOR_EACH (ImageSetVectorCIter, i, mTempSets)
{
if (*i)
(*i)->incRef();
@@ -453,9 +454,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o)
ParticleEmitter::~ParticleEmitter()
{
- for (std::vector<ImageSet*>::const_iterator
- i = mTempSets.begin(), i_end = mTempSets.end();
- i != i_end; ++i)
+ FOR_EACH (ImageSetVectorCIter, i, mTempSets)
{
if (*i)
(*i)->decRef();
@@ -576,13 +575,8 @@ std::list<Particle *> ParticleEmitter::createParticles(const int tick)
newParticle->setFadeIn(mParticleFadeIn.value(tick));
newParticle->setAlpha(mParticleAlpha.value(tick));
- for (std::list<ParticleEmitter>::const_iterator
- it = mParticleChildEmitters.begin(),
- it_end = mParticleChildEmitters.end();
- it != it_end; ++it)
- {
+ FOR_EACH (ParticleEmitterListCIter, it, mParticleChildEmitters)
newParticle->addEmitter(new ParticleEmitter(*it));
- }
if (!mDeathEffect.empty())
newParticle->setDeathEffect(mDeathEffect, mDeathEffectConditions);
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 6fb482eb8..5721d2d67 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -265,8 +265,7 @@ void logic()
if ((mSpecialRechargeUpdateNeeded % 11) == 0)
{
mSpecialRechargeUpdateNeeded = 0;
- for (SpecialsMap::iterator it = mSpecials.begin(),
- it_end = mSpecials.end(); it != it_end; ++it)
+ FOR_EACH (SpecialsMap::iterator, it, mSpecials)
{
Special &special = it->second;
special.currentMana += special.recharge;
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index fee43107e..7d7716c3e 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -137,21 +137,16 @@ PlayerRelationsManager::~PlayerRelationsManager()
{
delete_all(mIgnoreStrategies);
- for (PlayerRelationsCIter it = mRelations.begin(),
- it_end = mRelations.end(); it != it_end; ++ it)
- {
+ FOR_EACH (PlayerRelationsCIter, it, mRelations)
delete it->second;
- }
+ mRelations.clear();
}
void PlayerRelationsManager::clear()
{
StringVect *names = getPlayers();
- for (StringVectCIter it = names->begin(), it_end = names->end();
- it != it_end; ++ it)
- {
+ FOR_EACHP (StringVectCIter, it, names)
removePlayer(*it);
- }
delete names;
}
@@ -217,11 +212,8 @@ void PlayerRelationsManager::init()
// until the next update.
}
- for (PlayerRelationListenersCIter it = mListeners.begin(),
- it_end = mListeners.end(); it != it_end; ++it)
- {
+ FOR_EACH (PlayerRelationListenersCIter, it, mListeners)
(*it)->updateAll();
- }
}
void PlayerRelationsManager::store()
@@ -245,11 +237,8 @@ void PlayerRelationsManager::store()
void PlayerRelationsManager::signalUpdate(const std::string &name)
{
- for (PlayerRelationListenersCIter it = mListeners.begin(),
- it_end = mListeners.end(); it != it_end; ++ it)
- {
+ FOR_EACH (PlayerRelationListenersCIter, it, mListeners)
(*it)->updatedPlayer(name);
- }
if (actorSpriteManager)
{
@@ -357,8 +346,7 @@ StringVect * PlayerRelationsManager::getPlayers()
{
StringVect *const retval = new StringVect();
- for (PlayerRelationsCIter it = mRelations.begin(),
- it_end = mRelations.end(); it != it_end; ++ it)
+ FOR_EACH (PlayerRelationsCIter, it, mRelations)
{
if (it->second)
retval->push_back(it->first);
@@ -374,8 +362,7 @@ StringVect *PlayerRelationsManager::getPlayersByRelation(
{
StringVect *const retval = new StringVect();
- for (PlayerRelationsCIter it = mRelations.begin(),
- it_end = mRelations.end(); it != it_end; ++ it)
+ FOR_EACH (PlayerRelationsCIter, it, mRelations)
{
if (it->second && it->second->mRelation == rel)
retval->push_back(it->first);
diff --git a/src/textmanager.cpp b/src/textmanager.cpp
index 702b024f1..96f5612bb 100644
--- a/src/textmanager.cpp
+++ b/src/textmanager.cpp
@@ -48,8 +48,7 @@ void TextManager::moveText(Text *const text, const int x, const int y)
void TextManager::removeText(const Text *const text)
{
- for (TextList::iterator ptr = mTextList.begin(),
- pEnd = mTextList.end(); ptr != pEnd; ++ptr)
+ FOR_EACH (TextList::iterator, ptr, mTextList)
{
if (*ptr == text)
{
@@ -67,12 +66,8 @@ void TextManager::draw(Graphics *const graphics,
const int xOff, const int yOff)
{
BLOCK_START("TextManager::draw")
- for (TextList::const_iterator bPtr = mTextList.begin(),
- ePtr = mTextList.end();
- bPtr != ePtr; ++ bPtr)
- {
+ FOR_EACH (TextList::const_iterator, bPtr, mTextList)
(*bPtr)->draw(graphics, xOff, yOff);
- }
BLOCK_END("TextManager::draw")
}
@@ -110,10 +105,8 @@ void TextManager::place(const Text *const textObj, const Text *const omit,
}
}
bool ok = true;
- for (int i = wantedTop; i < wantedTop + h; ++i)
- {
+ for (int i = wantedTop; i < wantedTop + h; ++ i)
ok = ok && !occupied[i];
- }
if (ok)
return;
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index c8d813998..18bcd4a0d 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -158,11 +158,8 @@ void TouchManager::clear()
Theme *theme = Theme::instance();
if (!theme)
return;
- for (TouchItemVectorCIter it = mObjects.begin(), it_end = mObjects.end();
- it != it_end; ++ it)
- {
+ FOR_EACH (TouchItemVectorCIter, it, mObjects)
unload(*it);
- }
mObjects.clear();
mRedraw = true;
}
@@ -175,9 +172,7 @@ void TouchManager::draw()
{
mRedraw = false;
mVertexes->clear();
- for (TouchItemVectorCIter it = mObjects.begin(),
- it_end = mObjects.end();
- it != it_end; ++ it)
+ FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
if (item && item->images && (mShow ||
@@ -199,9 +194,7 @@ void TouchManager::draw()
}
else
{
- for (TouchItemVectorCIter it = mObjects.begin(),
- it_end = mObjects.end();
- it != it_end; ++ it)
+ FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
if (item && item->images && (mShow ||
@@ -226,8 +219,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput)
const int x = mouseInput.getTouchX();
const int y = mouseInput.getTouchY();
- for (TouchItemVectorCIter it = mObjects.begin(), it_end = mObjects.end();
- it != it_end; ++ it)
+ FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;
if (!item || (!mShow && (item != mKeyboard || !mShowKeyboard)))
@@ -278,8 +270,7 @@ bool TouchManager::isActionActive(const int index) const
void TouchManager::resize(int width, int height)
{
mRedraw = true;
- for (TouchItemVectorCIter it = mObjects.begin(),
- it_end = mObjects.end(); it != it_end; ++ it)
+ FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
TouchItem *const item = *it;
if (!item)
@@ -338,8 +329,7 @@ void TouchManager::unloadTouchItem(TouchItem **unloadItem)
Theme *theme = Theme::instance();
if (!theme)
return;
- for (TouchItemVectorIter it = mObjects.begin(), it_end = mObjects.end();
- it != it_end; ++ it)
+ FOR_EACH (TouchItemVectorIter, it, mObjects)
{
TouchItem *item = *it;
if (item && *unloadItem == item)