diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-04-25 02:26:22 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-04-25 02:26:22 +0300 |
commit | 8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf (patch) | |
tree | 2c95704e2de3418227faf7a52357a6fe03d5b735 | |
parent | e73f7da4d65e7dc61a952894cc6f0843c4da3170 (diff) | |
download | plus-8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf.tar.gz plus-8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf.tar.bz2 plus-8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf.tar.xz plus-8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf.zip |
Improve iterators part 1.
39 files changed, 202 insertions, 190 deletions
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index f7a6db823..6ed6a2a3d 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -107,8 +107,8 @@ public: && botCheckerWindow->mEnabled) { std::set<ActorSprite*> beings = actorSpriteManager->getAll(); - for (ActorSprites::const_iterator i = beings.begin(); - i != beings.end(); ++i) + for (ActorSprites::const_iterator i = beings.begin(), + i_end = beings.end(); i != i_end; ++i) { Being *being = dynamic_cast<Being*>(*i); @@ -390,8 +390,8 @@ void BotCheckerWindow::reset() if (actorSpriteManager) { std::set<ActorSprite*> beings = actorSpriteManager->getAll(); - for (ActorSprites::const_iterator i = beings.begin(); - i != beings.end(); ++i) + for (ActorSprites::const_iterator i = beings.begin(), + i_end = beings.end(); i != i_end; ++i) { Being *being = dynamic_cast<Being*>(*i); diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 83207b3d8..df64a5a61 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -345,10 +345,8 @@ void BuyDialog::setVisible(bool visible) void BuyDialog::closeAll() { - DialogList::const_iterator it = instances.begin(); - DialogList::const_iterator it_end = instances.end(); - - for (; it != it_end; ++it) + for (DialogList::const_iterator it = instances.begin(), + it_end = instances.end(); it != it_end; ++it) { if (*it) (*it)->close(); diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index 5aa421bad..429f62a85 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -129,10 +129,8 @@ void BuySellDialog::action(const gcn::ActionEvent &event) void BuySellDialog::closeAll() { - DialogList::const_iterator it = instances.begin(); - DialogList::const_iterator it_end = instances.end(); - - for (; it != it_end; ++it) + for (DialogList::const_iterator it = instances.begin(), + it_end = instances.end(); it != it_end; ++it) { if (*it) (*it)->close(); diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index f924cd259..a18f3d383 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -459,15 +459,15 @@ void CharSelectDialog::attemptCharacterSelect(int index) void CharSelectDialog::setCharacters(const Net::Characters &characters) { // Reset previous characters - std::vector<CharacterDisplay*>::const_iterator iter, iter_end; - for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end(); + for (std::vector<CharacterDisplay*>::const_iterator + iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end(); iter != iter_end; ++iter) { (*iter)->setCharacter(nullptr); } - Net::Characters::const_iterator i, i_end = characters.end(); - for (i = characters.begin(); i != i_end; ++i) + for (Net::Characters::const_iterator i = characters.begin(), + i_end = characters.end(); i != i_end; ++i) { if (!*i) continue; diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 191348897..c33478cc5 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -587,11 +587,13 @@ void ChatWindow::removeWhisper(const std::string &nick) void ChatWindow::removeAllWhispers() { - TabMap::iterator iter; std::list<ChatTab*> tabs; - for (iter = mWhispers.begin(); iter != mWhispers.end(); ++iter) + for (TabMap::iterator iter = mWhispers.begin(), + iter_end = mWhispers.end(); iter != iter_end; ++ iter) + { tabs.push_back(iter->second); + } for (std::list<ChatTab*>::iterator it = tabs.begin(); it != tabs.end(); ++it) @@ -821,16 +823,16 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mChatHistoryIndex --; } - std::list<std::string>::const_iterator it; unsigned int f = 0; const std::list<std::string> &rows = tab->getRows(); - for (it = rows.begin(); it != rows.end(); ++it, f++) + for (std::list<std::string>::const_iterator it = rows.begin(), + it_end = rows.end(); it != it_end; ++ it, f ++) { if (f == mChatHistoryIndex) mChatInput->setText(*it); } mChatInput->setCaretPosition(static_cast<unsigned>( - mChatInput->getText().length())); + mChatInput->getText().length())); } } else if (actionId == Input::KEY_CHAT_NEXT_HISTORY && @@ -855,10 +857,9 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mChatHistoryIndex = 0; } - std::list<std::string>::const_iterator it; unsigned int f = 0; - for (it = tab->getRows().begin(); - it != tab->getRows().end(); ++it, f++) + for (std::list<std::string>::const_iterator it = tab->getRows().begin(), + it_end = tab->getRows().end(); it != it_end; ++it, f++) { if (f == mChatHistoryIndex) mChatInput->setText(*it); @@ -1027,7 +1028,9 @@ void ChatWindow::addWhisper(const std::string &nick, TabMap::const_iterator i = mWhispers.find(tempNick); if (i != mWhispers.end()) + { tab = i->second; + } else if (config.getBoolValue("whispertab")) { tab = addWhisperTab(nick); @@ -1281,10 +1284,11 @@ std::string ChatWindow::autoComplete(StringVect &names, std::string partName) const { StringVectCIter i = names.begin(); + StringVectCIter i_end = names.end(); toLower(partName); std::string newName(""); - while (i != names.end()) + while (i != i_end) { if (!i->empty()) { @@ -1316,9 +1320,10 @@ std::string ChatWindow::autoComplete(std::string partName, History *words) return ""; Commands::const_iterator i = words->begin(); + Commands::const_iterator i_end = words->end(); StringVect nameList; - while (i != words->end()) + while (i != i_end) { std::string line = *i; size_t pos = line.find(partName, 0); @@ -1344,9 +1349,10 @@ void ChatWindow::moveTabRight(ChatTab *tab) std::string ChatWindow::autoCompleteHistory(std::string partName) { History::const_iterator i = mHistory.begin(); + History::const_iterator i_end = mHistory.end(); StringVect nameList; - while (i != mHistory.end()) + while (i != i_end) { std::string line = *i; unsigned int f = 0; @@ -1444,7 +1450,6 @@ void ChatWindow::initTradeFilter() void ChatWindow::updateOnline(std::set<std::string> &onlinePlayers) { - TabMap::const_iterator iter; const Party *party = nullptr; const Guild *guild = nullptr; if (player_node) @@ -1452,7 +1457,8 @@ void ChatWindow::updateOnline(std::set<std::string> &onlinePlayers) party = player_node->getParty(); guild = player_node->getGuild(); } - for (iter = mWhispers.begin(); iter != mWhispers.end(); ++iter) + for (TabMap::const_iterator iter = mWhispers.begin(), + iter_end = mWhispers.end(); iter != iter_end; ++iter) { if (!iter->second) return; @@ -1529,8 +1535,8 @@ void ChatWindow::loadState() void ChatWindow::saveState() { int num = 0; - TabMap::const_iterator iter; - for (iter = mWhispers.begin(); iter != mWhispers.end() && num < 50; ++iter) + for (TabMap::const_iterator iter = mWhispers.begin(), + iter_end = mWhispers.end(); iter != iter_end && num < 50; ++iter) { if (!iter->second) return; @@ -1612,8 +1618,9 @@ void ChatWindow::displayAwayLog() return; std::list<std::string>::iterator i = mAwayLog.begin(); + std::list<std::string>::iterator i_end = mAwayLog.end(); - while (i != mAwayLog.end()) + while (i != i_end) { localChatTab->addNewRow(*i); ++i; diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp index 1bd3ccbf5..37033af64 100644 --- a/src/gui/editdialog.cpp +++ b/src/gui/editdialog.cpp @@ -66,9 +66,11 @@ EditDialog::EditDialog(const std::string &title, const std::string &msg, void EditDialog::action(const gcn::ActionEvent &event) { // Proxy button events to our listeners - ActionListenerIterator i; - for (i = mActionListeners.begin(); i != mActionListeners.end(); ++i) + for (ActionListenerIterator i = mActionListeners.begin(), + i_end = mActionListeners.end(); i != i_end; ++i) + { (*i)->action(event); + } if (event.getId() == mEventOk) scheduleDelete(); diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp index 39017ac91..0b1d72808 100644 --- a/src/gui/emotepopup.cpp +++ b/src/gui/emotepopup.cpp @@ -213,10 +213,9 @@ void EmotePopup::recalculateSize() void EmotePopup::distributeValueChangedEvent() { gcn::SelectionEvent event(this); - Listeners::const_iterator i_end = mListeners.end(); - Listeners::const_iterator i; - for (i = mListeners.begin(); i != i_end; ++i) + for (Listeners::const_iterator i = mListeners.begin(), + i_end = mListeners.end(); i != i_end; ++i) { if (*i) (*i)->valueChanged(event); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 7b77c8de0..c3610ea0b 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -143,10 +143,8 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) int i = 0; const int fontHeight = getFont()->getHeight(); - std::vector<EquipmentBox*>::const_iterator it; - std::vector<EquipmentBox*>::const_iterator it_end = mBoxes.end(); - - for (it = mBoxes.begin(); it != it_end; ++ it, ++ i) + for (std::vector<EquipmentBox*>::const_iterator it = mBoxes.begin(), + it_end = mBoxes.end(); it != it_end; ++ it, ++ i) { EquipmentBox *box = *it; if (!box) @@ -214,11 +212,10 @@ Item *EquipmentWindow::getItem(int x, int y) const if (!mEquipment) return nullptr; - std::vector<EquipmentBox*>::const_iterator it; - std::vector<EquipmentBox*>::const_iterator it_end = mBoxes.end(); int i = 0; - for (it = mBoxes.begin(); it != it_end; ++ it, ++ i) + for (std::vector<EquipmentBox*>::const_iterator it = mBoxes.begin(), + it_end = mBoxes.end(); it != it_end; ++ it, ++ i) { EquipmentBox *box = *it; if (!box) @@ -247,11 +244,10 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) if (mForing) return; // Checks if any of the presses were in the equip boxes. - std::vector<EquipmentBox*>::const_iterator it; - std::vector<EquipmentBox*>::const_iterator it_end = mBoxes.end(); int i = 0; - for (it = mBoxes.begin(); it != it_end; ++ it, ++ i) + for (std::vector<EquipmentBox*>::const_iterator it = mBoxes.begin(), + it_end = mBoxes.end(); it != it_end; ++ it, ++ i) { EquipmentBox *box = *it; if (!box) diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 5fe44f2bd..c20dd0036 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -644,10 +644,8 @@ bool InventoryWindow::isInputFocused() const bool InventoryWindow::isAnyInputFocused() { - WindowList::const_iterator it = instances.begin(); - WindowList::const_iterator it_end = instances.end(); - - for (; it != it_end; ++it) + for (WindowList::const_iterator it = instances.begin(), + it_end = instances.end(); it != it_end; ++it) { if ((*it) && (*it)->isInputFocused()) return true; diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 219c319a5..9ac37a413 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -134,8 +134,8 @@ MiniStatusWindow::~MiniStatusWindow() if (inv) inv->removeInventoyListener(this); - std::vector <ProgressBar*>::const_iterator it, it_end; - for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) + for (std::vector <ProgressBar*>::const_iterator it = mBars.begin(), + it_end = mBars.end(); it != it_end; ++it) { ProgressBar *bar = *it; if (!bar) @@ -160,11 +160,14 @@ ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height, void MiniStatusWindow::updateBars() { int x = 0; - std::vector <ProgressBar*>::const_iterator it, it_end; ProgressBar* lastBar = nullptr; - for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) + for (std::vector <ProgressBar*>::const_iterator it = mBars.begin(), + it_end = mBars.end(); it != it_end; ++it) + { safeRemove(*it); - for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) + } + for (std::vector <ProgressBar*>::const_iterator it = mBars.begin(), + it_end = mBars.end(); it != it_end; ++it) { ProgressBar *bar = *it; if (!bar) @@ -439,10 +442,9 @@ void MiniStatusWindow::loadBars() void MiniStatusWindow::saveBars() { - std::vector <ProgressBar*>::const_iterator it, it_end; int i = 0; - for (it = mBars.begin(), it_end = mBars.end(); - it != it_end; ++it) + for (std::vector <ProgressBar*>::const_iterator it = mBars.begin(), + it_end = mBars.end(); it != it_end; ++it) { ProgressBar *bar = *it; if (!bar->isVisible()) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 24d94dc3f..c5143a136 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -384,10 +384,8 @@ bool NpcDialog::isInputFocused() const bool NpcDialog::isAnyInputFocused() { - DialogList::const_iterator it = instances.begin(); - DialogList::const_iterator it_end = instances.end(); - - for (; it != it_end; ++it) + for (DialogList::const_iterator it = instances.begin(), + it_end = instances.end(); it != it_end; ++it) { if ((*it) && (*it)->isInputFocused()) return true; @@ -445,10 +443,8 @@ NpcDialog *NpcDialog::getActive() if (instances.size() == 1) return instances.front(); - DialogList::const_iterator it = instances.begin(); - DialogList::const_iterator it_end = instances.end(); - - for (; it != it_end; ++it) + for (DialogList::const_iterator it = instances.begin(), + it_end = instances.end(); it != it_end; ++it) { if ((*it) && (*it)->isFocused()) return (*it); @@ -459,10 +455,8 @@ NpcDialog *NpcDialog::getActive() void NpcDialog::closeAll() { - DialogList::const_iterator it = instances.begin(); - DialogList::const_iterator it_end = instances.end(); - - for (; it != it_end; ++it) + for (DialogList::const_iterator it = instances.begin(), + it_end = instances.end(); it != it_end; ++it) { if (*it) (*it)->close(); diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index b2ffb312c..a6b12f833 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -123,9 +123,9 @@ void NpcPostDialog::setVisible(bool visible) void NpcPostDialog::closeAll() { - DialogList::const_iterator it = instances.begin(); - DialogList::const_iterator it_end = instances.end(); - - for (; it != it_end; ++it) + for (DialogList::const_iterator it = instances.begin(), + it_end = instances.end(); it != it_end; ++it) + { (*it)->close(); + } } diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index b48522faa..e24907256 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -80,11 +80,11 @@ const gcn::Color& Palette::getColor(char c, bool &valid) void Palette::advanceGradients() { - Palettes::const_iterator it = mInstances.begin(); - Palettes::const_iterator it_end = mInstances.end(); - - for (; it != it_end; ++it) + for (Palettes::const_iterator it = mInstances.begin(), + it_end = mInstances.end(); it != it_end; ++it) + { (*it)->advanceGradient(); + } } void Palette::advanceGradient() diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index d896b9420..45cf8b9b2 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -358,8 +358,8 @@ void PopupMenu::showPopup(int x, int y, std::vector<ActorSprite*> &beings) mY = y; mBrowserBox->clearRows(); mBrowserBox->addRow(_("Players")); - std::vector<ActorSprite*>::const_iterator it, it_end; - for (it = beings.begin(), it_end = beings.end(); it != it_end; ++it) + for (std::vector<ActorSprite*>::const_iterator it = beings.begin(), + it_end = beings.end(); it != it_end; ++it) { Being *being = dynamic_cast<Being*>(*it); ActorSprite *actor = *it; @@ -878,9 +878,8 @@ void PopupMenu::showChangePos(int x, int y) if (guild) { PositionsMap map = guild->getPositions(); - PositionsMap::const_iterator itr = map.begin(); - PositionsMap::const_iterator itr_end = map.end(); - for (; itr != itr_end; ++itr) + for (PositionsMap::const_iterator itr = map.begin(), + itr_end = map.end(); itr != itr_end; ++itr) { mBrowserBox->addRow(strprintf("@@guild-pos-%d|%s@@", itr->first, itr->second.c_str())); @@ -2037,8 +2036,8 @@ void PopupMenu::showPopup(int x, int y, Button *button) mBrowserBox->clearRows(); std::vector <gcn::Button*> names = windowMenu->getButtons(); - std::vector <gcn::Button*>::const_iterator it, it_end; - for (it = names.begin(), it_end = names.end(); it != it_end; ++ it) + for (std::vector <gcn::Button*>::const_iterator it = names.begin(), + it_end = names.end(); it != it_end; ++ it) { Button *btn = dynamic_cast<Button*>(*it); if (!btn || btn->getActionEventId() == "SET") @@ -2074,8 +2073,8 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) mBrowserBox->clearRows(); std::vector <ProgressBar*> bars = miniStatusWindow->getBars(); - std::vector <ProgressBar*>::const_iterator it, it_end; - for (it = bars.begin(), it_end = bars.end(); it != it_end; ++it) + for (std::vector <ProgressBar*>::const_iterator it = bars.begin(), + it_end = bars.end(); it != it_end; ++it) { ProgressBar *bar = *it; if (!bar || bar->getActionEventId() == "status bar") diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 51458cb08..c5257b99b 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -185,8 +185,9 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) if (dir != 0) { std::vector<gcn::RadioButton*>::const_iterator it = mOptions.begin(); + std::vector<gcn::RadioButton*>::const_iterator it_end = mOptions.end(); - for (; it < mOptions.end(); ++it) + for (; it < it_end; ++it) { if ((*it)->isSelected()) break; @@ -199,7 +200,9 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) return; } else if (it == mOptions.begin() && dir < 0) + { it = mOptions.end(); + } it += dir; diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 197b0f9cd..63688fa29 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -218,7 +218,8 @@ void SDLFont::drawString(gcn::Graphics *graphics, int cnt = 0; #endif - for (CacheIterator i = cache->begin(); i != cache->end(); ++i) + for (CacheIterator i = cache->begin(), i_end = cache->end(); + i != i_end; ++ i) { if (chunk == (*i)) { @@ -298,7 +299,8 @@ int SDLFont::getWidth(const std::string &text) const int cnt = 0; #endif - for (CacheIterator i = cache->begin(); i != cache->end(); ++i) + for (CacheIterator i = cache->begin(), i_end = cache->end(); + i != i_end; ++ i) { if (i->text == text) { diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 38355db03..931f9daf7 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -346,9 +346,9 @@ void SellDialog::setVisible(bool visible) void SellDialog::closeAll() { - DialogList::const_iterator it = instances.begin(); - DialogList::const_iterator it_end = instances.end(); - - for (; it != it_end; ++it) + for (DialogList::const_iterator it = instances.begin(), + it_end = instances.end(); it != it_end; ++it) + { (*it)->close(); + } } diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index d86d93f61..f646e4ee1 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -677,8 +677,8 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, } else { - ServerInfos::iterator i, i_end = mServers.end(); - for (i = mServers.begin(); i != i_end; ++i) + for (ServerInfos::iterator i = mServers.begin(), + i_end = mServers.end(); i != i_end; ++i) { if (*i == currentServer) { diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 65444a362..9f7ae209d 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -165,8 +165,9 @@ void Setup::action(const gcn::ActionEvent &event) if (!statusWindow) return; - for (std::list<Window*>::const_iterator it = mWindowsToReset.begin(); - it != mWindowsToReset.end(); ++it) + for (std::list<Window*>::const_iterator it = mWindowsToReset.begin(), + it_end = mWindowsToReset.end(); + it != it_end; ++it) { if (*it) (*it)->resetToDefaultSize(); @@ -181,8 +182,8 @@ void Setup::setInGame(bool inGame) void Setup::externalUpdate() { - for (std::list<SetupTab*>::const_iterator it = mTabs.begin(); - it != mTabs.end(); ++it) + for (std::list<SetupTab*>::const_iterator it = mTabs.begin(), it_end = mTabs.end(); + it != it_end; ++ it) { if (*it) (*it)->externalUpdated(); diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index fccb953b6..615bbc18b 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -408,8 +408,8 @@ void ShopWindow::saveList() } std::vector<ShopItem*> items = mBuyShopItems->items(); - std::vector<ShopItem*>::const_iterator it; - for (it = items.begin(); it != items.end(); ++it) + for (std::vector<ShopItem*>::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++it) { ShopItem *item = *(it); if (item) @@ -417,7 +417,8 @@ void ShopWindow::saveList() } items = mSellShopItems->items(); - for (it = items.begin(); it != items.end(); ++it) + for (std::vector<ShopItem*>::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++it) { if (!(*it)) continue; @@ -440,8 +441,8 @@ void ShopWindow::saveList() sellItem->getPrice()) << std::endl; } - std::map<int, ShopItem*>::const_iterator mapIt; - for (mapIt = mapItems.begin(); mapIt != mapItems.end(); ++mapIt) + for (std::map<int, ShopItem*>::const_iterator mapIt = mapItems.begin(), + mapIt_end = mapItems.end(); mapIt != mapIt_end; ++mapIt) { ShopItem *buyItem = (*mapIt).second; if (buyItem) @@ -480,9 +481,9 @@ void ShopWindow::announce(ShopItems *list, int mode) mSellAnnounceButton->setEnabled(false); std::vector<ShopItem*> items = list->items(); - std::vector<ShopItem*>::const_iterator it; - for (it = items.begin(); it != items.end(); ++it) + for (std::vector<ShopItem*>::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++it) { ShopItem *item = *(it); if (item->getQuantity() > 1) @@ -546,9 +547,9 @@ void ShopWindow::giveList(const std::string &nick, int mode) return; std::vector<ShopItem*> items = list->items(); - std::vector<ShopItem*>::const_iterator it; - for (it = items.begin(); it != items.end(); ++it) + for (std::vector<ShopItem*>::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++it) { ShopItem *item = *(it); if (!item) @@ -792,7 +793,6 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode) return false; std::vector<ShopItem*> items; - std::vector<ShopItem*>::const_iterator it; if (mode == SELL) { if (!mSellShopItems) @@ -806,7 +806,8 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode) items = mBuyShopItems->items(); } - for (it = items.begin(); it != items.end(); ++it) + for (std::vector<ShopItem*>::const_iterator it = items.begin(), + it_end = items.end(); it != it_end; ++ it) { ShopItem *item = *(it); if (!item) diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 6008e97b0..09c6a58fb 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -338,9 +338,8 @@ void SkillDialog::update() PlayerInfo::getAttribute(SKILL_POINTS))); mPointsLabel->adjustSize(); - for (SkillMap::const_iterator it = mSkills.begin(); - it != mSkills.end(); - ++ it) + for (SkillMap::const_iterator it = mSkills.begin(), it_end = mSkills.end(); + it != it_end; ++ it) { if ((*it).second && (*it).second->modifiable) (*it).second->update(); @@ -519,9 +518,9 @@ void SkillModel::updateVisibilities() { mVisibleSkills.clear(); - for (SkillList::const_iterator it = mSkills.begin(); - it != mSkills.end(); - ++ it) + for (SkillList::const_iterator it = mSkills.begin(), + it_end = mSkills.end(); + it != it_end; ++ it) { if ((*it)->visible) mVisibleSkills.push_back((*it)); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 458fe1450..876c98d32 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -556,7 +556,8 @@ public: Avatar *ava = nullptr; std::vector<Avatar*>::const_iterator i = avatars->begin(); - while (i != avatars->end()) + std::vector<Avatar*>::const_iterator i_end = avatars->end(); + while (i != i_end) { ava = (*i); if (ava && ava->getName() == name) @@ -589,7 +590,8 @@ public: break; StringVectCIter i = names.begin(); - while (i != names.end()) + StringVectCIter i_end = names.end(); + while (i != i_end) { if (ava->getName() == (*i) && (*i) != "") { @@ -611,8 +613,9 @@ public: } StringVectCIter i = names.begin(); + StringVectCIter i_end = names.end(); - while (i != names.end()) + while (i != i_end) { if ((*i) != "") updateAvatar(*i); @@ -779,7 +782,8 @@ public: Avatar *ava = nullptr; std::vector<Avatar*>::const_iterator i = avatars->begin(); - while (i != avatars->end()) + std::vector<Avatar*>::const_iterator i_end = avatars->end(); + while (i != i_end) { ava = (*i); if (!ava) @@ -813,8 +817,9 @@ public: Avatar *ava = nullptr; std::vector<Avatar*>::const_iterator i = avatars->begin(); + std::vector<Avatar*>::const_iterator i_end = avatars->end(); unsigned num = 0; - while (i != avatars->end()) + while (i != i_end) { ava = (*i); @@ -878,8 +883,9 @@ public: return; std::vector<Avatar*>::iterator i = avatars->begin(); + std::vector<Avatar*>::iterator i_end = avatars->end(); - while (i != avatars->end()) + while (i != i_end) { Avatar *ava = (*i); @@ -956,7 +962,6 @@ public: std::list<std::string> mobs = actorSpriteManager->getPriorityAttackMobs(); - std::list<std::string>::iterator i = mobs.begin(); std::vector<Avatar*>::iterator ia = avatars->begin(); @@ -975,7 +980,10 @@ public: ava->setY(0); avatars->push_back(ava); - while (i != mobs.end()) + std::list<std::string>::const_iterator i = mobs.begin(); + std::list<std::string>::const_iterator i_end = mobs.end(); + + while (i != i_end) { std::string name; int level = -1; @@ -1009,8 +1017,9 @@ public: mobs = actorSpriteManager->getAttackMobs(); i = mobs.begin(); + i_end = mobs.end(); - while (i != mobs.end()) + while (i != i_end) { std::string name; int level = -1; @@ -1044,8 +1053,9 @@ public: mobs = actorSpriteManager->getIgnoreAttackMobs(); i = mobs.begin(); + i_end = mobs.end(); - while (i != mobs.end()) + while (i != i_end) { std::string name; int level = -1; @@ -1150,9 +1160,8 @@ public: if (!players) return; - StringVectIter it = players->begin(); - StringVectIter it_end = players->end(); - for (; it != it_end; ++ it) + for (StringVectCIter it = players->begin(), it_end = players->end(); + it != it_end; ++ it) { Avatar *ava = nullptr; ava = new Avatar(*it); diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 4dd53cee1..fd9f5ab5a 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -134,8 +134,8 @@ void SpecialsWindow::draw(gcn::Graphics *graphics) unsigned int found = 0; // number of entries in specialData // which match mEntries - for (std::map<int, Special>::const_iterator i = specialData.begin(); - i != specialData.end(); ++i) + for (std::map<int, Special>::const_iterator i = specialData.begin(), + i_end = specialData.end(); i != i_end; ++i) { std::map<int, SpecialEntry *>::const_iterator e = mEntries.find(i->first); @@ -167,9 +167,8 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData) mEntries.clear(); int vPos = 0; //vertical position of next placed element - for (std::map<int, Special>::const_iterator i = specialData.begin(); - i != specialData.end(); - ++i) + for (std::map<int, Special>::const_iterator i = specialData.begin(), + i_end = specialData.end(); i != i_end; ++i) { logger->log("Updating special GUI for %d", i->first); diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index b1dade7d0..4798cbd84 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -444,10 +444,11 @@ void StatusWindow::clearAttributes() { mAttrCont->clear(); mDAttrCont->clear(); - Attrs::iterator it = mAttrs.begin(); - Attrs::iterator it_end = mAttrs.end(); - for (; it != it_end; ++ it) + for (Attrs::iterator it = mAttrs.begin(), it_end = mAttrs.end(); + it != it_end; ++ it) + { delete (*it).second; + } mAttrs.clear(); } diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index fe695e0ea..c3025f516 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -87,7 +87,7 @@ public: } virtual ~IconsModal() - {} + { } virtual int getNumberOfElements() { diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index dad553e81..4112a702f 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -292,7 +292,9 @@ void Theme::setMinimumOpacity(float minimumOpacity) void Theme::updateAlpha() { - for (SkinIterator iter = mSkins.begin(); iter != mSkins.end(); ++iter) + for (SkinIterator iter = mSkins.begin(), iter_end = mSkins.end(); + iter != iter_end; + ++ iter) { if (iter->second) iter->second->updateAlpha(mMinimumOpacity); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 3b58e03a9..35382bfdf 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -368,7 +368,8 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path, if (Net::getNetworkType() != ServerInfo::MANASERV) #endif { - for (Path::const_iterator i = path.begin(); i != path.end(); ++i) + for (Path::const_iterator i = path.begin(), i_end = path.end(); + i != i_end; ++i) { int squareX = i->x * 32 - static_cast<int>(mPixelViewX) + 12; int squareY = i->y * 32 - static_cast<int>(mPixelViewY) + 12; @@ -385,7 +386,8 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path, #ifdef MANASERV_SUPPORT else if (Net::getNetworkType() == ServerInfo::MANASERV) { - for (Path::const_iterator i = path.begin(); i != path.end(); ++i) + for (Path::const_iterator i = path.begin(), i_end = path.end(); + i != i_end; ++i) { int squareX = i->x - static_cast<int>(mPixelViewX); int squareY = i->y - static_cast<int>(mPixelViewY); diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index b9b692c0f..a7cbca7cc 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -143,11 +143,11 @@ WhoIsOnline::~WhoIsOnline() // Remove possibly leftover temporary download delete []mCurlError; - std::set<OnlinePlayer*>::iterator itd = mOnlinePlayers.begin(); - std::set<OnlinePlayer*>::iterator itd_end = mOnlinePlayers.end(); - - for (; itd != itd_end; ++ itd) + for (std::set<OnlinePlayer*>::iterator itd = mOnlinePlayers.begin(), + itd_end = mOnlinePlayers.end(); itd != itd_end; ++ itd) + { delete *itd; + } mOnlinePlayers.clear(); mOnlineNicks.clear(); } @@ -253,19 +253,18 @@ void WhoIsOnline::loadList(std::vector<OnlinePlayer*> &list) std::vector<OnlinePlayer*> disregard; std::vector<OnlinePlayer*> enemy; - std::set<OnlinePlayer*>::iterator itd = mOnlinePlayers.begin(); - std::set<OnlinePlayer*>::iterator itd_end = mOnlinePlayers.end(); - - for (; itd != itd_end; ++ itd) + for (std::set<OnlinePlayer*>::iterator itd = mOnlinePlayers.begin(), + itd_end = mOnlinePlayers.end(); itd != itd_end; ++ itd) + { delete *itd; + } mOnlinePlayers.clear(); mOnlineNicks.clear(); mShowLevel = config.getBoolValue("showlevel"); - std::vector<OnlinePlayer*>::iterator it = list.begin(); - std::vector<OnlinePlayer*>::iterator it_end = list.end(); - for (; it != it_end; ++ it) + for (std::vector<OnlinePlayer*>::const_iterator it = list.begin(), + it_end = list.end(); it != it_end; ++ it) { OnlinePlayer *player = *it; std::string nick = player->getNick(); @@ -342,11 +341,11 @@ void WhoIsOnline::loadWebList() char *line = strtok(mMemoryBuffer, "\n"); const std::string gmText = "(GM)"; - std::set<OnlinePlayer*>::iterator itd = mOnlinePlayers.begin(); - std::set<OnlinePlayer*>::iterator itd_end = mOnlinePlayers.end(); - - for (; itd != itd_end; ++ itd) + for (std::set<OnlinePlayer*>::iterator itd = mOnlinePlayers.begin(), + itd_end = mOnlinePlayers.end(); itd != itd_end; ++ itd) + { delete *itd; + } mOnlinePlayers.clear(); mOnlineNicks.clear(); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 8cbeec78c..30a5e72b6 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -219,7 +219,8 @@ void BrowserBox::addRow(const std::string &row, bool atTop) int hyphenWidth = font->getWidth(hyphen); unsigned x = 0; - for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i) + for (TextRowCIter i = mTextRows.begin(), i_end = mTextRows.end(); + i != i_end; ++ i) { std::string tempRow = *i; for (unsigned int j = 0; j < tempRow.size(); j++) @@ -374,9 +375,8 @@ void BrowserBox::draw(gcn::Graphics *graphics) gcn::Font *font = getFont(); - for (LinePartIterator i = mLineParts.begin(); - i != mLineParts.end(); - ++i) + for (LinePartCIter i = mLineParts.begin(), i_end = mLineParts.end(); + i != i_end; ++i) { const LinePart &part = *i; if (part.mY + 50 < mYStart) @@ -425,7 +425,8 @@ int BrowserBox::calcHeight() mLineParts.clear(); - for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i) + for (TextRowCIter i = mTextRows.begin(), i_end = mTextRows.end(); + i != i_end; ++ i) { const std::string row = *(i); bool wrapped = false; @@ -670,9 +671,8 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) int lastY = 0; - for (LinePartIterator i = mLineParts.begin(); - i != mLineParts.end(); - ++i) + for (LinePartCIter i = mLineParts.begin(), i_end = mLineParts.end(); + i != i_end; ++i) { const LinePart &part = *i; if (part.mY + 50 < mYStart) diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 55bea8dad..edea47ddf 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -206,11 +206,13 @@ class BrowserBox : public gcn::Widget, int calcHeight(); typedef TextRows::iterator TextRowIterator; + typedef TextRows::const_iterator TextRowCIter; TextRows mTextRows; std::list<int> mTextRowLinksCount; typedef std::vector<LinePart> LinePartList; typedef LinePartList::iterator LinePartIterator; + typedef LinePartList::const_iterator LinePartCIter; LinePartList mLineParts; typedef std::vector<BROWSER_LINK> Links; diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 106112956..e085d609f 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -37,8 +37,8 @@ Container::~Container() bool Container::safeRemove(gcn::Widget* widget) { - WidgetListConstIterator iter; - for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) + for (WidgetListConstIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++iter) { if (*iter == widget) { diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 0aabcd297..e52cc0e0c 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -529,8 +529,8 @@ void ItemContainer::updateMatrix() break; } - std::vector<ItemIdPair*>::const_iterator iter; - for (iter = sortedItems.begin(); iter != sortedItems.end(); ++iter) + for (std::vector<ItemIdPair*>::const_iterator iter = sortedItems.begin(), + iter_end = sortedItems.end(); iter != sortedItems.end(); ++ iter) { if (j >= mGridRows) break; diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index f3f8b1526..13c2668f5 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -87,8 +87,8 @@ void SetupTabScroll::addControl(SetupItem *widget, std::string event) void SetupTabScroll::apply() { - std::map<std::string, SetupItem*>::const_iterator iter; - for (iter = mItems.begin(); iter != mItems.end(); ++ iter) + for (std::map<std::string, SetupItem*>::const_iterator + iter = mItems.begin(); iter != mItems.end(); ++ iter) { if ((*iter).second) (*iter).second->apply((*iter).first); @@ -97,8 +97,8 @@ void SetupTabScroll::apply() void SetupTabScroll::cancel() { - std::map<std::string, SetupItem*>::const_iterator iter; - for (iter = mItems.begin(); iter != mItems.end(); ++ iter) + for (std::map<std::string, SetupItem*>::const_iterator + iter = mItems.begin(); iter != mItems.end(); ++ iter) { if ((*iter).second) (*iter).second->cancel((*iter).first); @@ -107,8 +107,8 @@ void SetupTabScroll::cancel() void SetupTabScroll::externalUpdated() { - std::map<std::string, SetupItem*>::const_iterator iter; - for (iter = mItems.begin(); iter != mItems.end(); ++ iter) + for (std::map<std::string, SetupItem*>::const_iterator + iter = mItems.begin(); iter != mItems.end(); ++ iter) { SetupItem *widget = (*iter).second; if (widget && !widget->isMainConfig()) diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 5896af304..96e81b534 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -167,8 +167,8 @@ void TabbedArea::removeTab(gcn::Tab *tab) tabIndexToBeSelected = index - 1; } - TabContainer::iterator iter; - for (iter = mTabs.begin(); iter != mTabs.end(); ++iter) + for (TabContainer::iterator iter = mTabs.begin(); + iter != mTabs.end(); ++iter) { if (iter->first == tab) { @@ -178,8 +178,8 @@ void TabbedArea::removeTab(gcn::Tab *tab) } } - std::vector<gcn::Tab*>::iterator iter2; - for (iter2 = mTabsToDelete.begin(); iter2 != mTabsToDelete.end(); ++iter2) + for (std::vector<gcn::Tab*>::iterator iter2 = mTabsToDelete.begin(); + iter2 != mTabsToDelete.end(); ++iter2) { if (*iter2 == tab) { diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp index 6b3f42fe9..758b69846 100644 --- a/src/gui/widgets/tabstrip.cpp +++ b/src/gui/widgets/tabstrip.cpp @@ -56,8 +56,8 @@ void TabStrip::action(const gcn::ActionEvent &event) gcn::Widget *widget = event.getSource(); if (static_cast<Button*>(widget)->isPressed2()) { - WidgetListConstIterator iter; - for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter) + for (WidgetListConstIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) { if (*iter != widget) { diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index b2b513850..076cf059c 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -55,8 +55,7 @@ void WidgetGroup::addButton(std::string text, std::string tag) void WidgetGroup::action(const gcn::ActionEvent &event) { - ActionListenerIterator iter; - for (iter = mActionListeners.begin(); + for (ActionListenerIterator iter = mActionListeners.begin(); iter != mActionListeners.end(); ++iter) { (*iter)->action(event); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 6e6918694..d956e9adf 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -382,12 +382,11 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED) if (gui) gui->setCursorType(Gui::CURSOR_POINTER); - WidgetListConstIterator it; - if (!mFocusHandler) return; - for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) + for (WidgetListConstIterator it = mWidgets.begin(); + it != mWidgets.end(); ++ it) { if (mFocusHandler->isFocused(*it)) mFocusHandler->focusNone(); diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index 9e698ffa6..2e40d88d2 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -47,7 +47,8 @@ void WindowContainer::scheduleDelete(gcn::Widget *widget) void WindowContainer::adjustAfterResize(int oldScreenWidth, int oldScreenHeight) { - for (WidgetListIterator i = mWidgets.begin(); i != mWidgets.end(); ++i) + for (WidgetListIterator i = mWidgets.begin(), i_end = mWidgets.end(); + i != i_end; ++i) { if (Window *window = dynamic_cast<Window*>(*i)) window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight); diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index e1ac916eb..6a9166219 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -127,8 +127,8 @@ WindowMenu::~WindowMenu() delete mTextPopup; mTextPopup = nullptr; mButtonNames.clear(); - std::vector <gcn::Button*>::iterator it, it_end; - for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) + for (std::vector <gcn::Button*>::iterator it = mButtons.begin(), + it_end = mButtons.end(); it != it_end; ++it) { Button *btn = dynamic_cast<Button*>(*it); if (!btn) |