From 4b2cb3433c82ba4ba28be8de82e0a49df7f3e388 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 4 Jul 2011 03:07:26 +0300 Subject: Replace some lists to vectors. --- src/gui/chatwindow.h | 2 +- src/gui/gui.cpp | 3 ++- src/gui/ministatus.cpp | 6 +++--- src/gui/ministatus.h | 4 ++-- src/gui/popupmenu.cpp | 8 ++++---- src/gui/windowmenu.cpp | 6 +++--- src/gui/windowmenu.h | 5 +++-- src/net/manaserv/attributes.cpp | 2 +- src/net/tmwa/generalhandler.cpp | 2 +- src/particleemitter.cpp | 4 ++-- src/particleemitter.h | 2 +- src/resources/itemdb.cpp | 6 +++--- src/resources/itemdb.h | 2 +- src/utils/stringutils.cpp | 4 ++-- src/utils/stringutils.h | 2 +- 15 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index d68fa7671..0c43dcd8e 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -317,7 +317,7 @@ class ChatWindow : public Window, bool mReturnToggles; /**< Marks whether toggles the chat log or not */ - std::list mTradeFilter; + std::vector mTradeFilter; gcn::DropDown *mColorPicker; ColorListModel *mColorListModel; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 05b168b5e..0bea1d0d7 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -419,7 +419,8 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, (*it)->mouseClicked(mouseEvent); break; default: - throw GCN_EXCEPTION("Unknown mouse event type."); + break; +// throw GCN_EXCEPTION("Unknown mouse event type."); } } diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 4c57812d5..feaf5e0ca 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -134,7 +134,7 @@ MiniStatusWindow::~MiniStatusWindow() if (inv) inv->removeInventoyListener(this); - std::list ::iterator it, it_end; + std::vector ::iterator it, it_end; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) { ProgressBar *bar = *it; @@ -160,7 +160,7 @@ ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height, void MiniStatusWindow::updateBars() { int x = 0; - std::list ::iterator it, it_end; + std::vector ::iterator it, it_end; ProgressBar* lastBar = 0; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) safeRemove(*it); @@ -439,7 +439,7 @@ void MiniStatusWindow::loadBars() void MiniStatusWindow::saveBars() { - std::list ::iterator it, it_end; + std::vector ::iterator it, it_end; int i = 0; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h index a2648d44b..0915ba8d4 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatus.h @@ -88,7 +88,7 @@ class MiniStatusWindow : public Popup, void slotsChanged(Inventory* inventory); - std::list &getBars() + std::vector &getBars() { return mBars; } private: @@ -116,7 +116,7 @@ class MiniStatusWindow : public Popup, ProgressBar *mStatusBar; TextPopup *mTextPopup; StatusPopup *mStatusPopup; - std::list mBars; + std::vector mBars; std::map mBarNames; std::vector mIcons; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 33d0425e1..0ede3d122 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -1755,8 +1755,8 @@ void PopupMenu::showPopup(int x, int y, Button *button) mButton = button; mBrowserBox->clearRows(); - std::list names = windowMenu->getButtons(); - std::list ::iterator it, it_end; + std::vector names = windowMenu->getButtons(); + std::vector ::iterator it, it_end; for (it = names.begin(), it_end = names.end(); it != it_end; ++ it) { Button *btn = dynamic_cast(*it); @@ -1790,8 +1790,8 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) mNick = b->text(); mBrowserBox->clearRows(); - std::list bars = miniStatusWindow->getBars(); - std::list ::iterator it, it_end; + std::vector bars = miniStatusWindow->getBars(); + std::vector ::iterator it, it_end; for (it = bars.begin(), it_end = bars.end(); it != it_end; ++it) { ProgressBar *bar = *it; diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index c62ab9bba..e47888a3a 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -117,7 +117,7 @@ WindowMenu::~WindowMenu() delete mTextPopup; mTextPopup = 0; mButtonNames.clear(); - std::list ::iterator it, it_end; + std::vector ::iterator it, it_end; for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) { Button *btn = dynamic_cast(*it); @@ -329,7 +329,7 @@ void WindowMenu::showButton(std::string name, bool isVisible) void WindowMenu::updateButtons() { int x = 0, h = 0; - std::list ::iterator it, it_end; + std::vector ::iterator it, it_end; for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) safeRemove(*it); for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) @@ -372,7 +372,7 @@ void WindowMenu::loadButtons() void WindowMenu::saveButtons() { - std::list ::iterator it, it_end; + std::vector ::iterator it, it_end; int i = 0; for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index cebae7c11..503a8c1ad 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -30,6 +30,7 @@ #include #include +#include #ifdef __GNUC__ #define _UNUSED_ __attribute__ ((unused)) @@ -68,7 +69,7 @@ class WindowMenu : public Container, std::map &getButtonNames() { return mButtonNames; } - std::list &getButtons() + std::vector &getButtons() { return mButtons; } void showButton(std::string name, bool isVisible); @@ -85,7 +86,7 @@ class WindowMenu : public Container, EmotePopup *mEmotePopup; TextPopup *mTextPopup; - std::list mButtons; + std::vector mButtons; std::map mButtonNames; }; diff --git a/src/net/manaserv/attributes.cpp b/src/net/manaserv/attributes.cpp index fa95a3d6d..b48cc9eff 100644 --- a/src/net/manaserv/attributes.cpp +++ b/src/net/manaserv/attributes.cpp @@ -380,7 +380,7 @@ namespace Attributes void informItemDB() { - std::list dbStats; + std::vector dbStats; TagMap::const_iterator it, it_end; for (it = tags.begin(), it_end = tags.end(); it != it_end; ++it) diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index b091267b7..7993c24dc 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -103,7 +103,7 @@ GeneralHandler::GeneralHandler(): handledMessages = _messages; generalHandler = this; - std::list stats; + std::vector stats; stats.push_back(ItemDB::Stat("str", _("Strength %+d"))); stats.push_back(ItemDB::Stat("agi", _("Agility %+d"))); stats.push_back(ItemDB::Stat("vit", _("Vitality %+d"))); diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index 6b6cca44b..c04b1b36f 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -435,7 +435,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o) mDeathEffect = o.mDeathEffect; mTempSets = o.mTempSets; - for (std::list::iterator + for (std::vector::iterator i = mTempSets.begin(); i != mTempSets.end(); ++i) { @@ -453,7 +453,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o) ParticleEmitter::~ParticleEmitter() { - for (std::list::iterator + for (std::vector::iterator i = mTempSets.begin(); i != mTempSets.end(); ++i) { diff --git a/src/particleemitter.h b/src/particleemitter.h index e82483370..49826d0f6 100644 --- a/src/particleemitter.h +++ b/src/particleemitter.h @@ -150,6 +150,6 @@ class ParticleEmitter /** List of emitters the spawned particles are equipped with */ std::list mParticleChildEmitters; - std::list mTempSets; + std::vector mTempSets; }; #endif diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index b4e33dfa7..1260fab58 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -65,9 +65,9 @@ static char const *const fields[][2] = { "mp", N_("MP %+d") } }; -static std::list extraStats; +static std::vector extraStats; -void ItemDB::setStatsList(const std::list &stats) +void ItemDB::setStatsList(const std::vector &stats) { extraStats = stats; } @@ -307,7 +307,7 @@ void ItemDB::load() effect += " / "; effect += strprintf(gettext(fields[i][1]), value); } - for (std::list::iterator it = extraStats.begin(); + for (std::vector::iterator it = extraStats.begin(); it != extraStats.end(); ++it) { int value = XML::getProperty(node, it->tag.c_str(), 0); diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 8c90e6769..ee16a6355 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -77,7 +77,7 @@ namespace ItemDB std::string format; }; - void setStatsList(const std::list &stats); + void setStatsList(const std::vector &stats); } diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 953cbf58a..ad2e52965 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -181,11 +181,11 @@ unsigned long findI(std::string str, std::string subStr) return str.find(subStr); } -unsigned long findI(std::string str, std::list &list) +unsigned long findI(std::string str, std::vector &list) { str = toLower(str); unsigned long idx; - for (std::list::iterator i = list.begin(); + for (std::vector::iterator i = list.begin(); i != list.end(); ++i) { std::string subStr = toLower(*i); diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 140baf944..4693b5425 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -133,7 +133,7 @@ bool isWordSeparator(char chr); unsigned long findI(std::string str, std::string subStr); -unsigned long findI(std::string str, std::list &list); +unsigned long findI(std::string str, std::vector &list); const std::string encodeStr(unsigned int value, unsigned int size = 0); -- cgit v1.2.3-70-g09d2