diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-04-25 02:26:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-04-25 02:26:34 +0300 |
commit | c9f43996f3147100627ee2c6f9da993ceb160113 (patch) | |
tree | 7577f02f4658b19e05d586f66b67a9a4f5fedb7e /src | |
parent | 8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf (diff) | |
download | ManaVerse-c9f43996f3147100627ee2c6f9da993ceb160113.tar.gz ManaVerse-c9f43996f3147100627ee2c6f9da993ceb160113.tar.bz2 ManaVerse-c9f43996f3147100627ee2c6f9da993ceb160113.tar.xz ManaVerse-c9f43996f3147100627ee2c6f9da993ceb160113.zip |
Improve iterators part 2.
Diffstat (limited to 'src')
34 files changed, 236 insertions, 219 deletions
diff --git a/src/actor.h b/src/actor.h index 51cba0c60..4c566ea5e 100644 --- a/src/actor.h +++ b/src/actor.h @@ -32,6 +32,7 @@ class Image; class Map; typedef std::list<Actor*> Actors; +typedef Actors::const_iterator ActorsCIter; class Actor { diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index e558e2469..e86c886e4 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -116,8 +116,8 @@ void ActorSprite::logic() if (mMustResetParticles) { mMustResetParticles = false; - for (std::set<int>::const_iterator it = mStatusEffects.begin(); - it != mStatusEffects.end(); ++it) + for (std::set<int>::const_iterator it = mStatusEffects.begin(), + it_end = mStatusEffects.end(); it != it_end; ++it) { const StatusEffect *effect = StatusEffect::getStatusEffect(*it, true); @@ -372,9 +372,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, //setup particle effects if (Particle::enabled && particleEngine) { - StringVectCIter itr; - StringVectCIter itr_end; - for (itr = display.particles.begin(), + for (StringVectCIter itr = display.particles.begin(), itr_end = display.particles.end(); itr != itr_end; ++itr) { diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index bcb807131..327d45a89 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -1133,7 +1133,8 @@ void ActorSpriteManager::addBlock(Uint32 id) void ActorSpriteManager::deleteBlock(Uint32 id) { std::vector<Uint32>::iterator iter = blockedBeings.begin(); - while (iter != blockedBeings.end()) + std::vector<Uint32>::iterator iter_end = blockedBeings.end(); + while (iter != iter_end) { if (*iter == id) { @@ -1171,7 +1172,8 @@ void ActorSpriteManager::printBeingsToChat(ActorSprites beings, debugChatTab->chatLog("---------------------------------------"); debugChatTab->chatLog(header); std::set<ActorSprite*>::const_iterator it; - for (it = beings.begin(); it != beings.end(); ++it) + std::set<ActorSprite*>::const_iterator it_end = beings.end(); + for (it = beings.begin(); it != it_end; ++it) { if (!*it) continue; @@ -1199,7 +1201,8 @@ void ActorSpriteManager::printBeingsToChat(std::vector<Being*> beings, debugChatTab->chatLog(header); std::vector<Being*>::const_iterator i; - for (i = beings.begin(); i != beings.end(); ++i) + std::vector<Being*>::const_iterator i_end = beings.end(); + for (i = beings.begin(); i != i_end; ++i) { if (!*i) continue; @@ -1484,7 +1487,8 @@ void ActorSpriteManager::loadAttackList() std::list<std::string> list = unpackList( serverConfig.getValue("attackPriorityMobs", "")); std::list<std::string>::const_iterator i = list.begin(); - while (i != list.end()) + std::list<std::string>::const_iterator i_end = list.end(); + while (i != i_end) { if (*i == "") empty = true; @@ -1495,7 +1499,8 @@ void ActorSpriteManager::loadAttackList() list = unpackList(serverConfig.getValue("attackMobs", "")); i = list.begin(); - while (i != list.end()) + i_end = list.end(); + while (i != i_end) { if (*i == "") empty = true; @@ -1506,7 +1511,8 @@ void ActorSpriteManager::loadAttackList() list = unpackList(serverConfig.getValue("ignoreAttackMobs", "")); i = list.begin(); - while (i != list.end()) + i_end = list.end(); + while (i != i_end) { if (*i == "") empty = true; diff --git a/src/being.cpp b/src/being.cpp index 75c215992..3459132b7 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -855,8 +855,8 @@ void Being::removeGuild(int id) Guild *Being::getGuild(const std::string &guildName) const { - std::map<int, Guild*>::const_iterator itr, itr_end = mGuilds.end(); - for (itr = mGuilds.begin(); itr != itr_end; ++itr) + for (std::map<int, Guild*>::const_iterator itr = mGuilds.begin(), + itr_end = mGuilds.end(); itr != itr_end; ++itr) { Guild *guild = itr->second; if (guild && guild->getName() == guildName) @@ -868,8 +868,7 @@ Guild *Being::getGuild(const std::string &guildName) const Guild *Being::getGuild(int id) const { - std::map<int, Guild*>::const_iterator itr; - itr = mGuilds.find(id); + std::map<int, Guild*>::const_iterator itr = mGuilds.find(id); if (itr != mGuilds.end()) return itr->second; @@ -878,8 +877,7 @@ Guild *Being::getGuild(int id) const Guild *Being::getGuild() const { - std::map<int, Guild*>::const_iterator itr; - itr = mGuilds.begin(); + std::map<int, Guild*>::const_iterator itr = mGuilds.begin(); if (itr != mGuilds.end()) return itr->second; @@ -888,8 +886,8 @@ Guild *Being::getGuild() const void Being::clearGuilds() { - std::map<int, Guild*>::const_iterator itr, itr_end = mGuilds.end(); - for (itr = mGuilds.begin(); itr != itr_end; ++itr) + for (std::map<int, Guild*>::const_iterator itr = mGuilds.begin(), + itr_end = mGuilds.end(); itr != itr_end; ++itr) { Guild *guild = itr->second; @@ -1931,7 +1929,7 @@ void Being::addToCache() BeingCacheEntry* Being::getCacheEntry(int id) { for (std::list<BeingCacheEntry*>::iterator i = beingInfoCache.begin(); - i != beingInfoCache.end(); ++i) + i != beingInfoCache.end(); ++ i) { if (!*i) continue; @@ -2247,10 +2245,8 @@ void Being::recalcSpritesOrder() if (spriteToItems) { - SpriteToItemMap::const_iterator itr; - - for (itr = spriteToItems->begin(); - itr != spriteToItems->end(); ++itr) + for (SpriteToItemMapCIter itr = spriteToItems->begin(), + itr_end = spriteToItems->end(); itr != itr_end; ++ itr) { int remSprite = itr->first; const std::map<int, int> &itemReplacer = itr->second; @@ -2284,11 +2280,10 @@ void Being::recalcSpritesOrder() } else { // slot unknown. Search for real slot, this can be slow - std::map<int, int>::const_iterator repIt - = itemReplacer.begin(); - std::map<int, int>::const_iterator repIt_end - = itemReplacer.end(); - for (; repIt != repIt_end; ++ repIt) + for (std::map<int, int>::const_iterator + repIt = itemReplacer.begin(), + repIt_end = itemReplacer.end(); + repIt != repIt_end; ++ repIt) { for (unsigned slot2 = 0; slot2 < sz; slot2 ++) { @@ -2312,9 +2307,7 @@ void Being::recalcSpritesOrder() if (info.mDrawBefore[dir] > 0) { int id2 = mSpriteIDs[info.mDrawBefore[dir]]; - std::map<int, int>::const_iterator - orderIt = itemSlotRemap.find(id2); - if (orderIt != itemSlotRemap.end()) + if (itemSlotRemap.find(id2) != itemSlotRemap.end()) { // logger->log("found duplicate (before)"); const ItemInfo &info2 = ItemDB::get(id2); @@ -2336,9 +2329,7 @@ void Being::recalcSpritesOrder() else if (info.mDrawAfter[dir] > 0) { int id2 = mSpriteIDs[info.mDrawAfter[dir]]; - std::map<int, int>::const_iterator - orderIt = itemSlotRemap.find(id2); - if (orderIt != itemSlotRemap.end()) + if (itemSlotRemap.find(id2) != itemSlotRemap.end()) { // logger->log("found duplicate (after)"); const ItemInfo &info2 = ItemDB::get(id2); @@ -2464,8 +2455,9 @@ void Being::searchSlotValueItr(std::vector<int>::iterator &it, int &idx, { // logger->log("searching %d", val); it = slotRemap.begin(); + std::vector<int>::iterator it_end = slotRemap.end(); idx = 0; - while (it != slotRemap.end()) + while (it != it_end) { // logger->log("testing %d", *it); if (*it == val) diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 95d987ead..0e0ec4cff 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -1214,7 +1214,8 @@ void showRes(std::string str, ResourceManager::Resources *res) debugChatTab->chatLog(str + toString(res->size())); logger->log(str + toString(res->size())); ResourceManager::ResourceIterator iter = res->begin(); - while (iter != res->end()) + ResourceManager::ResourceIterator iter_end = res->end(); + while (iter != iter_end) { if (iter->second && iter->second->getRefCount()) { @@ -1311,9 +1312,8 @@ void CommandHandler::replaceVars(std::string &str) StringVect names; std::string newStr = ""; actorSpriteManager->getPlayerNames(names, false); - StringVectCIter it = names.begin(); - StringVectCIter it_end = names.end(); - for (; it != it_end; ++ it) + for (StringVectCIter it = names.begin(), it_end = names.end(); + it != it_end; ++ it) { if (*it != player_node->getName()) newStr += *it + ","; @@ -1333,9 +1333,8 @@ void CommandHandler::replaceVars(std::string &str) if (player_node->isInParty() && (party = player_node->getParty())) { party->getNames(names); - StringVectCIter it = names.begin(); - StringVectCIter it_end = names.end(); - for (; it != it_end; ++ it) + for (StringVectCIter it = names.begin(), it_end = names.end(); + it != it_end; ++ it) { if (*it != player_node->getName()) newStr += *it + ","; diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index 62ef2d01c..e1d5d6b76 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -74,8 +74,8 @@ bool CompoundSprite::reset() { bool ret = false; - SpriteIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if (*it) ret |= (*it)->reset(); @@ -89,8 +89,8 @@ bool CompoundSprite::play(std::string action) { bool ret = false; - SpriteIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if (*it) ret |= (*it)->play(action); @@ -104,8 +104,8 @@ bool CompoundSprite::update(int time) { bool ret = false; - SpriteIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if (*it) ret |= (*it)->update(time); @@ -143,8 +143,8 @@ bool CompoundSprite::draw(Graphics *graphics, int posX, int posY) const void CompoundSprite::drawSprites(Graphics* graphics, int posX, int posY) const { - SpriteConstIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if (*it) { @@ -157,8 +157,8 @@ void CompoundSprite::drawSprites(Graphics* graphics, int posX, int posY) const void CompoundSprite::drawSpritesSDL(Graphics* graphics, int posX, int posY) const { - SpriteConstIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if (*it) (*it)->draw(graphics, posX, posY); @@ -169,8 +169,8 @@ int CompoundSprite::getWidth() const { Sprite *base = nullptr; - SpriteConstIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if ((base = (*it))) break; @@ -186,8 +186,8 @@ int CompoundSprite::getHeight() const { Sprite *base = nullptr; - SpriteConstIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if ((base = (*it))) break; @@ -208,8 +208,8 @@ bool CompoundSprite::setSpriteDirection(SpriteDirection direction) { bool ret = false; - SpriteIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if (*it) ret |= (*it)->setSpriteDirection(direction); @@ -229,8 +229,8 @@ int CompoundSprite::getNumberOfLayers() const unsigned int CompoundSprite::getCurrentFrame() const { - SpriteConstIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if (*it) return (*it)->getCurrentFrame(); @@ -241,8 +241,8 @@ unsigned int CompoundSprite::getCurrentFrame() const unsigned int CompoundSprite::getFrameCount() const { - SpriteConstIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteConstIterator it = mSprites.begin(), it_end = mSprites.end(); + it != it_end; ++ it) { if (*it) return (*it)->getFrameCount(); @@ -419,9 +419,8 @@ void CompoundSprite::setAlpha(float alpha) if (mEnableAlphaFix && size() > 3) #endif { - SpriteConstIterator it, it_end; - for (it = mSprites.begin(), it_end = mSprites.end(); - it != it_end; ++ it) + for (SpriteConstIterator it = mSprites.begin(), + it_end = mSprites.end(); it != it_end; ++ it) { if (*it) (*it)->setAlpha(alpha); @@ -464,8 +463,6 @@ void CompoundSprite::updateImages() const bool CompoundSprite::updateFromCache() const { - ImagesCache::iterator it = imagesCache.begin(); - ImagesCache::const_iterator it_end = imagesCache.end(); // static int hits = 0; // static int miss = 0; @@ -487,18 +484,20 @@ bool CompoundSprite::updateFromCache() const // logger->log("cache size: %d, hit %d, miss %d", // (int)imagesCache.size(), hits, miss); - for (it = imagesCache.begin(); it != it_end; ++ it) + for (ImagesCache::iterator it = imagesCache.begin(), + it_end = imagesCache.end(); it != it_end; ++ it) { CompoundItem *ic = *it; if (ic && ic->data.size() == size()) { bool fail(false); - SpriteConstIterator it1 = mSprites.begin(); - SpriteConstIterator it1_end = mSprites.end(); VectorPointers::const_iterator it2 = ic->data.begin(); VectorPointers::const_iterator it2_end = ic->data.end(); - for (; it1 != it1_end && it2 != it2_end; ++ it1, ++ it2) + for (SpriteConstIterator it1 = mSprites.begin(), + it1_end = mSprites.end(); + it1 != it1_end && it2 != it2_end; + ++ it1, ++ it2) { void *ptr1 = nullptr; void *ptr2 = nullptr; @@ -549,9 +548,9 @@ void CompoundSprite::initCurrentCacheItem() const bool CompoundSprite::updateNumber(unsigned num) { - SpriteConstIterator it, it_end; bool res(false); - for (it = mSprites.begin(), it_end = mSprites.end(); it != it_end; ++ it) + for (SpriteConstIterator it = mSprites.begin(), + it_end = mSprites.end(); it != it_end; ++ it) { if (*it) { diff --git a/src/configuration.cpp b/src/configuration.cpp index e4a1702de..684468997 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -222,8 +222,11 @@ 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 != listeners.end(); ++i) + for (ListenerIterator i = listeners.begin(), i_end = listeners.end(); + i != i_end; ++i) + { (*i)->optionChanged(key); + } } } @@ -735,8 +738,8 @@ void ConfigurationObject::writeToXML(XmlTextWriterPtr writer) } for (std::map<std::string, ConfigurationList>::const_iterator - it = mContainerOptions.begin(); - it != mContainerOptions.end(); ++it) + it = mContainerOptions.begin(), it_end = mContainerOptions.end(); + it != it_end; ++ it) { const char *name = it->first.c_str(); @@ -744,8 +747,8 @@ void ConfigurationObject::writeToXML(XmlTextWriterPtr writer) xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST name); // recurse on all elements - for (ConfigurationList::const_iterator elt_it = it->second.begin(); - elt_it != it->second.end(); ++elt_it) + for (ConfigurationList::const_iterator elt_it = it->second.begin(), + elt_it_end = it->second.end(); elt_it != elt_it_end; ++elt_it) { xmlTextWriterStartElement(writer, BAD_CAST name); if (*elt_it) @@ -807,10 +810,11 @@ void Configuration::removeListener(const std::string &key, void Configuration::removeListeners(ConfigListener *listener) { - ListenerMapIterator it = mListenerMap.begin(); - ListenerMapIterator it_end = mListenerMap.end(); - for (; it != it_end; ++ it) + for (ListenerMapIterator it = mListenerMap.begin(), + it_end = mListenerMap.end(); it != it_end; ++ it) + { (it->second).remove(listener); + } } void Configuration::removeOldKeys() diff --git a/src/depricatedevent.cpp b/src/depricatedevent.cpp index 8f0eadf82..d6a1f2935 100644 --- a/src/depricatedevent.cpp +++ b/src/depricatedevent.cpp @@ -117,7 +117,8 @@ void DepricatedEvent::trigger(Channels channel, const DepricatedEvent &event) // Loop though all listeners ListenerSet::const_iterator lit = it->second.begin(); - while (lit != it->second.end()) + ListenerSet::const_iterator lit_end = it->second.end(); + while (lit != lit_end) { if (*lit) (*lit)->processEvent(channel, event); diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index b52d2ac22..f477da631 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -68,8 +68,8 @@ bool EffectManager::trigger(int id, Being* being) return false; bool rValue = false; - for (std::vector<EffectDescription>::const_iterator i = mEffects.begin(); - i != mEffects.end(); ++i) + for (std::vector<EffectDescription>::const_iterator i = mEffects.begin(), + i_end = mEffects.end(); i != i_end; ++i) { if ((*i).id == id) { @@ -93,8 +93,8 @@ bool EffectManager::trigger(int id, int x, int y) return false; bool rValue = false; - for (std::vector<EffectDescription>::const_iterator i = mEffects.begin(); - i != mEffects.end(); ++i) + for (std::vector<EffectDescription>::const_iterator i = mEffects.begin(), + i_end = mEffects.end(); i != i_end; ++i) { if ((*i).id == id) { diff --git a/src/graphics.cpp b/src/graphics.cpp index 955b0fef5..44ff11783 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -504,11 +504,13 @@ void Graphics::drawImagePattern2(GraphicsVertexes *vert, Image *img) // here not checking input parameters std::vector<DoubleRect*> *arr = vert->getRectsSDL(); - std::vector<DoubleRect*>::const_iterator it; - for (it = arr->begin(); it != arr->end(); ++it) + for (std::vector<DoubleRect*>::const_iterator it = arr->begin(), + it_end = arr->end(); it != it_end; ++it) + { SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst); // SDL_BlitSurface(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst); + } } bool Graphics::calcImageRect(GraphicsVertexes* vert, diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index 60e4a7bca..3a4ee1b9b 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -106,10 +106,9 @@ void InputManager::retrieve() StringVect keys; splitToStringVector(keys, keyStr, ','); - StringVectCIter it = keys.begin(); - StringVectCIter it_end = keys.end(); int i2 = 0; - for (; it != it_end && i2 < KeyFunctionSize; ++ it) + for (StringVectCIter it = keys.begin(), it_end = keys.end(); + it != it_end && i2 < KeyFunctionSize; ++ it) { std::string keyStr2 = *it; if (keyStr.size() < 2) @@ -619,9 +618,8 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, } keySorter.keys = &keyData[0]; - KeyToActionMapIter it = actionMap.begin(); - KeyToActionMapIter it_end = actionMap.end(); - for (; it != it_end; ++ it) + for (KeyToActionMapIter it = actionMap.begin(), it_end = actionMap.end(); + it != it_end; ++ it) { KeysVector *keys = &it->second; if (keys && keys->size() > 1) @@ -635,10 +633,9 @@ bool InputManager::triggerAction(const KeysVector *ptrs) return false; // logger->log("ptrs: %d", (int)ptrs.size()); - KeysVectorCIter it = ptrs->begin(); - KeysVectorCIter it_end = ptrs->end(); - for (; it != it_end; ++ it) + for (KeysVectorCIter it = ptrs->begin(), it_end = ptrs->end(); + it != it_end; ++ it) { const int keyNum = *it; if (keyNum < 0 || keyNum >= Input::KEY_TOTAL) diff --git a/src/inventory.cpp b/src/inventory.cpp index b247b2f63..4b9a22739 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -198,10 +198,11 @@ void Inventory::removeInventoyListener(InventoryListener* listener) void Inventory::distributeSlotsChangedEvent() { - InventoryListenerList::const_iterator i = mInventoryListeners.begin(); - InventoryListenerList::const_iterator i_end = mInventoryListeners.end(); - for (; i != i_end; ++i) + for (InventoryListenerList::const_iterator i = mInventoryListeners.begin(), + i_end = mInventoryListeners.end(); i != i_end; ++i) + { (*i)->slotsChanged(this); + } } Item *Inventory::findItemBySprite(std::string spritePath, diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 9dc23a4c7..6cf02bf4a 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -909,9 +909,8 @@ void LocalPlayer::inviteToGuild(Being *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 - std::map<int, Guild*>::const_iterator itr = mGuilds.begin(); - std::map<int, Guild*>::const_iterator itr_end = mGuilds.end(); - for (; itr != itr_end; ++itr) + for (std::map<int, Guild*>::const_iterator itr = mGuilds.begin(), + itr_end = mGuilds.end(); itr != itr_end; ++itr) { if (itr->second && checkInviteRights(itr->second->getName())) { @@ -3402,8 +3401,8 @@ void LocalPlayer::saveHomes() std::string homeStr; std::stringstream ss(homeStr); - for (std::map<std::string, Vector>::const_iterator iter = mHomes.begin(); - iter != mHomes.end(); ++iter ) + for (std::map<std::string, Vector>::const_iterator iter = mHomes.begin(), + iter_end = mHomes.end(); iter != iter_end; ++iter ) { Vector pos = (*iter).second; diff --git a/src/map.cpp b/src/map.cpp index ebad60f84..1ffe20dd4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -108,8 +108,8 @@ bool TileAnimation::update(int ticks) Image *img = mAnimation->getCurrentImage(); if (img != mLastImage) { - for (std::vector<std::pair<MapLayer*, int> >::const_iterator i = - mAffected.begin(); i != mAffected.end(); ++i) + for (TilePairVectorCIter i = mAffected.begin(), i_end = mAffected.end(); + i != i_end; ++i) { if (i->first) i->first->setTile(i->second, img); @@ -304,9 +304,9 @@ void Map::addTileset(Tileset *tileset) void Map::update(int ticks) { // Update animated tiles - for (std::map<int, TileAnimation*>::const_iterator - iAni = mTileAnimations.begin(); - iAni != mTileAnimations.end(); ++iAni) + for (TileAnimationMapCIter iAni = mTileAnimations.begin(), + i_end = mTileAnimations.end(); + iAni != i_end; ++iAni) { if (iAni->second && iAni->second->update(ticks)) mRedrawMap = true; @@ -351,9 +351,6 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) graphics->mWidth, graphics->mHeight)); } - // draw the game world - Layers::const_iterator layeri = mLayers.begin(); - bool overFringe = false; int updateFlag = 0; @@ -392,7 +389,8 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) } else { - for (; layeri != mLayers.end() && !overFringe; ++layeri) + for (LayersCIter layeri = mLayers.begin(), layeri_end = mLayers.end(); + layeri != layeri_end && !overFringe; ++ layeri) { if ((*layeri)->isFringeLayer()) { @@ -439,8 +437,9 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) { // Draws beings with a lower opacity to make them visible // even when covered by a wall or some other elements... - Actors::const_iterator ai = mActors.begin(); - while (ai != mActors.end()) + ActorsCIter ai = mActors.begin(); + ActorsCIter ai_end = mActors.end(); + while (ai != ai_end) { if (Actor *actor = *ai) { @@ -600,12 +599,17 @@ void Map::updateAmbientLayers(float scrollX, float scrollY) float dy = scrollY - mLastAScrollY; int timePassed = get_elapsed_time(lastTick); - std::vector<AmbientLayer*>::const_iterator i; - for (i = mBackgrounds.begin(); i != mBackgrounds.end(); ++i) + for (AmbientLayerVectorCIter i = mBackgrounds.begin(), + i_end = mBackgrounds.end(); i != i_end; ++i) + { (*i)->update(timePassed, dx, dy); + } - for (i = mForegrounds.begin(); i != mForegrounds.end(); ++i) + for (AmbientLayerVectorCIter i = mForegrounds.begin(), + i_end = mForegrounds.end(); i != i_end; ++i) + { (*i)->update(timePassed, dx, dy); + } mLastAScrollX = scrollX; mLastAScrollY = scrollY; @@ -620,7 +624,7 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type, return; // find out which layer list to draw - std::vector<AmbientLayer*> *layers; + AmbientLayerVector *layers; switch (type) { case FOREGROUND_LAYERS: @@ -637,8 +641,8 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type, } // Draw overlays - for (std::vector<AmbientLayer*>::const_iterator i = layers->begin(); - i != layers->end(); ++i) + for (AmbientLayerVectorCIter i = layers->begin(), i_end = layers->end(); + i != i_end; ++i) { if (*i) (*i)->draw(graphics, graphics->mWidth, graphics->mHeight); @@ -863,8 +867,9 @@ Path Map::findPixelPath(int startPixelX, int startPixelY, int endPixelX, // Convert the map path to pixels over tiles // And add interpolation between the starting and ending offsets Path::iterator it = myPath.begin(); + Path::iterator it_end = myPath.end(); int i = 0; - while (it != myPath.end()) + while (it != it_end) { // A position that is valid on the start and end tile is not // necessarily valid on all the tiles in between, so check the offsets. @@ -1326,8 +1331,7 @@ TileAnimation *Map::getAnimationForGid(int gid) const if (mTileAnimations.empty()) return nullptr; - std::map<int, TileAnimation*>::const_iterator - i = mTileAnimations.find(gid); + TileAnimationMapCIter i = mTileAnimations.find(gid); return (i == mTileAnimations.end()) ? nullptr : i->second; } @@ -1373,7 +1377,8 @@ std::string Map::getObjectData(unsigned x, unsigned y, int type) return ""; std::vector<MapObject>::const_iterator it = list->objects.begin(); - while (it != list->objects.end()) + std::vector<MapObject>::const_iterator it_end = list->objects.end(); + while (it != it_end) { if ((*it).type == type) return (*it).data; @@ -1453,11 +1458,12 @@ void Map::reduce() { for (int y = 0; y < mHeight; y ++) { - Layers::const_iterator layeri = mLayers.begin(); bool correct(true); bool dontHaveAlpha(false); - for (; layeri != mLayers.end(); ++ layeri) + for (LayersCIter layeri = mLayers.begin(), + layeri_end = mLayers.end(); + layeri != layeri_end; ++ layeri) { MapLayer *layer = *layeri; if (x >= layer->mWidth || y >= layer->mHeight) @@ -43,6 +43,13 @@ class ObjectsLayer; typedef std::vector<Tileset*> Tilesets; typedef std::vector<MapLayer*> Layers; +typedef Layers::const_iterator LayersCIter; + +typedef std::vector<std::pair<MapLayer*, int> > TilePairVector; +typedef TilePairVector::const_iterator TilePairVectorCIter; + +typedef std::vector<AmbientLayer*> AmbientLayerVector; +typedef AmbientLayerVector::const_iterator AmbientLayerVectorCIter; /** * A meta tile stores additional information about a location on a tile map. @@ -84,11 +91,14 @@ class TileAnimation { mAffected.push_back(std::make_pair(layer, index)); } private: - std::vector<std::pair<MapLayer*, int> > mAffected; + TilePairVector mAffected; SimpleAnimation *mAnimation; Image *mLastImage; }; +typedef std::map<int, TileAnimation*> TileAnimationMap; +typedef TileAnimationMap::const_iterator TileAnimationMapCIter; + /** * A tile map. */ @@ -422,8 +432,8 @@ class Map : public Properties, public ConfigListener unsigned mOnClosedList, mOnOpenList; // Overlay data - std::vector<AmbientLayer*> mBackgrounds; - std::vector<AmbientLayer*> mForegrounds; + AmbientLayerVector mBackgrounds; + AmbientLayerVector mForegrounds; float mLastAScrollX; float mLastAScrollY; // bool mSpritesUpdated; diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 010906920..28976e099 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -334,7 +334,8 @@ void MapLayer::drawFringe(Graphics *graphics, int startX, int startY, if (endY > mHeight) endY = mHeight; - Actors::const_iterator ai = actors->begin(); + ActorsCIter ai = actors->begin(); + ActorsCIter ai_end = actors->end(); const int dx = (mX * 32) - scrollX; const int dy = (mY * 32) - scrollY + 32; @@ -350,7 +351,7 @@ void MapLayer::drawFringe(Graphics *graphics, int startX, int startY, // If drawing the fringe layer, make sure all actors above this row of // tiles have been drawn - while (ai != actors->end() && (*ai)->getPixelY() <= y32s) + while (ai != ai_end && (*ai)->getPixelY() <= y32s) { (*ai)->draw(graphics, -scrollX, -scrollY); ++ ai; @@ -453,7 +454,7 @@ void MapLayer::drawFringe(Graphics *graphics, int startX, int startY, // Draw any remaining actors if (debugFlags != Map::MAP_SPECIAL3) { - while (ai != actors->end()) + while (ai != ai_end) { (*ai)->draw(graphics, -scrollX, -scrollY); ++ai; diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index d870eff38..f28e9b396 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -431,9 +431,8 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg) if (!mStorage) mStorage = new Inventory(Inventory::STORAGE, size); - Ea::InventoryItems::const_iterator it = mInventoryItems.begin(); - Ea::InventoryItems::const_iterator it_end = mInventoryItems.end(); - for (; it != it_end; ++it) + for (Ea::InventoryItems::const_iterator it = mInventoryItems.begin(), + it_end = mInventoryItems.end(); it != it_end; ++it) { mStorage->setItem((*it).slot, (*it).id, (*it).quantity, (*it).refine, (*it).color, (*it).equip); diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 242270d13..e7fcc9cc6 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -197,9 +197,8 @@ void LoginHandler::processUpdateHost2(Net::MessageIn &msg) std::string updateHost = msg.readString(len); splitToStringVector(loginData.updateHosts, updateHost, '|'); - StringVectIter it = loginData.updateHosts.begin(); - StringVectIter it_end = loginData.updateHosts.end(); - for (; it != it_end; ++ it) + for (StringVectIter it = loginData.updateHosts.begin(), + it_end = loginData.updateHosts.end(); it != it_end; ++ it) { if (!checkPath(*it)) { diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 306765ff4..956067f4a 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -218,8 +218,8 @@ void Network::unregisterHandler(MessageHandler *handler) void Network::clearHandlers() { - MessageHandlerIterator i; - for (i = mMessageHandlers.begin(); i != mMessageHandlers.end(); ++i) + for (MessageHandlerIterator i = mMessageHandlers.begin(); + i != mMessageHandlers.end(); ++i) { if (i->second) i->second->setNetwork(nullptr); diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 9dd655420..40f1087d0 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -671,19 +671,22 @@ void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image) std::vector<GLint*> *intVertPool = ogl->getIntVertPool(); std::vector<GLint*>::const_iterator iv; + std::vector<GLint*>::const_iterator iv_end = intVertPool->end(); std::vector<int> *vp = ogl->getVp(); std::vector<int>::const_iterator ivp; + std::vector<int>::const_iterator ivp_end = vp->end(); // Draw a set of textured rectangles if (image->mTextureType == GL_TEXTURE_2D) { std::vector<GLfloat*> *floatTexPool = ogl->getFloatTexPool(); std::vector<GLfloat*>::const_iterator ft; + std::vector<GLfloat*>::const_iterator ft_end = floatTexPool->end(); for (iv = intVertPool->begin(), ft = floatTexPool->begin(), ivp = vp->begin(); - iv != intVertPool->end(), ft != floatTexPool->end(), - ivp != vp->end(); + iv != iv_end, ft != ft_end, + ivp != ivp_end; ++ iv, ++ ft, ++ ivp) { drawQuadArrayfi(*iv, *ft, *ivp); @@ -693,11 +696,12 @@ void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image) { std::vector<GLint*> *intTexPool = ogl->getIntTexPool(); std::vector<GLint*>::const_iterator it; + std::vector<GLint*>::const_iterator it_end = intTexPool->end(); for (iv = intVertPool->begin(), it = intTexPool->begin(), ivp = vp->begin(); - iv != intVertPool->end(), it != intTexPool->end(), - ivp != vp->end(); + iv != iv_end, it != it_end, + ivp != ivp_end; ++ iv, ++ it, ++ ivp) { drawQuadArrayii(*iv, *it, *ivp); diff --git a/src/particle.cpp b/src/particle.cpp index 0d771a15e..c1f2d9edd 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -203,12 +203,12 @@ bool Particle::update() // Update child emitters if ((mLifetimePast - 1) % Particle::emitterSkip == 0) { - for (EmitterConstIterator e = mChildEmitters.begin(); - e != mChildEmitters.end(); ++e) + for (EmitterConstIterator e = mChildEmitters.begin(), + e2 = mChildEmitters.end(); e != e2; ++ e) { Particles newParticles = (*e)->createParticles(mLifetimePast); - for (ParticleConstIterator p = newParticles.begin(); - p != newParticles.end(); ++p) + for (ParticleConstIterator p = newParticles.begin(), + p2 = newParticles.end(); p != p2; ++ p) { (*p)->moveBy(mPos); mChildParticles.push_back (*p); @@ -234,8 +234,8 @@ bool Particle::update() // Update child particles - for (ParticleIterator p = mChildParticles.begin(); - p != mChildParticles.end(); ) + for (ParticleIterator p = mChildParticles.begin(), + p2 = mChildParticles.end(); p != p2; ) { //move particle with its parent if desired if ((*p)->doesFollow()) @@ -261,8 +261,8 @@ bool Particle::update() void Particle::moveBy(const Vector &change) { mPos += change; - for (ParticleConstIterator p = mChildParticles.begin(); - p != mChildParticles.end(); ++p) + for (ParticleConstIterator p = mChildParticles.begin(), + p2 = mChildParticles.end(); p != p2; ++p) { if ((*p)->doesFollow()) (*p)->moveBy(change); @@ -454,8 +454,8 @@ void Particle::adjustEmitterSize(int w, int h) { if (mAllowSizeAdjust) { - for (EmitterConstIterator e = mChildEmitters.begin(); - e != mChildEmitters.end(); ++e) + for (EmitterConstIterator e = mChildEmitters.begin(), + e2 = mChildEmitters.end(); e != e2; ++e) { (*e)->adjustSize(w, h); } diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index e39f4dd86..9421e6354 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -75,9 +75,8 @@ void ParticleList::addLocally(Particle *particle) void ParticleList::removeLocally(Particle *particle) { - std::list<Particle *>::iterator it, it_end; - for (it = mElements.begin(), it_end = mElements.end(); - it != it_end; ) + for (std::list<Particle *>::iterator it = mElements.begin(); + it != mElements.end(); ) { if (*it == particle) { @@ -93,8 +92,8 @@ void ParticleList::removeLocally(Particle *particle) void ParticleList::clearLocally() { - for (std::list<Particle *>::const_iterator it = mElements.begin(); - it != mElements.end(); ++it) + for (std::list<Particle *>::const_iterator it = mElements.begin(), + it_end = mElements.end(); it != it_end; ++ it) { (*it)->kill(); } diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index c6c819e92..5fefd3609 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -431,8 +431,8 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o) mTempSets = o.mTempSets; for (std::vector<ImageSet*>::const_iterator - i = mTempSets.begin(); - i != mTempSets.end(); ++i) + i = mTempSets.begin(), i_end = mTempSets.end(); + i != i_end; ++ i) { if (*i) (*i)->incRef(); @@ -449,8 +449,8 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o) ParticleEmitter::~ParticleEmitter() { for (std::vector<ImageSet*>::const_iterator - i = mTempSets.begin(); - i != mTempSets.end(); ++i) + i = mTempSets.begin(), i_end = mTempSets.end(); + i != i_end; ++i) { if (*i) (*i)->decRef(); @@ -572,8 +572,9 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick) newParticle->setAlpha(mParticleAlpha.value(tick)); for (std::list<ParticleEmitter>::const_iterator - it = mParticleChildEmitters.begin(); - it != mParticleChildEmitters.end(); ++it) + it = mParticleChildEmitters.begin(), + it_end = mParticleChildEmitters.end(); + it != it_end; ++it) { newParticle->addEmitter(new ParticleEmitter(*it)); } diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index d79a621d5..d4a72ceab 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -44,6 +44,11 @@ #define IGNORE_EMOTE_TIME 100 +typedef std::map<std::string, PlayerRelation *> PlayerRelations; +typedef PlayerRelations::const_iterator PlayerRelationsCIter; +typedef std::list<PlayerRelationsListener *> PlayerRelationListeners; +typedef PlayerRelationListeners::const_iterator PlayerRelationListenersCIter; + class SortPlayersFunctor { public: @@ -130,9 +135,8 @@ PlayerRelationsManager::~PlayerRelationsManager() { delete_all(mIgnoreStrategies); - for (std::map<std::string, - PlayerRelation *>::const_iterator it = mRelations.begin(); - it != mRelations.end(); ++it) + for (PlayerRelationsCIter it = mRelations.begin(), + it_end = mRelations.end(); it != it_end; ++ it) { delete it->second; } @@ -141,8 +145,11 @@ PlayerRelationsManager::~PlayerRelationsManager() void PlayerRelationsManager::clear() { StringVect *names = getPlayers(); - for (StringVectCIter it = names->begin(); it != names->end(); ++ it) + for (StringVectCIter it = names->begin(), it_end = names->end(); + it != it_end; ++ it) + { removePlayer(*it); + } delete names; names = nullptr; } @@ -209,8 +216,8 @@ void PlayerRelationsManager::init() // until the next update. } - for (std::list<PlayerRelationsListener *>::const_iterator - it = mListeners.begin(); it != mListeners.end(); ++it) + for (PlayerRelationListenersCIter it = mListeners.begin(), + it_end = mListeners.end(); it != it_end; ++it) { (*it)->updateAll(); } @@ -237,8 +244,8 @@ void PlayerRelationsManager::store() void PlayerRelationsManager::signalUpdate(const std::string &name) { - for (std::list<PlayerRelationsListener *>::const_iterator - it = mListeners.begin(); it != mListeners.end(); ++it) + for (PlayerRelationListenersCIter it = mListeners.begin(), + it_end = mListeners.end(); it != it_end; ++ it) { (*it)->updatedPlayer(name); } @@ -346,9 +353,8 @@ StringVect * PlayerRelationsManager::getPlayers() { StringVect *retval = new StringVect(); - for (std::map<std::string, - PlayerRelation *>::const_iterator it = mRelations.begin(); - it != mRelations.end(); ++it) + for (PlayerRelationsCIter it = mRelations.begin(), + it_end = mRelations.end(); it != it_end; ++ it) { if (it->second) retval->push_back(it->first); @@ -364,9 +370,8 @@ StringVect *PlayerRelationsManager::getPlayersByRelation( { StringVect *retval = new StringVect(); - for (std::map<std::string, - PlayerRelation *>::const_iterator it = mRelations.begin(); - it != mRelations.end(); ++it) + for (PlayerRelationsCIter it = mRelations.begin(), + it_end = mRelations.end(); it != it_end; ++ it) { if (it->second && it->second->mRelation == rel) retval->push_back(it->first); diff --git a/src/resources/action.cpp b/src/resources/action.cpp index 6c799cdfa..2c1c5d080 100644 --- a/src/resources/action.cpp +++ b/src/resources/action.cpp @@ -72,9 +72,8 @@ void Action::setAnimation(int direction, Animation *animation) void Action::setLastFrameDelay(int delay) { - AnimationIter it = mAnimations.begin(); - AnimationIter it_end = mAnimations.end(); - for (; it != it_end; ++ it) + for (AnimationIter it = mAnimations.begin(), + it_end = mAnimations.end(); it != it_end; ++ it) { Animation *animation = (*it).second; if (!animation) diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index 853b79d64..63e73df55 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -78,9 +78,8 @@ void Animation::addPause(int delay, int rand) void Animation::setLastFrameDelay(int delay) { - FramesRevIter it = mFrames.rbegin(); - FramesRevIter it_end = mFrames.rend(); - for (; it != it_end; ++ it) + for (FramesRevIter it = mFrames.rbegin(), it_end = mFrames.rend(); + it != it_end; ++ it) { if ((*it).type == Frame::ANIMATION && (*it).image) { diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index e6f04536e..045900415 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -170,9 +170,8 @@ void EmoteDB::load() void EmoteDB::unload() { - for (EmoteInfos::const_iterator i = mEmoteInfos.begin(); - i != mEmoteInfos.end(); - ++i) + for (EmoteInfos::const_iterator i = mEmoteInfos.begin(), + i_end = mEmoteInfos.end(); i != i_end; ++ i) { if (i->second) { diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 72d1aa9eb..8d4cf8002 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -307,8 +307,8 @@ void ItemDB::load() effect += " / "; effect += strprintf(gettext(fields[i][1]), value); } - for (std::vector<Stat>::const_iterator it = extraStats.begin(); - it != extraStats.end(); ++it) + for (std::vector<Stat>::const_iterator it = extraStats.begin(), + it_end = extraStats.end(); it != it_end; ++it) { int value = XML::getProperty(node, it->tag.c_str(), 0); if (!value) diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 56a442832..9d1f94954 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -92,6 +92,7 @@ enum ItemType // sprite, <itemfrom, itemto> typedef std::map<int, std::map<int, int> > SpriteToItemMap; +typedef SpriteToItemMap::const_iterator SpriteToItemMapCIter; /** * Defines a class for storing item infos. This includes information used when diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 3411b70c4..4aa0eada4 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -61,9 +61,8 @@ Action *SpriteDef::getAction(std::string action, unsigned num) const unsigned SpriteDef::findNumber(unsigned num) const { unsigned min = 101; - Actions::const_iterator it = mActions.begin(); - Actions::const_iterator it_end = mActions.end(); - for (; it != it_end; ++ it) + for (Actions::const_iterator it = mActions.begin(), + it_end = mActions.end(); it != it_end; ++ it) { unsigned n = (*it).first; if (n >= num && n < min) @@ -107,9 +106,8 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) void SpriteDef::fixDeadAction() { - ActionsIter it = mActions.begin(); - ActionsIter it_end = mActions.end(); - for (; it != it_end; ++ it) + for (ActionsIter it = mActions.begin(), it_end = mActions.end(); + it != it_end; ++ it) { ActionMap *d = (*it).second; if (!d) @@ -122,9 +120,8 @@ void SpriteDef::fixDeadAction() void SpriteDef::substituteAction(std::string complete, std::string with) { - ActionsConstIter it = mActions.begin(); - ActionsConstIter it_end = mActions.end(); - for (; it != it_end; ++ it) + for (ActionsConstIter it = mActions.begin(), it_end = mActions.end(); + it != it_end; ++ it) { ActionMap *d = (*it).second; if (!d) @@ -326,9 +323,8 @@ void SpriteDef::loadAnimation(XmlNodePtr animationNode, { StringVect vals; splitToStringVector(vals, value, ','); - StringVectCIter it = vals.begin(); - StringVectCIter it_end = vals.end(); - for (; it != it_end; ++ it) + for (StringVectCIter it = vals.begin(), it_end = vals.end(); + it != it_end; ++ it) { std::string str = *it; size_t idx = str.find("-"); @@ -419,10 +415,11 @@ SpriteDef::~SpriteDef() for (Actions::iterator i = mActions.begin(), i_end = mActions.end(); i != i_end; ++i) { - ActionMap::iterator it = (*i).second->begin(); - ActionMap::iterator it_end = (*i).second->end(); - for (; it != it_end; ++ it) + for (ActionMap::iterator it = (*i).second->begin(), + it_end = (*i).second->end(); it != it_end; ++ it) + { actions.insert(it->second); + } delete (*i).second; } diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 7b89bed6e..2f5fd9dca 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -136,13 +136,14 @@ void Wallpaper::loadWallpapers() std::string Wallpaper::getWallpaper(int width, int height) { - std::vector<WallpaperData>::const_iterator iter; WallpaperData wp; // Wallpaper filename container StringVect wallPaperVector; - for (iter = wallpaperData.begin(); iter != wallpaperData.end(); ++iter) + for (std::vector<WallpaperData>::const_iterator + iter = wallpaperData.begin(), iter_end = wallpaperData.end(); + iter != iter_end; ++iter) { wp = *iter; if (wp.width <= width && wp.height <= height) diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index 854e1f918..ed6989280 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -352,10 +352,11 @@ void SpellManager::save() std::string SpellManager::autoComplete(std::string partName) { std::vector<TextCommand*>::const_iterator i = mSpellsVector.begin(); + std::vector<TextCommand*>::const_iterator i_end = mSpellsVector.end(); std::string newName = ""; TextCommand *newCommand = nullptr; - while (i != mSpellsVector.end()) + while (i != i_end) { TextCommand *cmd = *i; std::string line = cmd->getCommand(); diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 9d57c58a7..fcafd7711 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -207,7 +207,8 @@ size_t findI(std::string text, StringVect &list) { std::string str = toLower(text); size_t idx; - for (StringVectCIter i = list.begin(); i != list.end(); ++ i) + for (StringVectCIter i = list.begin(), i_end = list.end(); + i != i_end; ++ i) { std::string subStr = *i; subStr = toLower(subStr); @@ -482,9 +483,8 @@ std::string combineDye2(std::string file, std::string dye) file = file.substr(0, pos); std::list<std::string> list1 = splitToStringList(dye1, ';'); std::list<std::string> list2 = splitToStringList(dye, ';'); - std::list<std::string>::const_iterator it1, it1_end = list1.end(); - std::list<std::string>::const_iterator it2, it2_end = list2.end(); - for (it1 = list1.begin(), it2 = list2.begin(); + for (std::list<std::string>::const_iterator it1 = list1.begin(), + it2 = list2.begin(), it1_end = list1.end(), it2_end = list2.end(); it1 != it1_end && it2 != it2_end; ++it1, ++it2) { str += (*it1) + ":" + (*it2) + ";"; diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp index 81fb612e4..dab6958d3 100644 --- a/src/utils/translation/translationmanager.cpp +++ b/src/utils/translation/translationmanager.cpp @@ -63,10 +63,7 @@ PoDict *TranslationManager::loadLang(LangVect lang, std::string name = ""; PoParser parser; - LangIter it = lang.begin(); - LangIter it_end = lang.end(); - - for (; it != it_end; ++ it) + for (LangIter it = lang.begin(), it_end = lang.end(); it != it_end; ++ it) { if (*it == "C") continue; |