From af4727577f39720564b4339de267aa0aae7af4a5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 5 Sep 2011 19:18:46 +0300 Subject: Fix multiply new message sounds at same time. --- src/resources/soundeffect.cpp | 2 +- src/resources/soundeffect.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/resources') diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index 49e7adc31..de11a8786 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -53,7 +53,7 @@ Resource *SoundEffect::load(void *buffer, unsigned bufferSize) } } -bool SoundEffect::play(int loops, int volume) +bool SoundEffect::play(int loops, int volume, int channel) { Mix_VolumeChunk(mChunk, volume); diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 80f826646..fdd4bd275 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -54,11 +54,12 @@ class SoundEffect : public Resource * * @param loops Number of times to repeat the playback. * @param volume Sample playback volume. + * @param channel Sample playback channel. * * @return true if the playback started properly * false otherwise. */ - virtual bool play(int loops, int volume); + virtual bool play(int loops, int volume, int channel = -1); protected: /** -- cgit v1.2.3-70-g09d2 From 64a14cb9d04c4cf0ea5a2ff5b09578c86335086b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 5 Sep 2011 21:32:56 +0300 Subject: fix missing set sound channel. --- src/resources/soundeffect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/resources') diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index de11a8786..e8e5d3dbb 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -57,5 +57,5 @@ bool SoundEffect::play(int loops, int volume, int channel) { Mix_VolumeChunk(mChunk, volume); - return Mix_PlayChannel(-1, mChunk, loops) != -1; + return Mix_PlayChannel(channel, mChunk, loops) != -1; } -- cgit v1.2.3-70-g09d2 From b3f70d8d46199524edc590269a73c262899763c7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 8 Sep 2011 00:07:56 +0300 Subject: Replace most iterator to const_iterator. Some other minor changes. --- src/actorsprite.cpp | 2 +- src/actorspritemanager.cpp | 34 +++++++++++++++---------------- src/being.cpp | 12 +++++------ src/compoundsprite.cpp | 6 +++--- src/effectmanager.cpp | 4 ++-- src/event.cpp | 7 ++++--- src/graphics.cpp | 6 +++--- src/gui/buydialog.cpp | 4 ++-- src/gui/buyselldialog.cpp | 4 ++-- src/gui/charselectdialog.cpp | 4 +++- src/gui/chatwindow.cpp | 14 ++++++------- src/gui/gui.cpp | 2 +- src/gui/ministatuswindow.cpp | 6 +++--- src/gui/npcdialog.cpp | 16 +++++++-------- src/gui/npcpostdialog.cpp | 4 ++-- src/gui/palette.cpp | 4 ++-- src/gui/popupmenu.cpp | 10 +++++----- src/gui/quitdialog.cpp | 2 +- src/gui/selldialog.cpp | 4 ++-- src/gui/setup.cpp | 13 +++++++----- src/gui/setup_video.cpp | 4 ++-- src/gui/shopwindow.cpp | 10 +++++----- src/gui/skilldialog.cpp | 12 +++++++---- src/gui/socialwindow.cpp | 14 ++++++------- src/gui/specialswindow.cpp | 5 +++-- src/gui/statuswindow.cpp | 12 +++++------ src/gui/userpalette.cpp | 2 +- src/gui/widgets/chattab.cpp | 2 +- src/gui/widgets/flowcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/layout.cpp | 10 ++++++---- src/gui/widgets/setuptabscroll.cpp | 18 +++++++++++------ src/gui/widgets/vertcontainer.cpp | 5 +++-- src/gui/widgets/window.cpp | 2 +- src/gui/windowmenu.cpp | 2 +- src/guichan/focushandler.cpp | 6 ++++-- src/guichan/gui.cpp | 8 ++++---- src/guichan/widget.cpp | 2 +- src/guichan/widgets/window.cpp | 2 +- src/guild.cpp | 6 +++--- src/guildmanager.cpp | 4 ++-- src/localplayer.cpp | 14 ++++++------- src/map.cpp | 41 ++++++++++++++++++++------------------ src/net/ea/inventoryhandler.cpp | 4 ++-- src/net/manaserv/network.cpp | 6 +----- src/net/manaserv/npchandler.cpp | 4 +--- src/net/tmwa/npchandler.cpp | 2 +- src/openglgraphics.cpp | 8 ++++---- src/particlecontainer.cpp | 2 +- src/particleemitter.cpp | 6 +++--- src/party.cpp | 7 ++++--- src/playerinfo.cpp | 5 ++++- src/resources/image.cpp | 4 ++-- src/resources/itemdb.cpp | 2 +- src/resources/iteminfo.cpp | 6 ++++-- src/resources/mapreader.cpp | 2 +- src/resources/specialdb.cpp | 2 +- src/resources/spritedef.cpp | 2 +- src/resources/wallpaper.cpp | 2 +- src/spellmanager.cpp | 4 ++-- src/textmanager.cpp | 7 ++++--- src/utils/stringutils.cpp | 11 +++++----- 62 files changed, 228 insertions(+), 201 deletions(-) (limited to 'src/resources') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 2b133eca5..2cc138047 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -113,7 +113,7 @@ void ActorSprite::logic() if (mMustResetParticles) { mMustResetParticles = false; - for (std::set::iterator it = mStatusEffects.begin(); + for (std::set::const_iterator it = mStatusEffects.begin(); it != mStatusEffects.end(); ++it) { const StatusEffect *effect diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 5f28f237c..edd1db2aa 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -105,9 +105,9 @@ class SortBeingFunctor { int w1 = defaultPriorityIndex; int w2 = defaultPriorityIndex; - std::map::iterator it1 + std::map::const_iterator it1 = priorityBeings->find(being1->getName()); - std::map::iterator it2 + std::map::const_iterator it2 = priorityBeings->find(being2->getName()); if (it1 != priorityBeings->end()) w1 = (*it1).second; @@ -144,9 +144,9 @@ class SortBeingFunctor { int w1 = defaultAttackIndex; int w2 = defaultAttackIndex; - std::map::iterator it1 + std::map::const_iterator it1 = attackBeings->find(being1->getName()); - std::map::iterator it2 + std::map::const_iterator it2 = attackBeings->find(being2->getName()); if (it1 != attackBeings->end()) w1 = (*it1).second; @@ -327,9 +327,9 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y, return being; } else if (!noBeing && (being->getPixelX() - 32 <= x) && - (being->getPixelX() + 32 > x) && - (being->getPixelY() - 64 <= y) && - (being->getPixelY() + 16 > y)) + (being->getPixelX() + 32 > x) && + (being->getPixelY() - 64 <= y) && + (being->getPixelY() + 16 > y)) { if (tempBeing) noBeing = true; @@ -705,7 +705,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, beingSorter.priorityBeings = &priorityMobsMap; if (ignoreAttackMobs.find("") != ignoreAttackMobs.end()) ignoreDefault = true; - std::map::iterator itr = attackMobsMap.find(""); + std::map::const_iterator itr = attackMobsMap.find(""); if (itr != attackMobsMap.end()) defaultAttackIndex = (*itr).second; itr = priorityMobsMap.find(""); @@ -855,7 +855,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, int w2 = defaultPriorityIndex; if (closestBeing) { - std::map::iterator it2 + std::map::const_iterator it2 = priorityMobsMap.find(being->getName()); if (it2 != priorityMobsMap.end()) w2 = (*it2).second; @@ -880,7 +880,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, { dist = d; closestBeing = being; - std::map::iterator it1 + std::map::const_iterator it1 = priorityMobsMap.find(being->getName()); if (it1 != priorityMobsMap.end()) index = (*it1).second; @@ -1054,7 +1054,7 @@ void ActorSpriteManager::printBeingsToChat(ActorSprites beings, debugChatTab->chatLog("---------------------------------------"); debugChatTab->chatLog(header); - std::set::iterator it; + std::set::const_iterator it; for (it = beings.begin(); it != beings.end(); ++it) { if ((*it)->getType() == ActorSprite::FLOOR_ITEM) @@ -1079,7 +1079,7 @@ void ActorSpriteManager::printBeingsToChat(std::vector beings, debugChatTab->chatLog("---------------------------------------"); debugChatTab->chatLog(header); - std::vector::iterator i; + std::vector::const_iterator i; for (i = beings.begin(); i != beings.end(); ++i) { const Being *being = *i; @@ -1298,7 +1298,7 @@ void ActorSpriteManager::addIgnoreAttackMob(std::string name) void ActorSpriteManager::rebuildPriorityAttackMobs() { mPriorityAttackMobsMap.clear(); - std::list::iterator i = mPriorityAttackMobs.begin(); + std::list::const_iterator i = mPriorityAttackMobs.begin(); int cnt = 0; while (i != mPriorityAttackMobs.end()) { @@ -1311,7 +1311,7 @@ void ActorSpriteManager::rebuildPriorityAttackMobs() void ActorSpriteManager::rebuildAttackMobs() { mAttackMobsMap.clear(); - std::list::iterator i = mAttackMobs.begin(); + std::list::const_iterator i = mAttackMobs.begin(); int cnt = 0; while (i != mAttackMobs.end()) { @@ -1323,7 +1323,7 @@ void ActorSpriteManager::rebuildAttackMobs() int ActorSpriteManager::getPriorityAttackMobIndex(std::string name) { - std::map::iterator i = mPriorityAttackMobsMap.find(name); + std::map::const_iterator i = mPriorityAttackMobsMap.find(name); if (i == mPriorityAttackMobsMap.end()) return -1; @@ -1332,7 +1332,7 @@ int ActorSpriteManager::getPriorityAttackMobIndex(std::string name) int ActorSpriteManager::getAttackMobIndex(std::string name) { - std::map::iterator i = mAttackMobsMap.find(name); + std::map::const_iterator i = mAttackMobsMap.find(name); if (i == mAttackMobsMap.end()) return -1; @@ -1344,7 +1344,7 @@ void ActorSpriteManager::loadAttackList() bool empty = false; std::list list = unpackList( serverConfig.getValue("attackPriorityMobs", "")); - std::list::iterator i = list.begin(); + std::list::const_iterator i = list.begin(); while (i != list.end()) { if (*i == "") diff --git a/src/being.cpp b/src/being.cpp index 5a4bcd737..090e7d10d 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2155,20 +2155,20 @@ void Being::recalcSpritesOrder() if (spriteToItems) { - SpriteToItemMap::iterator it; + SpriteToItemMap::const_iterator it; for (it = spriteToItems->begin(); it != spriteToItems->end(); ++it) { int removeSprite = it->first; - std::map &itemReplacer = it->second; + const std::map &itemReplacer = it->second; if (itemReplacer.empty()) { mSpriteHide[removeSprite] = 1; } else { - std::map::iterator repIt + std::map::const_iterator repIt = itemReplacer.find(mSpriteIDs[removeSprite]); if (repIt != itemReplacer.end()) { @@ -2188,7 +2188,7 @@ void Being::recalcSpritesOrder() if (info.mDrawBefore[dir] > 0) { int id2 = mSpriteIDs[info.mDrawBefore[dir]]; - std::map::iterator orderIt = itemSlotRemap.find(id2); + std::map::const_iterator orderIt = itemSlotRemap.find(id2); if (orderIt != itemSlotRemap.end()) { // logger->log("found duplicate (before)"); @@ -2211,7 +2211,7 @@ void Being::recalcSpritesOrder() else if (info.mDrawAfter[dir] > 0) { int id2 = mSpriteIDs[info.mDrawAfter[dir]]; - std::map::iterator orderIt = itemSlotRemap.find(id2); + std::map::const_iterator orderIt = itemSlotRemap.find(id2); if (orderIt != itemSlotRemap.end()) { // logger->log("found duplicate (after)"); @@ -2256,7 +2256,7 @@ void Being::recalcSpritesOrder() int idx1 = -1; // logger->log("item %d, id=%d", slot, id); int reorder = 0; - std::map::iterator orderIt = itemSlotRemap.find(id); + std::map::const_iterator orderIt = itemSlotRemap.find(id); if (orderIt != itemSlotRemap.end()) reorder = orderIt->second; diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index c6921b2e8..ceab9a149 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -461,7 +461,7 @@ void CompoundSprite::updateImages() const bool CompoundSprite::updateFromCache() const { ImagesCache::iterator it = imagesCache.begin(); - ImagesCache::iterator it_end = imagesCache.end(); + ImagesCache::const_iterator it_end = imagesCache.end(); // static int hits = 0; // static int miss = 0; @@ -491,8 +491,8 @@ bool CompoundSprite::updateFromCache() const bool fail(false); SpriteConstIterator it1 = begin(); SpriteConstIterator it1_end = end(); - VectorPointers::iterator it2 = ic->data.begin(); - VectorPointers::iterator it2_end = ic->data.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) { diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 36e7aac16..55bf692cd 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -67,7 +67,7 @@ bool EffectManager::trigger(int id, Being* being) return false; bool rValue = false; - for (std::vector::iterator i = mEffects.begin(); + for (std::vector::const_iterator i = mEffects.begin(); i != mEffects.end(); ++i) { if ((*i).id == id) @@ -92,7 +92,7 @@ bool EffectManager::trigger(int id, int x, int y) return false; bool rValue = false; - for (std::vector::iterator i = mEffects.begin(); + for (std::vector::const_iterator i = mEffects.begin(); i != mEffects.end(); ++i) { if ((*i).id == id) diff --git a/src/event.cpp b/src/event.cpp index 8660f6b94..8ac9be189 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -107,17 +107,18 @@ double Event::getFloat(const std::string &key) const throw (BadEvent) void Event::trigger(Channels channel, const Event &event) { - ListenMap::iterator it = mBindings.find(channel); + ListenMap::const_iterator it = mBindings.find(channel); // Make sure something is listening if (it == mBindings.end()) return; // Loop though all listeners - ListenerSet::iterator lit = it->second.begin(); + ListenerSet::const_iterator lit = it->second.begin(); while (lit != it->second.end()) { - (*lit)->event(channel, event); + if (*lit) + (*lit)->event(channel, event); ++lit; } } diff --git a/src/graphics.cpp b/src/graphics.cpp index abd7341e2..0da8c1bd4 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -453,7 +453,7 @@ void Graphics::drawImagePattern2(GraphicsVertexes *vert, Image *img) // here not checking input parameters std::vector *arr = vert->getRectsSDL(); - std::vector::iterator it; + std::vector::const_iterator it; for (it = arr->begin(); it != arr->end(); ++it) SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst); @@ -603,8 +603,8 @@ void Graphics::drawTile(ImageVertexes *vert) { Image *img = vert->image; DoubleRects *rects = &vert->sdl; - DoubleRects::iterator it = rects->begin(); - DoubleRects::iterator it_end = rects->end(); + DoubleRects::const_iterator it = rects->begin(); + DoubleRects::const_iterator it_end = rects->end(); while (it != it_end) { SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst); diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 8c1ad62ce..4a03370a8 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -317,8 +317,8 @@ void BuyDialog::setVisible(bool visible) void BuyDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + DialogList::const_iterator it = instances.begin(); + DialogList::const_iterator it_end = instances.end(); for (; it != it_end; ++it) { diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index 14dcb0bc1..dfe7a422a 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -129,8 +129,8 @@ void BuySellDialog::action(const gcn::ActionEvent &event) void BuySellDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + DialogList::const_iterator it = instances.begin(); + DialogList::const_iterator it_end = instances.end(); for (; it != it_end; ++it) { diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 1942ebaeb..75468d1ab 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -309,10 +309,12 @@ void CharSelectDialog::attemptCharacterSelect(int index) void CharSelectDialog::setCharacters(const Net::Characters &characters) { // Reset previous characters - std::vector::iterator iter, iter_end; + std::vector::const_iterator iter, iter_end; for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end(); iter != iter_end; ++iter) + { (*iter)->setCharacter(0); + } Net::Characters::const_iterator i, i_end = characters.end(); for (i = characters.begin(); i != i_end; ++i) diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 784fb812a..0f42fb1b6 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -754,7 +754,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mChatHistoryIndex --; } - std::list::iterator it; + std::list::const_iterator it; unsigned int f = 0; for (it = tab->getRows().begin(); it != tab->getRows().end(); ++it, f++) @@ -788,7 +788,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mChatHistoryIndex = 0; } - std::list::iterator it; + std::list::const_iterator it; unsigned int f = 0; for (it = tab->getRows().begin(); it != tab->getRows().end(); ++it, f++) @@ -1179,7 +1179,7 @@ void ChatWindow::autoComplete() std::string ChatWindow::autoComplete(std::vector &names, std::string partName) const { - std::vector::iterator i = names.begin(); + std::vector::const_iterator i = names.begin(); toLower(partName); std::string newName(""); @@ -1215,7 +1215,7 @@ std::string ChatWindow::autoComplete(std::string partName, History *words) if (!words) return ""; - Commands::iterator i = words->begin(); + Commands::const_iterator i = words->begin(); std::vector nameList; while (i != words->end()) @@ -1243,7 +1243,7 @@ void ChatWindow::moveTabRight(ChatTab *tab) std::string ChatWindow::autoCompleteHistory(std::string partName) { - History::iterator i = mHistory.begin(); + History::const_iterator i = mHistory.begin(); std::vector nameList; while (i != mHistory.end()) @@ -1344,7 +1344,7 @@ void ChatWindow::initTradeFilter() void ChatWindow::updateOnline(std::set &onlinePlayers) { - TabMap::iterator iter; + TabMap::const_iterator iter; const Party *party = 0; const Guild *guild = 0; if (player_node) @@ -1429,7 +1429,7 @@ void ChatWindow::loadState() void ChatWindow::saveState() { int num = 0; - TabMap::iterator iter; + TabMap::const_iterator iter; for (iter = mWhispers.begin(); iter != mWhispers.end() && num < 50; ++iter) { if (!iter->second) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 7d38b1025..658d65769 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -394,7 +394,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, = widget->_getMouseListeners(); // Send the event to all mouse listeners of the widget. - for (std::list::iterator + for (std::list::const_iterator it = mouseListeners.begin(); it != mouseListeners.end(); ++ it) { diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 08e3d0053..da39eb24c 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -134,7 +134,7 @@ MiniStatusWindow::~MiniStatusWindow() if (inv) inv->removeInventoyListener(this); - std::vector ::iterator it, it_end; + std::vector ::const_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::vector ::iterator it, it_end; + std::vector ::const_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::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; int i = 0; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 0db618d69..d941153b7 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -362,12 +362,12 @@ bool NpcDialog::isInputFocused() const bool NpcDialog::isAnyInputFocused() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + DialogList::const_iterator it = instances.begin(); + DialogList::const_iterator it_end = instances.end(); for (; it != it_end; ++it) { - if ((*it)->isInputFocused()) + if ((*it) && (*it)->isInputFocused()) return true; } @@ -430,12 +430,12 @@ NpcDialog *NpcDialog::getActive() if (instances.size() == 1) return instances.front(); - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + DialogList::const_iterator it = instances.begin(); + DialogList::const_iterator it_end = instances.end(); for (; it != it_end; ++it) { - if ((*it)->isFocused()) + if ((*it) && (*it)->isFocused()) return (*it); } @@ -444,8 +444,8 @@ NpcDialog *NpcDialog::getActive() void NpcDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + DialogList::const_iterator it = instances.begin(); + DialogList::const_iterator it_end = instances.end(); for (; it != it_end; ++it) { diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 0ba4e44b6..72dd76aa3 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -123,8 +123,8 @@ void NpcPostDialog::setVisible(bool visible) void NpcPostDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + DialogList::const_iterator it = instances.begin(); + DialogList::const_iterator it_end = instances.end(); for (; it != it_end; ++it) (*it)->close(); diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index f5c074f6c..f3046264f 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -80,8 +80,8 @@ const gcn::Color& Palette::getColor(char c, bool &valid) void Palette::advanceGradients() { - Palettes::iterator it = mInstances.begin(); - Palettes::iterator it_end = mInstances.end(); + Palettes::const_iterator it = mInstances.begin(); + Palettes::const_iterator it_end = mInstances.end(); for (; it != it_end; ++it) (*it)->advanceGradient(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 0eac0a4f9..a329488ce 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -360,7 +360,7 @@ void PopupMenu::showPopup(int x, int y, std::vector &beings) { mBrowserBox->clearRows(); mBrowserBox->addRow("Players"); - std::vector::iterator it, it_end; + std::vector::const_iterator it, it_end; for (it = beings.begin(), it_end = beings.end(); it != it_end; ++it) { Being *being = *it; @@ -804,8 +804,8 @@ void PopupMenu::showChangePos(int x, int y) if (guild) { PositionsMap map = guild->getPositions(); - PositionsMap::iterator itr = map.begin(); - PositionsMap::iterator itr_end = map.end(); + PositionsMap::const_iterator itr = map.begin(); + PositionsMap::const_iterator itr_end = map.end(); for (; itr != itr_end; ++itr) { mBrowserBox->addRow(strprintf("@@guild-pos-%d|%s@@", @@ -1872,7 +1872,7 @@ void PopupMenu::showPopup(int x, int y, Button *button) mBrowserBox->clearRows(); std::vector names = windowMenu->getButtons(); - std::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; for (it = names.begin(), it_end = names.end(); it != it_end; ++ it) { Button *btn = dynamic_cast(*it); @@ -1907,7 +1907,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) mBrowserBox->clearRows(); std::vector bars = miniStatusWindow->getBars(); - std::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; for (it = bars.begin(), it_end = bars.end(); it != it_end; ++it) { ProgressBar *bar = *it; diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 04f43fb88..96848f645 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -178,7 +178,7 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) if (dir != 0) { - std::vector::iterator it = mOptions.begin(); + std::vector::const_iterator it = mOptions.begin(); for (; it < mOptions.end(); ++it) { diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index d9030e3fb..5cbb4167e 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -346,8 +346,8 @@ void SellDialog::setVisible(bool visible) void SellDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + DialogList::const_iterator it = instances.begin(); + DialogList::const_iterator it_end = instances.end(); for (; it != it_end; ++it) (*it)->close(); diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 76e3936c2..113dd9081 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -103,7 +103,8 @@ Setup::Setup(): mTabs.push_back(new Setup_Theme); mTabs.push_back(new Setup_Other); - for (std::list::iterator i = mTabs.begin(), i_end = mTabs.end(); + for (std::list::const_iterator i = mTabs.begin(), + i_end = mTabs.end(); i != i_end; ++i) { SetupTab *tab = *i; @@ -162,10 +163,11 @@ void Setup::action(const gcn::ActionEvent &event) if (!statusWindow) return; - for (std::list::iterator it = mWindowsToReset.begin(); + for (std::list::const_iterator it = mWindowsToReset.begin(); it != mWindowsToReset.end(); ++it) { - (*it)->resetToDefaultSize(); + if (*it) + (*it)->resetToDefaultSize(); } } } @@ -177,10 +179,11 @@ void Setup::setInGame(bool inGame) void Setup::externalUpdate() { - for (std::list::iterator it = mTabs.begin(); + for (std::list::const_iterator it = mTabs.begin(); it != mTabs.end(); ++it) { - (*it)->externalUpdated(); + if (*it) + (*it)->externalUpdated(); } } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 03b485097..0bfab1438 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -166,8 +166,8 @@ ModeListModel::ModeListModel() void ModeListModel::addCustomMode(std::string mode) { - std::vector::iterator it = mVideoModes.begin(); - std::vector::iterator it_end = mVideoModes.end(); + std::vector::const_iterator it = mVideoModes.begin(); + std::vector::const_iterator it_end = mVideoModes.end(); while (it != it_end) { if (*it == mode) diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 9aaf88bf3..5cf1573bb 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -395,7 +395,7 @@ void ShopWindow::saveList() } std::vector items = mBuyShopItems->items(); - std::vector::iterator it; + std::vector::const_iterator it; for (it = items.begin(); it != items.end(); ++it) { ShopItem *item = *(it); @@ -428,7 +428,7 @@ void ShopWindow::saveList() } } - std::map::iterator mapIt; + std::map::const_iterator mapIt; for (mapIt = mapItems.begin(); mapIt != mapItems.end(); ++mapIt) { ShopItem *buyItem = (*mapIt).second; @@ -468,7 +468,7 @@ void ShopWindow::announce(ShopItems *list, int mode) mSellAnnounceButton->setEnabled(false); std::vector items = list->items(); - std::vector::iterator it; + std::vector::const_iterator it; for (it = items.begin(); it != items.end(); ++it) { @@ -534,7 +534,7 @@ void ShopWindow::giveList(const std::string &nick, int mode) return; std::vector items = list->items(); - std::vector::iterator it; + std::vector::const_iterator it; for (it = items.begin(); it != items.end(); ++it) { @@ -780,7 +780,7 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode) return false; std::vector items; - std::vector::iterator it; + std::vector::const_iterator it; if (mode == SELL) { if (!mSellShopItems) diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index bf87e804d..c2685b476 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -321,7 +321,7 @@ void SkillDialog::action(const gcn::ActionEvent &event) std::string SkillDialog::update(int id) { - SkillMap::iterator i = mSkills.find(id); + SkillMap::const_iterator i = mSkills.find(id); if (i != mSkills.end()) { @@ -342,7 +342,9 @@ void SkillDialog::update() PlayerInfo::getAttribute(SKILL_POINTS))); mPointsLabel->adjustSize(); - for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); ++it) + for (SkillMap::const_iterator it = mSkills.begin(); + it != mSkills.end(); + ++ it) { if ((*it).second && (*it).second->modifiable) (*it).second->update(); @@ -467,7 +469,7 @@ void SkillDialog::loadSkills(const std::string &file) bool SkillDialog::setModifiable(int id, bool modifiable) { - SkillMap::iterator it = mSkills.find(id); + SkillMap::const_iterator it = mSkills.find(id); if (it != mSkills.end()) { @@ -508,7 +510,9 @@ void SkillModel::updateVisibilities() { mVisibleSkills.clear(); - for (SkillList::iterator it = mSkills.begin(); it != mSkills.end(); ++it) + for (SkillList::const_iterator it = mSkills.begin(); + it != mSkills.end(); + ++ it) { if ((*it)->visible) mVisibleSkills.push_back((*it)); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 749f26f85..7feca8bf4 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -232,7 +232,7 @@ public: mScroll = 0; } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event A_UNUSED) { /* if (event.getId() == "do invite") @@ -528,7 +528,7 @@ public: return 0; Avatar *ava = 0; - std::vector::iterator i = avatars->begin(); + std::vector::const_iterator i = avatars->begin(); while (i != avatars->end()) { ava = (*i); @@ -562,7 +562,7 @@ public: if (!ava) break; - std::vector::iterator i = names.begin(); + std::vector::const_iterator i = names.begin(); while (i != names.end()) { if (ava->getName() == (*i) && (*i) != "") @@ -584,7 +584,7 @@ public: } } - std::vector::iterator i = names.begin(); + std::vector::const_iterator i = names.begin(); while (i != names.end()) { @@ -659,7 +659,7 @@ public: std::vector *avatars = mBeings->getMembers(); std::vector portals = map->getPortals(); - std::vector::iterator i = portals.begin(); + std::vector::const_iterator i = portals.begin(); SpecialLayer *specialLayer = map->getSpecialLayer(); std::vector::iterator ia = avatars->begin(); @@ -752,7 +752,7 @@ public: return; Avatar *ava = 0; - std::vector::iterator i = avatars->begin(); + std::vector::const_iterator i = avatars->begin(); while (i != avatars->end()) { ava = (*i); @@ -786,7 +786,7 @@ public: return 01; Avatar *ava = 0; - std::vector::iterator i = avatars->begin(); + std::vector::const_iterator i = avatars->begin(); unsigned num = 0; while (i != avatars->end()) { diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 702c31718..64f61e3c3 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -134,10 +134,11 @@ void SpecialsWindow::draw(gcn::Graphics *graphics) unsigned int found = 0; // number of entries in specialData // which match mEntries - for (std::map::iterator i = specialData.begin(); + for (std::map::const_iterator i = specialData.begin(); i != specialData.end(); ++i) { - std::map::iterator e = mEntries.find(i->first); + std::map::const_iterator + e = mEntries.find(i->first); if (e == mEntries.end()) { // found a new special - abort update and rebuild from scratch diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index d1fde2dd1..a85f60133 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -311,7 +311,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, mCharacterPointsLabel->adjustSize(); // Update all attributes - for (Attrs::iterator it = mAttrs.begin(); + for (Attrs::const_iterator it = mAttrs.begin(); it != mAttrs.end(); ++it) { if (it->second) @@ -324,7 +324,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, _("Correction points: %d"), event.getInt("newValue"))); mCorrectionPointsLabel->adjustSize(); // Update all attributes - for (Attrs::iterator it = mAttrs.begin(); + for (Attrs::const_iterator it = mAttrs.begin(); it != mAttrs.end(); ++it) { if (it->second) @@ -392,7 +392,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, else { updateMPBar(mMpBar, true); - Attrs::iterator it = mAttrs.find(id); + Attrs::const_iterator it = mAttrs.find(id); if (it != mAttrs.end() && it->second) { if (it->second) @@ -404,7 +404,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, void StatusWindow::setPointsNeeded(int id, int needed) { - Attrs::iterator it = mAttrs.find(id); + Attrs::const_iterator it = mAttrs.find(id); if (it != mAttrs.end()) { @@ -909,8 +909,8 @@ void StatusWindow::action(const gcn::ActionEvent &event) if (event.getId() == "copy") { - Attrs::iterator it = mAttrs.begin(); - Attrs::iterator it_end = mAttrs.end(); + Attrs::const_iterator it = mAttrs.begin(); + Attrs::const_iterator it_end = mAttrs.end(); std::string str; while (it != it_end) { diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index eac9559ef..62fd03c70 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -172,7 +172,7 @@ UserPalette::UserPalette(): UserPalette::~UserPalette() { - for (Colors::iterator col = mColors.begin(), + for (Colors::const_iterator col = mColors.begin(), colEnd = mColors.end(); col != colEnd; ++col) { const std::string &configName = ColorTypeNames[col->type]; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 81c0d277f..4f358c8e7 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -439,7 +439,7 @@ void ChatTab::loadFromLogFile(std::string name) { std::list list; chatLogger->loadLast(name, list, 5); - std::list::iterator i = list.begin(); + std::list::const_iterator i = list.begin(); while (i != list.end()) { std::string line = "##9" + *i; diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index 33e3790a0..0a64a7142 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -67,7 +67,7 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED) int i = 0; height = 0; - for (WidgetList::iterator it = mWidgets.begin(); + for (WidgetList::const_iterator it = mWidgets.begin(); it != mWidgets.end(); ++it) { int x = i % mGridWidth * mBoxWidth; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 91b674018..3d6d24868 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -479,7 +479,7 @@ void ItemContainer::updateMatrix() break; } - std::vector::iterator iter; + std::vector::const_iterator iter; for (iter = sortedItems.begin(); iter != sortedItems.end(); ++iter) { if (j >= mGridRows) diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index a14b416ce..52b92d0bc 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -86,12 +86,12 @@ void LayoutCell::computeSizes() if (mType != ARRAY) return; - std::vector< std::vector< LayoutCell * > >::iterator + std::vector >::const_iterator i = mArray->mCells.begin(); while (i != mArray->mCells.end()) { - std::vector< LayoutCell * >::iterator j = i->begin(); + std::vector ::const_iterator j = i->begin(); while (j != i->end()) { LayoutCell *cell = *j; @@ -113,7 +113,8 @@ LayoutArray::LayoutArray(): mSpacing(4) LayoutArray::~LayoutArray() { - std::vector< std::vector< LayoutCell * > >::iterator i = mCells.begin(); + std::vector >::iterator + i = mCells.begin(); while (i != mCells.end()) { std::vector< LayoutCell * >::iterator j = i->begin(); @@ -154,7 +155,8 @@ void LayoutArray::resizeGrid(int w, int h) if (extW) mSizes[0].resize(w, Layout::AUTO_DEF); - std::vector< std::vector< LayoutCell * > >::iterator i = mCells.begin(); + std::vector >::iterator + i = mCells.begin(); while (i != mCells.end()) { i->resize(w, 0); diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index 30bb66469..e9917b090 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -90,25 +90,31 @@ void SetupTabScroll::addControl(SetupItem *widget, std::string event) void SetupTabScroll::apply() { - std::map::iterator iter; + std::map::const_iterator iter; for (iter = mItems.begin(); iter != mItems.end(); ++ iter) - (*iter).second->apply((*iter).first); + { + if ((*iter).second) + (*iter).second->apply((*iter).first); + } } void SetupTabScroll::cancel() { - std::map::iterator iter; + std::map::const_iterator iter; for (iter = mItems.begin(); iter != mItems.end(); ++ iter) - (*iter).second->cancel((*iter).first); + { + if ((*iter).second) + (*iter).second->cancel((*iter).first); + } } void SetupTabScroll::externalUpdated() { - std::map::iterator iter; + std::map::const_iterator iter; for (iter = mItems.begin(); iter != mItems.end(); ++ iter) { SetupItem *widget = (*iter).second; - if (!widget->isMainConfig()) + if (widget && !widget->isMainConfig()) (*iter).second->externalUpdated((*iter).first); } } diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index ea6b4d520..5e79b7c19 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -73,8 +73,9 @@ void VertContainer::clear() void VertContainer::widgetResized(const gcn::Event &event A_UNUSED) { - for (std::vector::iterator it = mResizableWidgets.begin(); - it != mResizableWidgets.end(); ++ it) + for (std::vector::const_iterator + it = mResizableWidgets.begin(); + it != mResizableWidgets.end(); ++ it) { (*it)->setWidth(getWidth()); } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 4435496a7..9709f4c8a 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -373,7 +373,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED) if (!mFocusHandler) return; - for (it = mWidgets.begin(); it != mWidgets.end(); it++) + for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) { if (mFocusHandler->isFocused(*it)) mFocusHandler->focusNone(); diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 0d81ba3a9..8431cece1 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -329,7 +329,7 @@ void WindowMenu::showButton(std::string name, bool isVisible) void WindowMenu::updateButtons() { int x = 0, h = 0; - std::vector ::iterator it, it_end; + std::vector ::const_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) diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp index bb0378f59..367eed6b1 100644 --- a/src/guichan/focushandler.cpp +++ b/src/guichan/focushandler.cpp @@ -479,7 +479,8 @@ namespace gcn = sourceWidget->_getFocusListeners(); // Send the event to all focus listeners of the widget. - for (std::list::iterator it = focusListeners.begin(); + for (std::list::const_iterator + it = focusListeners.begin(); it != focusListeners.end(); ++ it) { @@ -495,7 +496,8 @@ namespace gcn = sourceWidget->_getFocusListeners(); // Send the event to all focus listeners of the widget. - for (std::list::iterator it = focusListeners.begin(); + for (std::list::const_iterator + it = focusListeners.begin(); it != focusListeners.end(); ++ it) { diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp index bec4c875f..0c81182ea 100644 --- a/src/guichan/gui.cpp +++ b/src/guichan/gui.cpp @@ -421,7 +421,7 @@ namespace gcn // Check if the widget is present in the "widget with mouse" queue. bool widgetIsPresentInQueue = false; - std::deque::iterator iter; + std::deque::const_iterator iter; for (iter = mWidgetWithMouseQueue.begin(); iter != mWidgetWithMouseQueue.end(); ++ iter) @@ -697,7 +697,7 @@ namespace gcn = widget->_getMouseListeners(); // Send the event to all mouse listeners of the widget. - for (std::list::iterator + for (std::list::const_iterator it = mouseListeners.begin(); it != mouseListeners.end(); ++it) @@ -796,7 +796,7 @@ namespace gcn = widget->_getKeyListeners(); // Send the event to all key listeners of the source widget. - for (std::list::iterator + for (std::list::const_iterator it = keyListeners.begin(); it != keyListeners.end(); ++it) @@ -936,7 +936,7 @@ namespace gcn // Check if the widget is present in the "widget with mouse" queue. bool widgetIsPresentInQueue = false; - std::deque::iterator iter; + std::deque::const_iterator iter; for (iter = mWidgetWithMouseQueue.begin(); iter != mWidgetWithMouseQueue.end(); ++ iter) diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp index e2ed26508..1b2b3295b 100644 --- a/src/guichan/widget.cpp +++ b/src/guichan/widget.cpp @@ -470,7 +470,7 @@ namespace gcn { mGlobalFont = font; - std::list::iterator iter; + std::list::const_iterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) { if ((*iter)->mCurrentFont == NULL) diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp index 7b04981c2..d0ba32f47 100644 --- a/src/guichan/widgets/window.cpp +++ b/src/guichan/widgets/window.cpp @@ -282,7 +282,7 @@ namespace gcn WidgetListConstIterator it; int w = 0, h = 0; - for (it = mWidgets.begin(); it != mWidgets.end(); it++) + for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) { if ((*it)->getX() + (*it)->getWidth() > w) w = (*it)->getX() + (*it)->getWidth(); diff --git a/src/guild.cpp b/src/guild.cpp index 98e5bb519..234c7d32f 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -230,8 +230,8 @@ void Guild::removeFromMembers() if (!actorSpriteManager) return; - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { Being *b = actorSpriteManager->findBeing((*itr)->getID()); @@ -321,7 +321,7 @@ void Guild::addPos(int id, std::string name) Guild *Guild::getGuild(short id) { - GuildMap::iterator it = guilds.find(id); + GuildMap::const_iterator it = guilds.find(id); if (it != guilds.end()) return it->second; diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 1a8d5b433..13a837dfb 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -135,8 +135,8 @@ void GuildManager::updateList() if (guild) { guild->setServerGuild(false); - std::vector::iterator it = mTempList.begin(); - std::vector::iterator it_end = mTempList.end(); + std::vector::const_iterator it = mTempList.begin(); + std::vector::const_iterator it_end = mTempList.end(); int i = 0; while (it != it_end) { diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c91532227..a68cd5ee8 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -902,11 +902,11 @@ 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::iterator itr = mGuilds.begin(); - std::map::iterator itr_end = mGuilds.end(); + std::map::const_iterator itr = mGuilds.begin(); + std::map::const_iterator itr_end = mGuilds.end(); for (; itr != itr_end; ++itr) { - if (checkInviteRights(itr->second->getName())) + if (itr->second && checkInviteRights(itr->second->getName())) { Net::getGuildHandler()->invite(itr->second->getId(), being); return; @@ -1813,7 +1813,7 @@ void LocalPlayer::moveToHome() } else { - std::map::iterator iter = + std::map::const_iterator iter = mHomes.find(mMap->getProperty("_realfilename")); if (iter != mHomes.end()) @@ -2996,7 +2996,7 @@ void LocalPlayer::setHome() if (mAction == SIT) { - std::map::iterator iter = mHomes.find(key); + std::map::const_iterator iter = mHomes.find(key); if (iter != mHomes.end()) { @@ -3102,7 +3102,7 @@ void LocalPlayer::saveHomes() std::string homeStr; std::stringstream ss(homeStr); - for (std::map::iterator iter = mHomes.begin(); + for (std::map::const_iterator iter = mHomes.begin(); iter != mHomes.end(); ++iter ) { Vector pos = (*iter).second; @@ -3802,7 +3802,7 @@ void LocalPlayer::updateNavigateList() { if (mMap) { - std::map::iterator iter = + std::map::const_iterator iter = mHomes.find(mMap->getProperty("_realfilename")); if (iter != mHomes.end()) diff --git a/src/map.cpp b/src/map.cpp index 947bb8f09..e5b3632b6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -104,10 +104,11 @@ void TileAnimation::update(int ticks) Image *img = mAnimation->getCurrentImage(); if (img != mLastImage) { - for (std::vector >::iterator i = + for (std::vector >::const_iterator i = mAffected.begin(); i != mAffected.end(); ++i) { - i->first->setTile(i->second, img); + if (i->first) + i->first->setTile(i->second, img); } mLastImage = img; } @@ -284,13 +285,13 @@ void MapLayer::updateSDL(Graphics *graphics, int startX, int startY, void MapLayer::drawSDL(Graphics *graphics) { - MapRows::iterator rit = mTempRows.begin(); - MapRows::iterator rit_end = mTempRows.end(); + MapRows::const_iterator rit = mTempRows.begin(); + MapRows::const_iterator rit_end = mTempRows.end(); while (rit != rit_end) { MepRowImages *images = &(*rit)->images; - MepRowImages::iterator iit = images->begin(); - MepRowImages::iterator iit_end = images->end(); + MepRowImages::const_iterator iit = images->begin(); + MepRowImages::const_iterator iit_end = images->end(); while (iit != iit_end) { graphics->drawTile(*iit); @@ -375,13 +376,13 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY, void MapLayer::drawOGL(Graphics *graphics) { - MapRows::iterator rit = mTempRows.begin(); - MapRows::iterator rit_end = mTempRows.end(); + MapRows::const_iterator rit = mTempRows.begin(); + MapRows::const_iterator rit_end = mTempRows.end(); while (rit != rit_end) { MepRowImages *images = &(*rit)->images; - MepRowImages::iterator iit = images->begin(); - MepRowImages::iterator iit_end = images->end(); + MepRowImages::const_iterator iit = images->begin(); + MepRowImages::const_iterator iit_end = images->end(); while (iit != iit_end) { graphics->drawTile(*iit); @@ -789,11 +790,12 @@ bool actorCompare(const Actor *a, const Actor *b) void Map::update(int ticks) { // Update animated tiles - for (std::map::iterator + for (std::map::const_iterator iAni = mTileAnimations.begin(); iAni != mTileAnimations.end(); ++iAni) { - iAni->second->update(ticks); + if (iAni->second) + iAni->second->update(ticks); } } @@ -1079,7 +1081,7 @@ void Map::updateAmbientLayers(float scrollX, float scrollY) float dy = scrollY - mLastAScrollY; int timePassed = get_elapsed_time(lastTick); - std::vector::iterator i; + std::vector::const_iterator i; for (i = mBackgrounds.begin(); i != mBackgrounds.end(); ++i) (*i)->update(timePassed, dx, dy); @@ -1116,10 +1118,11 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type, } // Draw overlays - for (std::vector::iterator i = layers->begin(); + for (std::vector::const_iterator i = layers->begin(); i != layers->end(); ++i) { - (*i)->draw(graphics, graphics->mWidth, graphics->mHeight); + if (*i) + (*i)->draw(graphics, graphics->mWidth, graphics->mHeight); // Detail 1: only one overlay, higher: all overlays if (detail == 1) @@ -1598,7 +1601,7 @@ void Map::initializeParticleEffects(Particle *particleEngine) if (config.getBoolValue("particleeffects")) { - for (std::vector::iterator + for (std::vector::const_iterator i = particleEffects.begin(); i != particleEffects.end(); ++i) { @@ -1785,8 +1788,8 @@ void Map::updatePortalTile(const std::string &name, int type, MapItem *Map::findPortalXY(int x, int y) { - std::vector::iterator it; - std::vector::iterator it_end; + std::vector::const_iterator it; + std::vector::const_iterator it_end; for (it = mMapPortals.begin(), it_end = mMapPortals.end(); it != it_end; ++it) @@ -1849,7 +1852,7 @@ std::string Map::getObjectData(unsigned x, unsigned y, int type) if (!list) return ""; - std::vector::iterator it = list->objects.begin(); + std::vector::const_iterator it = list->objects.begin(); while (it != list->objects.end()) { if ((*it).type == type) diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 01000f8f1..1de681007 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -434,8 +434,8 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg) if (!mStorage) mStorage = new Inventory(Inventory::STORAGE, size); - Ea::InventoryItems::iterator it = mInventoryItems.begin(); - Ea::InventoryItems::iterator it_end = mInventoryItems.end(); + Ea::InventoryItems::const_iterator it = mInventoryItems.begin(); + Ea::InventoryItems::const_iterator it_end = mInventoryItems.end(); for (; it != it_end; ++it) { mStorage->setItem((*it).slot, (*it).id, (*it).quantity, diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index 53e83e4ec..b83bc5748 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -45,7 +45,7 @@ namespace ManaServ { typedef std::map MessageHandlers; -typedef MessageHandlers::iterator MessageHandlerIterator; +typedef MessageHandlers::const_iterator MessageHandlerIterator; static MessageHandlers mMessageHandlers; void initialize() @@ -96,17 +96,13 @@ Connection *getConnection() void registerHandler(MessageHandler *handler) { for (const Uint16 *i = handler->handledMessages; *i; i++) - { mMessageHandlers[*i] = handler; - } } void unregisterHandler(MessageHandler *handler) { for (const Uint16 *i = handler->handledMessages; *i; i++) - { mMessageHandlers.erase(*i); - } } void clearNetworkHandlers() diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp index efd2ab2bc..8c14f3dfc 100644 --- a/src/net/manaserv/npchandler.cpp +++ b/src/net/manaserv/npchandler.cpp @@ -60,12 +60,10 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) { Being *being = actorSpriteManager->findBeing(msg.readInt16()); if (!being || being->getType() != ActorSprite::NPC) - { return; - } int npcId = being->getId(); - NpcDialogs::iterator diag = mNpcDialogs.find(npcId); + NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId); NpcDialog *dialog; if (diag == mNpcDialogs.end()) diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 43271671e..f80dd6e69 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -194,7 +194,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength) const int npcId = msg.readInt32(); - NpcDialogs::iterator diag = mNpcDialogs.find(npcId); + NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId); mDialog = 0; if (diag == mNpcDialogs.end()) diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index f918a5c0d..046c5fd30 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -631,15 +631,15 @@ void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image) setTexturingAndBlending(true); std::vector *intVertPool = ogl->getIntVertPool(); - std::vector::iterator iv; + std::vector::const_iterator iv; std::vector *vp = ogl->getVp(); - std::vector::iterator ivp; + std::vector::const_iterator ivp; // Draw a set of textured rectangles if (image->mTextureType == GL_TEXTURE_2D) { std::vector *floatTexPool = ogl->getFloatTexPool(); - std::vector::iterator ft; + std::vector::const_iterator ft; for (iv = intVertPool->begin(), ft = floatTexPool->begin(), ivp = vp->begin(); @@ -653,7 +653,7 @@ void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image) else { std::vector *intTexPool = ogl->getIntTexPool(); - std::vector::iterator it; + std::vector::const_iterator it; for (iv = intVertPool->begin(), it = intTexPool->begin(), ivp = vp->begin(); diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index 70b1e2c84..686390474 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -93,7 +93,7 @@ void ParticleList::removeLocally(Particle *particle) void ParticleList::clearLocally() { - for (std::list::iterator it = mElements.begin(); + for (std::list::const_iterator it = mElements.begin(); it != mElements.end(); ++it) { (*it)->kill(); diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index caa48a795..fd1f07e16 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::vector::iterator + for (std::vector::const_iterator i = mTempSets.begin(); i != mTempSets.end(); ++i) { @@ -453,7 +453,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o) ParticleEmitter::~ParticleEmitter() { - for (std::vector::iterator + for (std::vector::const_iterator i = mTempSets.begin(); i != mTempSets.end(); ++i) { @@ -576,7 +576,7 @@ std::list ParticleEmitter::createParticles(int tick) newParticle->setFadeIn(mParticleFadeIn.value(tick)); newParticle->setAlpha(mParticleAlpha.value(tick)); - for (std::list::iterator + for (std::list::const_iterator i = mParticleChildEmitters.begin(); i != mParticleChildEmitters.end(); ++i) { diff --git a/src/party.cpp b/src/party.cpp index f3f787807..9becee1cd 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -181,8 +181,9 @@ void Party::removeFromMembers() if (!actorSpriteManager) return; - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + MemberList::const_iterator itr_end = mMembers.end(); + while (itr != itr_end) { Being *b = actorSpriteManager->findBeing((*itr)->getID()); @@ -281,7 +282,7 @@ void Party::getNamesSet(std::set &names) const Party *Party::getParty(short id) { - PartyMap::iterator it = parties.find(id); + PartyMap::const_iterator it = parties.find(id); if (it != parties.end()) return it->second; Party *party = new Party(id); diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 769d24a16..562795563 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -68,7 +68,10 @@ void triggerAttr(int id, int old) void triggerStat(int id, const std::string &changed, int old1, int old2) { - StatMap::iterator it = mData.mStats.find(id); + StatMap::const_iterator it = mData.mStats.find(id); + if (it == mData.mStats.end()) + return; + Mana::Event event(Mana::EVENT_UPDATESTAT); event.setInt("id", id); event.setInt("base", it->second.base); diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 802f2ee12..e28cb2bc5 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -336,7 +336,7 @@ bool Image::hasAlphaChannel() SDL_Surface *Image::getByAlpha(float alpha) { - std::map::iterator it = mAlphaCache.find(alpha); + std::map::const_iterator it = mAlphaCache.find(alpha); if (it != mAlphaCache.end()) return (*it).second; return 0; @@ -361,7 +361,7 @@ void Image::setAlpha(float alpha) { #ifdef DEBUG_ALPHA_CACHE logger->log("cleanCache"); - for (std::map::iterator + for (std::map::const_iterator i = mAlphaCache.begin(), i_end = mAlphaCache.end(); i != i_end; ++i) { diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 733c12958..89df407a6 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -308,7 +308,7 @@ void ItemDB::load() effect += " / "; effect += strprintf(gettext(fields[i][1]), value); } - for (std::vector::iterator it = extraStats.begin(); + for (std::vector::const_iterator it = extraStats.begin(); it != extraStats.end(); ++it) { int value = XML::getProperty(node, it->tag.c_str(), 0); diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index fb4b8ed5e..75e6e1d8c 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -185,7 +185,8 @@ std::string ItemInfo::getDyeColorsString(int color) const if (!mColors || mColorList.empty()) return ""; - std::map ::iterator it = mColors->find(color); + std::map ::const_iterator + it = mColors->find(color); if (it == mColors->end()) return ""; @@ -208,7 +209,8 @@ const std::string ItemInfo::replaceColors(std::string str, std::string name; if (mColors && !mColorList.empty()) { - std::map ::iterator it = mColors->find(color); + std::map ::const_iterator + it = mColors->find(color); if (it == mColors->end()) name = "unknown"; else diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 685d415ff..f702864ea 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -734,7 +734,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, Animation *ani = new Animation; for (int i = 0; ; i++) { - std::map::iterator iFrame, iDelay; + std::map::const_iterator iFrame, iDelay; iFrame = tileProperties.find( "animation-frame" + toString(i)); iDelay = tileProperties.find( diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 573ffb2a3..2463da06a 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -123,7 +123,7 @@ void SpecialDB::unload() SpecialInfo *SpecialDB::get(int id) { - SpecialInfos::iterator i = mSpecialInfos.find(id); + SpecialInfos::const_iterator i = mSpecialInfos.find(id); if (i == mSpecialInfos.end()) return NULL; diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index dee93e1e7..2e32f6c5f 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -86,7 +86,7 @@ void SpriteDef::substituteAction(std::string complete, std::string with) { if (mActions.find(complete) == mActions.end()) { - Actions::iterator i = mActions.find(with); + Actions::const_iterator i = mActions.find(with); if (i != mActions.end()) mActions[complete] = i->second; } diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 09c9f2a04..5cfec3b84 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -137,7 +137,7 @@ void Wallpaper::loadWallpapers() std::string Wallpaper::getWallpaper(int width, int height) { - std::vector::iterator iter; + std::vector::const_iterator iter; WallpaperData wp; // Wallpaper filename container diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index a79388350..fcdf94039 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -104,7 +104,7 @@ bool SpellManager::addSpell(TextCommand *spell) if (!spell) return false; - std::map::iterator + std::map::const_iterator i = mSpells.find(spell->getId()); if (i == mSpells.end()) { @@ -342,7 +342,7 @@ void SpellManager::save() std::string SpellManager::autoComplete(std::string partName) { - std::vector::iterator i = mSpellsVector.begin(); + std::vector::const_iterator i = mSpellsVector.begin(); std::string newName = ""; TextCommand *newCommand = NULL; diff --git a/src/textmanager.cpp b/src/textmanager.cpp index c9da12e92..7c1be58cf 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -48,7 +48,7 @@ void TextManager::moveText(Text *text, int x, int y) void TextManager::removeText(const Text *text) { for (TextList::iterator ptr = mTextList.begin(), - pEnd = mTextList.end(); ptr != pEnd; ++ptr) + pEnd = mTextList.end(); ptr != pEnd; ++ptr) { if (*ptr == text) { @@ -64,8 +64,9 @@ TextManager::~TextManager() void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff) { - for (TextList::iterator bPtr = mTextList.begin(), ePtr = mTextList.end(); - bPtr != ePtr; ++bPtr) + for (TextList::const_iterator bPtr = mTextList.begin(), + ePtr = mTextList.end(); + bPtr != ePtr; ++ bPtr) { (*bPtr)->draw(graphics, xOff, yOff); } diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 176c5499c..f3aed5276 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -185,10 +185,11 @@ unsigned long findI(std::string text, std::vector &list) { std::string str = toLower(text); unsigned long idx; - for (std::vector::iterator i = list.begin(); + for (std::vector::const_iterator i = list.begin(); i != list.end(); ++i) { - std::string subStr = toLower(*i); + std::string subStr = *i; + subStr = toLower(subStr); idx = str.find(subStr); if (idx != std::string::npos) return idx; @@ -450,8 +451,8 @@ std::string combineDye2(std::string file, std::string dye) file = file.substr(0, pos); std::list list1 = splitToStringList(dye1, ';'); std::list list2 = splitToStringList(dye, ';'); - std::list::iterator it1, it1_end = list1.end(); - std::list::iterator it2, it2_end = list2.end(); + std::list::const_iterator it1, it1_end = list1.end(); + std::list::const_iterator it2, it2_end = list2.end(); for (it1 = list1.begin(), it2 = list2.begin(); it1 != it1_end && it2 != it2_end; ++it1, ++it2) { @@ -485,7 +486,7 @@ std::vector getLang() std::string packList(std::list &list) { - std::list::iterator i = list.begin(); + std::list::const_iterator i = list.begin(); std::string str = ""; while (i != list.end()) { -- cgit v1.2.3-70-g09d2 From 10d3b05b00e913ee2e396facdb8d2ed2177efb53 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 8 Sep 2011 01:19:49 +0300 Subject: Fix code style. --- src/actorspritemanager.cpp | 6 ++++-- src/being.cpp | 9 ++++++--- src/graphics.cpp | 8 ++++---- src/graphics.h | 4 ++-- src/guildmanager.cpp | 2 +- src/resources/image.h | 2 +- src/utils/stringutils.cpp | 2 +- 7 files changed, 19 insertions(+), 14 deletions(-) (limited to 'src/resources') diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index edd1db2aa..1104f034a 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -705,7 +705,8 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, beingSorter.priorityBeings = &priorityMobsMap; if (ignoreAttackMobs.find("") != ignoreAttackMobs.end()) ignoreDefault = true; - std::map::const_iterator itr = attackMobsMap.find(""); + std::map::const_iterator + itr = attackMobsMap.find(""); if (itr != attackMobsMap.end()) defaultAttackIndex = (*itr).second; itr = priorityMobsMap.find(""); @@ -1323,7 +1324,8 @@ void ActorSpriteManager::rebuildAttackMobs() int ActorSpriteManager::getPriorityAttackMobIndex(std::string name) { - std::map::const_iterator i = mPriorityAttackMobsMap.find(name); + std::map::const_iterator + i = mPriorityAttackMobsMap.find(name); if (i == mPriorityAttackMobsMap.end()) return -1; diff --git a/src/being.cpp b/src/being.cpp index 090e7d10d..3d89c71ba 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2188,7 +2188,8 @@ void Being::recalcSpritesOrder() if (info.mDrawBefore[dir] > 0) { int id2 = mSpriteIDs[info.mDrawBefore[dir]]; - std::map::const_iterator orderIt = itemSlotRemap.find(id2); + std::map::const_iterator + orderIt = itemSlotRemap.find(id2); if (orderIt != itemSlotRemap.end()) { // logger->log("found duplicate (before)"); @@ -2211,7 +2212,8 @@ void Being::recalcSpritesOrder() else if (info.mDrawAfter[dir] > 0) { int id2 = mSpriteIDs[info.mDrawAfter[dir]]; - std::map::const_iterator orderIt = itemSlotRemap.find(id2); + std::map::const_iterator + orderIt = itemSlotRemap.find(id2); if (orderIt != itemSlotRemap.end()) { // logger->log("found duplicate (after)"); @@ -2256,7 +2258,8 @@ void Being::recalcSpritesOrder() int idx1 = -1; // logger->log("item %d, id=%d", slot, id); int reorder = 0; - std::map::const_iterator orderIt = itemSlotRemap.find(id); + std::map::const_iterator + orderIt = itemSlotRemap.find(id); if (orderIt != itemSlotRemap.end()) reorder = orderIt->second; diff --git a/src/graphics.cpp b/src/graphics.cpp index 0da8c1bd4..e79cbf56b 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -559,7 +559,7 @@ void Graphics::calcImagePattern(GraphicsVertexes* vert, srcRect.w = static_cast(dw); srcRect.h = static_cast(dh); - if (SDL_FakeUpperBlit(image->mSDLSurface, &srcRect, + if (sdl_FakeUpperBlit(image->mSDLSurface, &srcRect, mTarget, &dstRect) == 1) { vert->pushSDL(srcRect, dstRect); @@ -588,7 +588,7 @@ void Graphics::calcTile(ImageVertexes *vert, int x, int y) rect->src.y = static_cast(image->mBounds.y); rect->src.w = static_cast(image->mBounds.w); rect->src.h = static_cast(image->mBounds.h); - if (SDL_FakeUpperBlit(image->mSDLSurface, &rect->src, + if (sdl_FakeUpperBlit(image->mSDLSurface, &rect->src, mTarget, &rect->dst) == 1) { vert->sdl.push_back(rect); @@ -668,8 +668,8 @@ bool Graphics::calcWindow(GraphicsVertexes* vert, imgRect.grid[4]); } -int Graphics::SDL_FakeUpperBlit (SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect) +int Graphics::SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) { SDL_Rect fulldst; int srcx, srcy, w, h; diff --git a/src/graphics.h b/src/graphics.h index a2e25b5a8..53b4b7c72 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -279,8 +279,8 @@ class Graphics : public gcn::SDLGraphics int mHeight; protected: - int SDL_FakeUpperBlit (SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); + int SDL_FakeUpperBlit(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); int mBpp; bool mFullscreen; diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 13a837dfb..7bc0444ed 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -338,7 +338,7 @@ bool GuildManager::process(std::string msg) return true; } else if (!haveNick && (findCutLast(msg, " has been removed " - "from the Guild.") || findCutLast(msg," has left the Guild."))) + "from the Guild.") || findCutLast(msg, " has left the Guild."))) { Guild *guild = createGuild(); if (!guild) diff --git a/src/resources/image.h b/src/resources/image.h index 9ac2b163e..eb211341c 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -162,7 +162,7 @@ class Image : public Resource * * @return A new Image* object. */ - Image* SDLgetScaledImage(int width, int height); + Image* SDLGetScaledImage(int width, int height); /** * Merges two image SDL_Surfaces together. This is for SDL use only, as diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 62564e0e0..efe5f9efb 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -175,7 +175,7 @@ const std::string findSameSubstring(const std::string &str1, } const std::string findSameSubstringI(const std::string &s1, - const std::string &s2) + const std::string &s2) { std::string str1 = s1; std::string str2 = s2; -- cgit v1.2.3-70-g09d2 From eebadc5b3970ae11a1e51a5d1ceb8ec1b9fd0770 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 8 Sep 2011 01:29:48 +0300 Subject: Fix compilation errors. --- src/graphics.cpp | 4 ++-- src/resources/image.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/resources') diff --git a/src/graphics.cpp b/src/graphics.cpp index e79cbf56b..61f98b2a7 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -559,7 +559,7 @@ void Graphics::calcImagePattern(GraphicsVertexes* vert, srcRect.w = static_cast(dw); srcRect.h = static_cast(dh); - if (sdl_FakeUpperBlit(image->mSDLSurface, &srcRect, + if (SDL_FakeUpperBlit(image->mSDLSurface, &srcRect, mTarget, &dstRect) == 1) { vert->pushSDL(srcRect, dstRect); @@ -588,7 +588,7 @@ void Graphics::calcTile(ImageVertexes *vert, int x, int y) rect->src.y = static_cast(image->mBounds.y); rect->src.w = static_cast(image->mBounds.w); rect->src.h = static_cast(image->mBounds.h); - if (sdl_FakeUpperBlit(image->mSDLSurface, &rect->src, + if (SDL_FakeUpperBlit(image->mSDLSurface, &rect->src, mTarget, &rect->dst) == 1) { vert->sdl.push_back(rect); diff --git a/src/resources/image.h b/src/resources/image.h index eb211341c..9ac2b163e 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -162,7 +162,7 @@ class Image : public Resource * * @return A new Image* object. */ - Image* SDLGetScaledImage(int width, int height); + Image* SDLgetScaledImage(int width, int height); /** * Merges two image SDL_Surfaces together. This is for SDL use only, as -- cgit v1.2.3-70-g09d2 From 4484b433abc8f07bcf7d4d22fd946e00b66b078d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 19:43:40 +0300 Subject: Fix first part of shadow variables/methods errors. --- src/client.cpp | 30 +++++----- src/game.cpp | 12 ++-- src/graphics.h | 2 +- src/gui/changeemaildialog.cpp | 18 +++--- src/gui/changeemaildialog.h | 2 +- src/gui/changepassworddialog.cpp | 20 +++---- src/gui/changepassworddialog.h | 2 +- src/gui/charselectdialog.cpp | 10 ++-- src/gui/charselectdialog.h | 2 +- src/gui/chatwindow.cpp | 4 +- src/gui/palette.h | 13 +++-- src/gui/popupmenu.cpp | 8 +-- src/gui/setup_video.cpp | 30 +++++----- src/gui/spellpopup.cpp | 8 +-- src/gui/statuspopup.cpp | 6 +- src/gui/textpopup.cpp | 6 +- src/gui/widgets/avatarlistbox.cpp | 3 +- src/gui/widgets/browserbox.cpp | 14 ++--- src/gui/widgets/popup.cpp | 10 ++-- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/window.cpp | 84 +++++++++++++-------------- src/gui/windowmenu.cpp | 8 +-- src/guichan/cliprectangle.cpp | 16 ++--- src/guichan/include/guichan/cliprectangle.hpp | 32 +++++----- src/guichan/include/guichan/inputevent.hpp | 8 +-- src/guichan/include/guichan/keyevent.hpp | 20 +++---- src/guichan/include/guichan/mouseevent.hpp | 16 ++--- src/guichan/inputevent.cpp | 16 ++--- src/guichan/keyevent.cpp | 20 +++---- src/guichan/mouseevent.cpp | 16 ++--- src/map.h | 6 +- src/position.h | 4 +- src/resources/ambientlayer.cpp | 8 +-- src/resources/colordb.h | 8 +-- src/resources/itemdb.h | 8 +-- src/resources/spritedef.h | 6 +- src/vector.h | 8 +-- 37 files changed, 242 insertions(+), 246 deletions(-) (limited to 'src/resources') diff --git a/src/client.cpp b/src/client.cpp index 472c862e6..b9e9735c9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -140,11 +140,11 @@ Configuration config; /**< XML file configuration reader */ Configuration serverConfig; /**< XML file server configuration reader */ Configuration branding; /**< XML branding information reader */ Configuration paths; /**< XML default paths information reader */ -Logger *logger; /**< Log object */ -ChatLogger *chatLogger; /**< Chat log object */ +Logger *logger = 0; /**< Log object */ +ChatLogger *chatLogger = 0; /**< Chat log object */ KeyboardConfig keyboard; -UserPalette *userPalette; -Graphics *graphics; +UserPalette *userPalette = 0; +Graphics *mainGraphics = 0; Sound sound; @@ -440,20 +440,20 @@ Client::Client(const Options &options): switch(useOpenGL) { case 0: - graphics = new Graphics; + mainGraphics = new Graphics; break; case 1: default: - graphics = new OpenGLGraphics; + mainGraphics = new OpenGLGraphics; break; case 2: - graphics = new OpenGL1Graphics; + mainGraphics = new OpenGL1Graphics; break; }; #else // Create the graphics context - graphics = new Graphics; + mainGraphics = new Graphics; #endif runCounters = config.getBoolValue("packetcounters"); @@ -465,7 +465,7 @@ Client::Client(const Options &options): const bool hwaccel = config.getBoolValue("hwaccel"); // Try to set the desired video mode - if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) + if (!mainGraphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) { logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s", width, height, bpp, SDL_GetError())); @@ -482,7 +482,7 @@ Client::Client(const Options &options): config.setValueInt("screenwidth", oldWidth); config.setValueInt("screenheight", oldHeight); config.setValue("screen", oldFullscreen); - if (!graphics->setVideoMode(oldWidth, oldHeight, bpp, + if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp, oldFullscreen, hwaccel)) { logger->error(strprintf("Couldn't restore %dx%dx%d " @@ -493,7 +493,7 @@ Client::Client(const Options &options): } // Initialize for drawing - graphics->_beginDraw(); + mainGraphics->_beginDraw(); Theme::selectSkin(); // Theme::prepareThemePath(); @@ -507,7 +507,7 @@ Client::Client(const Options &options): // Initialize the drop shortcuts. dropShortcut = new DropShortcut; - gui = new Gui(graphics); + gui = new Gui(mainGraphics); // Initialize sound engine try @@ -645,8 +645,8 @@ Client::~Client() logger->log1("Quitting3"); - delete graphics; - graphics = 0; + delete mainGraphics; + mainGraphics = 0; logger->log1("Quitting4"); @@ -760,7 +760,7 @@ int Client::exec() frame_count++; if (gui) gui->draw(); - graphics->updateScreen(); + mainGraphics->updateScreen(); // logger->log("active"); } else diff --git a/src/game.cpp b/src/game.cpp index aaa9694bf..a0635f42f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -371,8 +371,8 @@ Game::Game(): // Create the viewport viewport = new Viewport; - viewport->setDimension(gcn::Rectangle(0, 0, graphics->mWidth, - graphics->mHeight)); + viewport->setDimension(gcn::Rectangle(0, 0, mainGraphics->mWidth, + mainGraphics->mHeight)); gcn::Container *top = static_cast(gui->getTop()); top->add(viewport); @@ -459,14 +459,14 @@ static bool saveScreenshot() if (!config.getBoolValue("showip")) { - graphics->setSecure(true); + mainGraphics->setSecure(true); gui->draw(); - screenshot = graphics->getScreenshot(); - graphics->setSecure(false); + screenshot = mainGraphics->getScreenshot(); + mainGraphics->setSecure(false); } else { - screenshot = graphics->getScreenshot(); + screenshot = mainGraphics->getScreenshot(); } if (!screenshot) diff --git a/src/graphics.h b/src/graphics.h index 53b4b7c72..f3e0bd05d 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -292,6 +292,6 @@ class Graphics : public gcn::SDLGraphics bool mSecure; }; -extern Graphics *graphics; +extern Graphics *mainGraphics; #endif diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index c24624bc2..69af649e2 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -44,10 +44,10 @@ #include "debug.h" -ChangeEmailDialog::ChangeEmailDialog(LoginData *loginData): +ChangeEmailDialog::ChangeEmailDialog(LoginData *data): Window(_("Change Email Address"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); @@ -120,7 +120,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) logger->log("ChangeEmailDialog::Email change, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; int error = 0; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -129,21 +129,21 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) if (newFirstEmail.length() < min) { // First email address too short - errorMessage << strprintf(_("The new email address needs to be at " - "least %d characters long."), min); + errorMsg << strprintf(_("The new email address needs to be at " + "least %d characters long."), min); error = 1; } else if (newFirstEmail.length() > max - 1 ) { // First email address too long - errorMessage << strprintf(_("The new email address needs to be " - "less than %d characters long."), max); + errorMsg << strprintf(_("The new email address needs to be " + "less than %d characters long."), max); error = 1; } else if (newFirstEmail != newSecondEmail) { // Second Pass mismatch - errorMessage << _("The email address entries mismatch."); + errorMsg << _("The email address entries mismatch."); error = 2; } @@ -154,7 +154,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) else if (error == 2) mWrongDataNoticeListener->setTarget(this->mSecondEmailField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); if (dlg) dlg->addActionListener(mWrongDataNoticeListener); } diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h index e130a9074..fccb5cb1c 100644 --- a/src/gui/changeemaildialog.h +++ b/src/gui/changeemaildialog.h @@ -46,7 +46,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangeEmailDialog(LoginData *loginData); + ChangeEmailDialog(LoginData *data); /** * Destructor. diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 30012ae52..56db37ebb 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -46,10 +46,10 @@ #include "debug.h" -ChangePasswordDialog::ChangePasswordDialog(LoginData *loginData): +ChangePasswordDialog::ChangePasswordDialog(LoginData *data): Window(_("Change Password"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *accountLabel = new Label( strprintf(_("Account: %s"), mLoginData->username.c_str())); @@ -101,7 +101,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) logger->log("ChangePasswordDialog::Password change, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; int error = 0; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -111,27 +111,27 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) if (oldPassword.empty()) { // No old password - errorMessage << _("Enter the old password first."); + errorMsg << _("Enter the old password first."); error = 1; } else if (newFirstPass.length() < min) { // First password too short - errorMessage << strprintf(_("The new password needs to be at least" - " %d characters long."), min); + errorMsg << strprintf(_("The new password needs to be at least" + " %d characters long."), min); error = 2; } else if (newFirstPass.length() > max - 1 ) { // First password too long - errorMessage << strprintf(_("The new password needs to be less " - "than %d characters long."), max); + errorMsg << strprintf(_("The new password needs to be less " + "than %d characters long."), max); error = 2; } else if (newFirstPass != newSecondPass) { // Second Pass mismatch - errorMessage << _("The new password entries mismatch."); + errorMsg << _("The new password entries mismatch."); error = 3; } @@ -144,7 +144,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) else if (error == 3) mWrongDataNoticeListener->setTarget(this->mSecondPassField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index 3b0626922..fca8b4946 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -46,7 +46,7 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangePasswordDialog(LoginData *loginData); + ChangePasswordDialog(LoginData *data); /** * Destructor diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 75468d1ab..f926a90aa 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -121,20 +121,20 @@ class CharacterDisplay : public Container Button *mDelete; }; -CharSelectDialog::CharSelectDialog(LoginData *loginData): +CharSelectDialog::CharSelectDialog(LoginData *data): Window(_("Account and Character Management")), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), mCharacterEntries(0), - mLoginData(loginData), + mLoginData(data), mCharHandler(Net::getCharHandler()), mDeleteDialog(0), mDeleteIndex(-1) { setCloseButton(false); - mAccountNameLabel = new Label(loginData->username); + mAccountNameLabel = new Label(mLoginData->username); mSwitchLoginButton = new Button(_("Switch Login"), "switch", this); mChangePasswordButton = new Button(_("Change Password"), "change_password", this); @@ -373,7 +373,7 @@ void CharSelectDialog::setLocked(bool locked) } bool CharSelectDialog::selectByName(const std::string &name, - SelectAction action) + SelectAction selAction) { if (mLocked) return false; @@ -387,7 +387,7 @@ bool CharSelectDialog::selectByName(const std::string &name, { if (mCharacterEntries[i]) mCharacterEntries[i]->requestFocus(); - if (action == Choose) + if (selAction == Choose) attemptCharacterSelect(i); return true; } diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index bcbbb7679..0dfe90733 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -60,7 +60,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener, /** * Constructor. */ - CharSelectDialog(LoginData *loginData); + CharSelectDialog(LoginData *data); ~CharSelectDialog(); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 639125739..1b9877363 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -666,8 +666,8 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX() + event.getX() - mDragOffsetX); int newY = std::max(0, getY() + event.getY() - mDragOffsetY); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } } diff --git a/src/gui/palette.h b/src/gui/palette.h index 1cebe236f..645260280 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -182,13 +182,14 @@ class Palette int delay; int committedDelay; - void set(int type, gcn::Color& color, GradientType grad, int delay) + void set(int type0, gcn::Color& color0, GradientType grad0, + int delay0) { - ColorElem::type = type; - ColorElem::color = color; - ColorElem::testColor = color; - ColorElem::grad = grad; - ColorElem::delay = delay; + ColorElem::type = type0; + ColorElem::color = color0; + ColorElem::testColor = color0; + ColorElem::grad = grad0; + ColorElem::delay = delay0; ColorElem::gradientIndex = rand(); } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index a329488ce..7e43c9954 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -2029,10 +2029,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item) void PopupMenu::showPopup(int x, int y) { setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8); - if (graphics->mWidth < (x + getWidth() + 5)) - x = graphics->mWidth - getWidth(); - if (graphics->mHeight < (y + getHeight() + 5)) - y = graphics->mHeight - getHeight(); + if (mainGraphics->mWidth < (x + getWidth() + 5)) + x = mainGraphics->mWidth - getWidth(); + if (mainGraphics->mHeight < (y + getHeight() + 5)) + y = mainGraphics->mHeight - getHeight(); setPosition(x, y); setVisible(true); requestMoveToTop(); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 0bfab1438..7bbcd9a2c 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -59,7 +59,7 @@ #include "debug.h" -extern Graphics *graphics; +extern Graphics *mainGraphics; /** * The list model for mode list. @@ -157,8 +157,8 @@ ModeListModel::ModeListModel() addCustomMode("1280x1024"); addCustomMode("1400x900"); addCustomMode("1500x990"); - addCustomMode(toString(graphics->mWidth) + "x" - + toString(graphics->mHeight)); + addCustomMode(toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight)); std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter); mVideoModes.push_back("custom"); @@ -348,8 +348,8 @@ Setup_Video::Setup_Video(): mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. - std::string videoMode = toString(graphics->mWidth) + "x" - + toString(graphics->mHeight); + std::string videoMode = toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); mModeList->setActionEventId("videomode"); @@ -473,10 +473,10 @@ void Setup_Video::apply() if (!config.getIntValue("opengl")) { #endif - if (!graphics->setFullscreen(fullscreen)) + if (!mainGraphics->setFullscreen(fullscreen)) { fullscreen = !fullscreen; - if (!graphics->setFullscreen(fullscreen)) + if (!mainGraphics->setFullscreen(fullscreen)) { std::stringstream errorMessage; if (fullscreen) @@ -564,11 +564,11 @@ void Setup_Video::cancel() config.setValue("screen", mFullScreenEnabled); // Set back to the current video mode. - std::string videoMode = toString(graphics->mWidth) + "x" - + toString(graphics->mHeight); + std::string videoMode = toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); - config.setValue("screenwidth", graphics->mWidth); - config.setValue("screenheight", graphics->mHeight); + config.setValue("screenwidth", mainGraphics->mWidth); + config.setValue("screenheight", mainGraphics->mHeight); config.setValue("customcursor", mCustomCursorEnabled); config.setValue("particleeffects", mParticleEffectsEnabled); @@ -612,9 +612,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) return; // TODO: Find out why the drawing area doesn't resize without a restart. - if (width != graphics->mWidth || height != graphics->mHeight) + if (width != mainGraphics->mWidth || height != mainGraphics->mHeight) { - if (width < graphics->mWidth || height < graphics->mHeight) + if (width < mainGraphics->mWidth || height < mainGraphics->mHeight) new OkDialog(_("Screen Resolution Changed"), _("Restart your client for the change to take effect.") + std::string("\n") + @@ -625,8 +625,8 @@ void Setup_Video::action(const gcn::ActionEvent &event) } config.setValue("oldscreen", config.getBoolValue("screen")); - config.setValue("oldscreenwidth", graphics->mWidth); - config.setValue("oldscreenheight", graphics->mHeight); + config.setValue("oldscreenwidth", mainGraphics->mWidth); + config.setValue("oldscreenheight", mainGraphics->mHeight); config.setValue("screenwidth", width); config.setValue("screenheight", height); } diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index a918e037d..f87e691de 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -80,14 +80,14 @@ void SpellPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) + if (posX + getWidth() > mainGraphics->mWidth) { - if (graphics->mWidth > getWidth()) - posX = graphics->mWidth - getWidth(); + if (mainGraphics->mWidth > getWidth()) + posX = mainGraphics->mWidth - getWidth(); else posX = 0; } - if (posY + getHeight() > graphics->mHeight) + if (posY + getHeight() > mainGraphics->mHeight) { if (y > getHeight() + distance) posY = y - getHeight() - distance; diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index bb7a295ab..9214f1406 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -169,9 +169,9 @@ void StatusPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; update(); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 1ff601154..65c712461 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -96,9 +96,9 @@ void TextPopup::show(int x, int y, const std::string &str1, int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index d4764cba5..29fca7662 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -373,7 +373,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) default: { Map *map = viewport->getMap(); - Avatar *ava = model->getAvatarAt(selected); + ava = model->getAvatarAt(selected); if (map && ava) { MapItem *mapItem = map->findPortalXY( @@ -384,7 +384,6 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) } } } - else if (event.getButton() == gcn::MouseEvent::MIDDLE) { if (ava->getType() == AVATAR_PLAYER && chatWindow) diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 65a25363d..c20eb4622 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -210,23 +210,23 @@ void BrowserBox::addRow(const std::string &row, bool atTop) for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i) { - std::string row = *i; - for (unsigned int j = 0; j < row.size(); j++) + std::string tempRow = *i; + for (unsigned int j = 0; j < tempRow.size(); j++) { - std::string character = row.substr(j, 1); + std::string character = tempRow.substr(j, 1); x += font->getWidth(character); nextChar = j + 1; // Wraping between words (at blank spaces) - if ((nextChar < row.size()) && (row.at(nextChar) == ' ')) + if (nextChar < tempRow.size() && tempRow.at(nextChar) == ' ') { int nextSpacePos = static_cast( - row.find(" ", (nextChar + 1))); + tempRow.find(" ", (nextChar + 1))); if (nextSpacePos <= 0) - nextSpacePos = static_cast(row.size()) - 1; + nextSpacePos = static_cast(tempRow.size()) - 1; unsigned nextWordWidth = font->getWidth( - row.substr(nextChar, + tempRow.substr(nextChar, (nextSpacePos - nextChar))); if ((x + nextWordWidth + 10) > (unsigned)getWidth()) diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 38088770b..ebfdbe303 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -44,8 +44,8 @@ Popup::Popup(const std::string &name, const std::string &skin): mPopupName(name), mMinWidth(100), mMinHeight(40), - mMaxWidth(graphics->mWidth), - mMaxHeight(graphics->mHeight), + mMaxWidth(mainGraphics->mWidth), + mMaxHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -190,9 +190,9 @@ void Popup::position(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 52a26ddac..36ed96bd2 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -94,8 +94,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener /** * Sets the text shown on the progress bar. */ - void setText(const std::string &text) - { mText = text; } + void setText(const std::string &str) + { mText = str; } /** * Returns the text shown on the progress bar. diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9709f4c8a..05509ab39 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -63,8 +63,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, mStickyButtonLock(false), mMinWinWidth(100), mMinWinHeight(40), - mMaxWinWidth(graphics->mWidth), - mMaxWinHeight(graphics->mHeight), + mMaxWinWidth(mainGraphics->mWidth), + mMaxWinHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -244,39 +244,39 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position, } else if (position == ImageRect::UPPER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); + offsetX += mainGraphics->mWidth - getWidth(); } else if (position == ImageRect::LEFT) { - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::LOWER_LEFT) { - offsetY += graphics->mHeight - getHeight(); + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += graphics->mHeight - getHeight(); + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += graphics->mHeight - getHeight(); + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += mainGraphics->mHeight - getHeight(); } setPosition(offsetX, offsetY); @@ -579,8 +579,8 @@ void Window::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX()); int newY = std::max(0, getY()); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } @@ -621,14 +621,10 @@ void Window::mouseDragged(gcn::MouseEvent &event) newDim.height += newDim.y; newDim.y = 0; } - if (newDim.x + newDim.width > graphics->mWidth) - { - newDim.width = graphics->mWidth - newDim.x; - } - if (newDim.y + newDim.height > graphics->mHeight) - { - newDim.height = graphics->mHeight - newDim.y; - } + if (newDim.x + newDim.width > mainGraphics->mWidth) + newDim.width = mainGraphics->mWidth - newDim.x; + if (newDim.y + newDim.height > mainGraphics->mHeight) + newDim.height = mainGraphics->mHeight - newDim.y; // Update mouse offset when dragging bottom or right border if (mouseResize & BOTTOM) @@ -790,39 +786,39 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight, } else if (position == ImageRect::UPPER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - x = graphics->mWidth - defaultWidth; + x = mainGraphics->mWidth - defaultWidth; } else if (position == ImageRect::LEFT) { - y = (graphics->mHeight - defaultHeight) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = (graphics->mHeight - defaultHeight) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::RIGHT) { - x = graphics->mWidth - defaultWidth; - y = (graphics->mHeight - defaultHeight) / 2; + x = mainGraphics->mWidth - defaultWidth; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::LOWER_LEFT) { - y = graphics->mHeight - defaultHeight; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = graphics->mHeight - defaultHeight; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_RIGHT) { - x = graphics->mWidth - defaultWidth; - y = graphics->mHeight - defaultHeight; + x = mainGraphics->mWidth - defaultWidth; + y = mainGraphics->mHeight - defaultHeight; } mDefaultX = x - offsetX; @@ -994,11 +990,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) // Look if the window is partially off-screen limits... if (partially) { - if (winDimension.x + winDimension.width > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x + winDimension.width > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y + winDimension.height > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y + winDimension.height > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; setDimension(winDimension); return; @@ -1006,11 +1002,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) if (entirely) { - if (winDimension.x > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; } setDimension(winDimension); } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 8431cece1..eaec791ee 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -99,9 +99,9 @@ WindowMenu::WindowMenu(): KeyboardConfig::KEY_WINDOW_DIDYOUKNOW); addButton(N_("SET"), _("Setup"), x, h, KeyboardConfig::KEY_WINDOW_SETUP); - if (graphics) + if (mainGraphics) { - setDimension(gcn::Rectangle(graphics->mWidth - x - 3, + setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3, 3, x - 3, h)); } @@ -345,9 +345,9 @@ void WindowMenu::updateButtons() h = btn->getHeight(); } } - if (graphics) + if (mainGraphics) { - setDimension(gcn::Rectangle(graphics->mWidth - x - 3, + setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3, 3, x - 3, h)); } } diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp index feaa47729..6effb48c8 100644 --- a/src/guichan/cliprectangle.cpp +++ b/src/guichan/cliprectangle.cpp @@ -61,15 +61,15 @@ namespace gcn yOffset = 0; } - ClipRectangle::ClipRectangle(int x, int y, int width, int height, - int xOffset, int yOffset) + ClipRectangle::ClipRectangle(int x0, int y0, int width0, int height0, + int xOffset0, int yOffset0) { - this->x = x; - this->y = y; - this->width = width; - this->height = height; - this->xOffset = xOffset; - this->yOffset = yOffset; + x = x0; + y = y0; + width = width0; + height = height0; + xOffset = xOffset0; + yOffset = yOffset0; } const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) diff --git a/src/guichan/include/guichan/cliprectangle.hpp b/src/guichan/include/guichan/cliprectangle.hpp index 792c40bb9..b5aa5e4af 100644 --- a/src/guichan/include/guichan/cliprectangle.hpp +++ b/src/guichan/include/guichan/cliprectangle.hpp @@ -67,23 +67,23 @@ namespace gcn /** * Constructor. * - * @param x The rectangle x coordinate. - * @param y The rectangle y coordinate. - * @param width The rectangle width. - * @param height The rectangle height. - * @param xOffset The offset of the x coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - * @param yOffset The offset of the y coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. + * @param x0 The rectangle x coordinate. + * @param y0 The rectangle y coordinate. + * @param width0 The rectangle width. + * @param height0 The rectangle height. + * @param xOffset0 The offset of the x coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + * @param yOffset0 The offset of the y coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. */ - ClipRectangle(int x, - int y, - int width, - int height, - int xOffset, - int yOffset); + ClipRectangle(int x0, + int y0, + int width0, + int height0, + int xOffset0, + int yOffset0); /** * Copy constructor. Copies x, y, width and height diff --git a/src/guichan/include/guichan/inputevent.hpp b/src/guichan/include/guichan/inputevent.hpp index 8594d3dae..f252341cf 100644 --- a/src/guichan/include/guichan/inputevent.hpp +++ b/src/guichan/include/guichan/inputevent.hpp @@ -69,10 +69,10 @@ namespace gcn * @param isMetaPressed True if meta is pressed, false otherwise. */ InputEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed); + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed); /** * Checks if shift is pressed. diff --git a/src/guichan/include/guichan/keyevent.hpp b/src/guichan/include/guichan/keyevent.hpp index f42601235..5c10238c5 100644 --- a/src/guichan/include/guichan/keyevent.hpp +++ b/src/guichan/include/guichan/keyevent.hpp @@ -71,22 +71,22 @@ namespace gcn * Constructor. * * @param source The source widget of the event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the event. A value from KeyEventType. - * @param isNumericPad True if the event occured on the numeric pad, + * @param numericPad True if the event occured on the numeric pad, * false otherwise. * @param key The key of the event. */ KeyEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, - bool isNumericPad, + bool numericPad, const Key& key); /** diff --git a/src/guichan/include/guichan/mouseevent.hpp b/src/guichan/include/guichan/mouseevent.hpp index 280d373e6..6f6dc828c 100644 --- a/src/guichan/include/guichan/mouseevent.hpp +++ b/src/guichan/include/guichan/mouseevent.hpp @@ -66,10 +66,10 @@ namespace gcn * Constructor. * * @param source The source widget of the mouse event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the mouse event. * @param button The button of the mouse event. * @param x The x coordinate of the event relative to the source widget. @@ -78,10 +78,10 @@ namespace gcn * It's set to zero if another button is used. */ MouseEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, diff --git a/src/guichan/inputevent.cpp b/src/guichan/inputevent.cpp index 7a3bdb06d..a135b15b8 100644 --- a/src/guichan/inputevent.cpp +++ b/src/guichan/inputevent.cpp @@ -52,15 +52,15 @@ namespace gcn { InputEvent::InputEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed) + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed) :Event(source), - mShiftPressed(isShiftPressed), - mControlPressed(isControlPressed), - mAltPressed(isAltPressed), - mMetaPressed(isMetaPressed), + mShiftPressed(shiftPressed), + mControlPressed(controlPressed), + mAltPressed(altPressed), + mMetaPressed(metaPressed), mIsConsumed(false) { diff --git a/src/guichan/keyevent.cpp b/src/guichan/keyevent.cpp index 1bc8fe9d2..f9c14bb59 100644 --- a/src/guichan/keyevent.cpp +++ b/src/guichan/keyevent.cpp @@ -52,20 +52,20 @@ namespace gcn { KeyEvent::KeyEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, - bool isNumericPad, + bool numericPad, const Key& key) :InputEvent(source, - isShiftPressed, - isControlPressed, - isAltPressed, - isMetaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), - mIsNumericPad(isNumericPad), + mIsNumericPad(numericPad), mKey(key) { diff --git a/src/guichan/mouseevent.cpp b/src/guichan/mouseevent.cpp index e5046ed15..5ff544a04 100644 --- a/src/guichan/mouseevent.cpp +++ b/src/guichan/mouseevent.cpp @@ -52,20 +52,20 @@ namespace gcn { MouseEvent::MouseEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, int y, int clickCount) :InputEvent(source, - isShiftPressed, - isControlPressed, - isAltPressed, - isMetaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), mButton(button), mX(x), diff --git a/src/map.h b/src/map.h index c92a3c60f..e9a9df593 100644 --- a/src/map.h +++ b/src/map.h @@ -96,10 +96,10 @@ struct MetaTile class MapObject { public: - MapObject(int type, std::string data) + MapObject(int type0, std::string data0) { - this->type = type; - this->data = data; + type = type0; + data = data0; } int type; diff --git a/src/position.h b/src/position.h index 1d3070e1b..973a774f0 100644 --- a/src/position.h +++ b/src/position.h @@ -31,8 +31,8 @@ */ struct Position { - Position(int x, int y): - x(x), y(y) + Position(int x0, int y0): + x(x0), y(y0) { } int x; diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index 10d70c2c7..319bc5b8c 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -41,16 +41,16 @@ AmbientLayer::AmbientLayer(Image *img, float parallax, if (keepRatio && !mImage->useOpenGL() /*&& defaultScreenWidth != 0 && defaultScreenHeight != 0*/ - && graphics->mWidth != defaultScreenWidth - && graphics->mHeight != defaultScreenHeight) + && mainGraphics->mWidth != defaultScreenWidth + && mainGraphics->mHeight != defaultScreenHeight) { // Rescale the overlay to keep the ratio as if we were on // the default resolution... Image *rescaledOverlay = ResourceManager::getInstance()-> getRescaled(mImage, static_cast(mImage->mBounds.w) - / defaultScreenWidth * graphics->mWidth, + / defaultScreenWidth * mainGraphics->mWidth, static_cast(mImage->mBounds.h) - / defaultScreenHeight * graphics->mHeight); + / defaultScreenHeight * mainGraphics->mHeight); if (rescaledOverlay) mImage = rescaledOverlay; diff --git a/src/resources/colordb.h b/src/resources/colordb.h index ce128578e..83bff57da 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -38,11 +38,11 @@ namespace ColorDB color("") { } - ItemColor(int id, std::string name, std::string color) + ItemColor(int id0, std::string name0, std::string color0) { - this->id = id; - this->name = name; - this->color = color; + this->id = id0; + this->name = name0; + this->color = color0; } int id; diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 267f60eef..c20961eff 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -68,10 +68,10 @@ namespace ItemDB struct Stat { - Stat(const std::string &tag, - const std::string &format): - tag(tag), - format(format) + Stat(const std::string &tag0, + const std::string &format0) : + tag(tag0), + format(format0) {} std::string tag; diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 8fa64e7b9..ccad62b1b 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -43,10 +43,10 @@ struct SpriteReference sprite(""), variant(0) {} - SpriteReference(std::string sprite, int variant) + SpriteReference(std::string sprite0, int variant0) { - this->sprite = sprite; - this->variant = variant; + sprite = sprite0; + variant = variant0; } std::string sprite; diff --git a/src/vector.h b/src/vector.h index 87e9c647a..0f10bae96 100644 --- a/src/vector.h +++ b/src/vector.h @@ -46,10 +46,10 @@ class Vector /** * Constructor. */ - Vector(float x, float y, float z = 0.0f): - x(x), - y(y), - z(z) + Vector(float x0, float y0, float z0 = 0.0f): + x(x0), + y(y0), + z(z0) {} /** -- cgit v1.2.3-70-g09d2 From 703a3c4df3732e3e88559147001260f3355d42d6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 22:10:53 +0300 Subject: Continue fix for shadow variables/methods errors. --- src/actorspritemanager.cpp | 7 +++--- src/actorspritemanager.h | 4 +-- src/client.cpp | 52 +++++++++++++++++++-------------------- src/client.h | 4 +-- src/commandhandler.cpp | 6 ++--- src/game.cpp | 4 +-- src/gui/chatwindow.cpp | 8 +++--- src/gui/chatwindow.h | 4 +-- src/gui/inventorywindow.cpp | 11 +++------ src/gui/itemamountwindow.cpp | 4 +-- src/gui/logindialog.cpp | 8 +++--- src/gui/logindialog.h | 2 +- src/gui/ministatuswindow.cpp | 4 +-- src/gui/ministatuswindow.h | 2 +- src/gui/popupmenu.cpp | 15 ++++++----- src/gui/register.cpp | 22 ++++++++--------- src/gui/sdlfont.cpp | 4 +-- src/gui/serverdialog.cpp | 10 ++++---- src/gui/setup_video.cpp | 16 ++++++------ src/gui/shopwindow.cpp | 2 +- src/gui/socialwindow.cpp | 6 ++--- src/gui/textcommandeditor.cpp | 4 +-- src/gui/tradewindow.cpp | 4 +-- src/gui/unregisterdialog.cpp | 16 ++++++------ src/gui/viewport.cpp | 2 +- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/mouseevent.h | 10 ++++---- src/gui/windowmenu.cpp | 4 +-- src/gui/windowmenu.h | 2 +- src/localplayer.cpp | 6 ++--- src/map.cpp | 10 ++++---- src/net/ea/buysellhandler.cpp | 12 ++++----- src/net/ea/chathandler.cpp | 20 +++++++-------- src/net/ea/inventoryhandler.h | 16 ++++++------ src/net/manaserv/chathandler.cpp | 2 +- src/net/tmwa/adminhandler.cpp | 2 +- src/net/tmwa/adminhandler.h | 2 +- src/net/tmwa/beinghandler.cpp | 12 ++++----- src/party.cpp | 4 +-- src/resources/beinginfo.h | 10 ++++---- 40 files changed, 166 insertions(+), 169 deletions(-) (limited to 'src/resources') diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 1104f034a..3acb63dc3 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -257,7 +257,6 @@ void ActorSpriteManager::undelete(ActorSprite *actor) for (it = mDeleteActors.begin(), it_end = mDeleteActors.end(); it != it_end; ++it) { - ActorSprite *actor = *it; if (*it == actor) { mDeleteActors.erase(*it); @@ -906,15 +905,15 @@ bool ActorSpriteManager::validateBeing(Being *aroundBeing, Being* being, || player_node->isReachable(being, maxCost)); } -void ActorSpriteManager::healTarget(LocalPlayer* player_node) +void ActorSpriteManager::healTarget() { if (!player_node) return; - heal(player_node, player_node->getTarget()); + heal(player_node->getTarget()); } -void ActorSpriteManager::heal(LocalPlayer* player_node, Being* target) +void ActorSpriteManager::heal(Being* target) { if (!player_node || !chatWindow || !player_node->isAlive() || !Net::getPlayerHandler()->canUseMagic()) diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h index 91503e1c3..bd2ae79fb 100644 --- a/src/actorspritemanager.h +++ b/src/actorspritemanager.h @@ -164,9 +164,9 @@ class ActorSpriteManager: public ConfigListener // void HealAllTargets(Being *aroundBeing, int maxdist, // Being::Type type) const; - void healTarget(LocalPlayer* player_node); + void healTarget(); - void heal(LocalPlayer* player_node, Being* target); + void heal(Being* target); void itenplz(); diff --git a/src/client.cpp b/src/client.cpp index b9e9735c9..be1c00197 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -196,16 +196,16 @@ Uint32 nextSecond(Uint32 interval, void *param A_UNUSED) * @return the elapsed time in milliseconds * between two tick values. */ -int get_elapsed_time(int start_time) +int get_elapsed_time(int startTime) { - if (start_time <= tick_time) + if (startTime <= tick_time) { - return (tick_time - start_time) * MILLISECONDS_IN_A_TICK; + return (tick_time - startTime) * MILLISECONDS_IN_A_TICK; } else { - return (tick_time + (MAX_TICK_VALUE - start_time)) - * MILLISECONDS_IN_A_TICK; + return (tick_time + (MAX_TICK_VALUE - startTime)) + * MILLISECONDS_IN_A_TICK; } } @@ -845,10 +845,10 @@ int Client::exec() if (mState != mOldState) { { - Mana::Event event(EVENT_STATECHANGE); - event.setInt("oldState", mOldState); - event.setInt("newState", mState); - Mana::Event::trigger(CHANNEL_CLIENT, event); + Mana::Event evt(EVENT_STATECHANGE); + evt.setInt("oldState", mOldState); + evt.setInt("newState", mState); + Mana::Event::trigger(CHANNEL_CLIENT, evt); } if (mOldState == STATE_GAME) @@ -1046,10 +1046,10 @@ int Client::exec() if (!BeingInfo::unknown) BeingInfo::unknown = new BeingInfo; - Mana::Event event(EVENT_STATECHANGE); - event.setInt("newState", STATE_LOAD_DATA); - event.setInt("oldState", mOldState); - Mana::Event::trigger(CHANNEL_CLIENT, event); + Mana::Event evt(EVENT_STATECHANGE); + evt.setInt("newState", STATE_LOAD_DATA); + evt.setInt("oldState", mOldState); + Mana::Event::trigger(CHANNEL_CLIENT, evt); // Load XML databases ColorDB::load(); @@ -1733,27 +1733,27 @@ void Client::initScreenshotDir() } } -void Client::accountLogin(LoginData *loginData) +void Client::accountLogin(LoginData *data) { - if (!loginData) + if (!data) return; - logger->log("Username is %s", loginData->username.c_str()); + logger->log("Username is %s", data->username.c_str()); // Send login infos - if (loginData->registerLogin) - Net::getLoginHandler()->registerAccount(loginData); + if (data->registerLogin) + Net::getLoginHandler()->registerAccount(data); else - Net::getLoginHandler()->loginAccount(loginData); + Net::getLoginHandler()->loginAccount(data); // Clear the password, avoids auto login when returning to login - loginData->password = ""; + data->password = ""; // TODO This is not the best place to save the config, but at least better // than the login gui window - if (loginData->remember) - serverConfig.setValue("username", loginData->username); - serverConfig.setValue("remember", loginData->remember); + if (data->remember) + serverConfig.setValue("username", data->username); + serverConfig.setValue("remember", data->remember); } bool Client::copyFile(std::string &configPath, std::string &oldConfigPath) @@ -1805,7 +1805,7 @@ void Client::storeSafeParameters() int width; int height; std::string font; - std::string boldFont; + std::string bFont; std::string particleFont; std::string helpFont; std::string secureFont; @@ -1833,7 +1833,7 @@ void Client::storeSafeParameters() height = config.getIntValue("screenheight"); font = config.getStringValue("font"); - boldFont = config.getStringValue("boldFont"); + bFont = config.getStringValue("boldFont"); particleFont = config.getStringValue("particleFont"); helpFont = config.getStringValue("helpFont"); secureFont = config.getStringValue("secureFont"); @@ -1878,7 +1878,7 @@ void Client::storeSafeParameters() config.setValue("screenwidth", width); config.setValue("screenheight", height); config.setValue("font", font); - config.setValue("boldFont", boldFont); + config.setValue("boldFont", bFont); config.setValue("particleFont", particleFont); config.setValue("helpFont", helpFont); config.setValue("secureFont", secureFont); diff --git a/src/client.h b/src/client.h index 3edf12674..4409cf8db 100644 --- a/src/client.h +++ b/src/client.h @@ -78,7 +78,7 @@ extern LoginData loginData; /** * Returns elapsed time. (Warning: supposes the delay is always < 100 seconds) */ -int get_elapsed_time(int start_time); +int get_elapsed_time(int startTime); /** * All client states. @@ -291,7 +291,7 @@ private: bool copyFile(std::string &configPath, std::string &oldConfigPath); bool createConfig(std::string &configPath); - void accountLogin(LoginData *loginData); + void accountLogin(LoginData *data); void storeSafeParameters(); diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index dc962a17d..d16a7db27 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -397,7 +397,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) if (tempNick.compare(playerName) == 0 || args.empty()) return; - chatWindow->whisper(recvnick, msg, BY_PLAYER); + chatWindow->addWhisper(recvnick, msg, BY_PLAYER); } else tab->chatLog(_("Cannot send empty whispers!"), BY_SERVER); @@ -851,11 +851,11 @@ void CommandHandler::handleHeal(const std::string &args, ChatTab *tab A_UNUSED) Being *being = actorSpriteManager->findBeingByName( args, Being::PLAYER); if (being) - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else { - actorSpriteManager->heal(player_node, player_node); + actorSpriteManager->heal(player_node); } } diff --git a/src/game.cpp b/src/game.cpp index a0635f42f..3c7579d78 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -972,7 +972,7 @@ void Game::handleInput() break; case KeyboardConfig::KEY_MAGIC_INMA1: - actorSpriteManager->healTarget(player_node); + actorSpriteManager->healTarget(); setValidSpeed(); break; @@ -1094,7 +1094,7 @@ void Game::handleInput() && !keyboard.isKeyActive(keyboard.KEY_TARGET) && !InventoryWindow::isAnyInputFocused()) { - const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); +// const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); if (setupWindow->isVisible()) { diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index c52511189..f3e4b88b8 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -907,9 +907,9 @@ void ChatWindow::addItemText(const std::string &item) addInputText(text.str()); } -void ChatWindow::setVisible(bool isVisible) +void ChatWindow::setVisible(bool visible) { - Window::setVisible(isVisible); + Window::setVisible(visible); /* * For whatever reason, if setVisible is called, the mTmpVisible effect @@ -918,8 +918,8 @@ void ChatWindow::setVisible(bool isVisible) mTmpVisible = false; } -void ChatWindow::whisper(const std::string &nick, - const std::string &mes, Own own) +void ChatWindow::addWhisper(const std::string &nick, + const std::string &mes, Own own) { if (mes.empty() || !player_node) return; diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index 97e366701..1ad468a3b 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -222,8 +222,8 @@ class ChatWindow : public Window, void doPresent(); - void whisper(const std::string &nick, const std::string &mes, - Own own = BY_OTHER); + void addWhisper(const std::string &nick, const std::string &mes, + Own own = BY_OTHER); ChatTab *addWhisperTab(const std::string &nick, bool switchTo = false); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index da1c45782..c6afaaf1d 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -362,17 +362,12 @@ void InventoryWindow::action(const gcn::ActionEvent &event) else if (event.getId() == "split") { ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item, - (item->getQuantity() - 1)); + (item->getQuantity() - 1)); } else if (event.getId() == "retrieve") { - Item *item = mItems->getSelectedItem(); - - if (!item) - return; - - ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, this, - item); + ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, + this, item); } } diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index 059f3d785..9bd3f3ab3 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -53,11 +53,11 @@ class ItemsModal : public gcn::ListModel public: ItemsModal() { - std::map info = ItemDB::getItemInfos(); + std::map items = ItemDB::getItemInfos(); std::list tempStrings; for (std::map::const_iterator - i = info.begin(), i_end = info.end(); + i = items.begin(), i_end = items.end(); i != i_end; ++i) { if (i->first < 0) diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index ab5dc7401..adf499f75 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -81,10 +81,10 @@ public: } }; -LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, +LoginDialog::LoginDialog(LoginData *data, std::string serverName, std::string *updateHost): Window(_("Login")), - mLoginData(loginData), + mLoginData(data), mUpdateHost(updateHost), mServerName(serverName) { @@ -94,7 +94,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passLabel = new Label(_("Password:")); mCustomUpdateHost = new CheckBox(_("Custom update host"), - loginData->updateType & LoginData::Upd_Custom, this, "customhost"); + mLoginData->updateType & LoginData::Upd_Custom, this, "customhost"); mUpdateHostText = new TextField(serverConfig.getValue( "customUpdateHost", "")); @@ -112,7 +112,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, mUpdateTypeModel = new UpdateTypeModel(); mUpdateTypeDropDown = new DropDown(mUpdateTypeModel); mUpdateTypeDropDown->setActionEventId("updatetype"); - mUpdateTypeDropDown->setSelected((loginData->updateType + mUpdateTypeDropDown->setSelected((mLoginData->updateType | LoginData::Upd_Custom) ^ LoginData::Upd_Custom); if (!mCustomUpdateHost->isSelected()) diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h index e464c6f24..0696bc680 100644 --- a/src/gui/logindialog.h +++ b/src/gui/logindialog.h @@ -49,7 +49,7 @@ class LoginDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ - LoginDialog(LoginData *loginData, std::string serverName, + LoginDialog(LoginData *data, std::string serverName, std::string *updateHost); ~LoginDialog(); diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index b325bcef6..e3f441b60 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -400,12 +400,12 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) mStatusPopup->hide(); } -void MiniStatusWindow::showBar(std::string name, bool isVisible) +void MiniStatusWindow::showBar(std::string name, bool visible) { ProgressBar *bar = mBarNames[name]; if (!bar) return; - bar->setVisible(isVisible); + bar->setVisible(visible); updateBars(); saveBars(); } diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 91aebcfac..5e1b442dc 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -80,7 +80,7 @@ class MiniStatusWindow : public Popup, void mouseExited(gcn::MouseEvent &event); - void showBar(std::string name, bool isVisible); + void showBar(std::string name, bool visible); void updateBars(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 7e43c9954..e43ab35bc 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -879,7 +879,7 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "heal" && being && being->getType() != Being::MONSTER) { - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else if (link == "unignore" && being && being->getType() == ActorSprite::PLAYER) @@ -1591,12 +1591,15 @@ void PopupMenu::handleLink(const std::string &link, } else if (!link.compare(0, 7, "player_")) { - mBeingId = atoi(link.substr(7).c_str()); - Being *being = actorSpriteManager->findBeing(mBeingId); - if (being) + if (actorSpriteManager) { - showPopup(getX(), getY(), being); - return; + mBeingId = atoi(link.substr(7).c_str()); + being = actorSpriteManager->findBeing(mBeingId); + if (being) + { + showPopup(getX(), getY(), being); + return; + } } } else if (!link.compare(0, 12, "hide button_")) diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 913c958f2..e2c718359 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -62,21 +62,21 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) mTarget->requestFocus(); } -RegisterDialog::RegisterDialog(LoginData *loginData): +RegisterDialog::RegisterDialog(LoginData *data): Window(_("Register")), mEmailField(0), mMaleButton(0), mFemaleButton(0), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passwordLabel = new Label(_("Password:")); gcn::Label *confirmLabel = new Label(_("Confirm:")); - mUserField = new TextField(loginData->username); - mPasswordField = new PasswordField(loginData->password); + mUserField = new TextField(mLoginData->username); + mPasswordField = new PasswordField(mLoginData->password); mConfirmField = new PasswordField; mRegisterButton = new Button(_("Register"), "register", this); mCancelButton = new Button(_("Cancel"), "cancel", this); @@ -161,7 +161,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) const std::string user = mUserField->getText(); logger->log("RegisterDialog::register Username is %s", user.c_str()); - std::string errorMessage; + std::string errorMsg; int error = 0; unsigned int minUser = Net::getLoginHandler()->getMinUserNameLength(); @@ -172,7 +172,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) if (user.length() < minUser) { // Name too short - errorMessage = strprintf + errorMsg = strprintf (_("The username needs to be at least %d characters long."), minUser); error = 1; @@ -180,7 +180,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (user.length() > maxUser - 1 ) { // Name too long - errorMessage = strprintf + errorMsg = strprintf (_("The username needs to be less than %d characters long."), maxUser); error = 1; @@ -188,7 +188,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText().length() < minPass) { // Pass too short - errorMessage = strprintf + errorMsg = strprintf (_("The password needs to be at least %d characters long."), minPass); error = 2; @@ -196,7 +196,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText().length() > maxPass - 1 ) { // Pass too long - errorMessage = strprintf + errorMsg = strprintf (_("The password needs to be less than %d characters long."), maxPass); error = 2; @@ -204,7 +204,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText() != mConfirmField->getText()) { // Password does not match with the confirmation one - errorMessage = _("Passwords do not match."); + errorMsg = _("Passwords do not match."); error = 2; } @@ -225,7 +225,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 8dd7f929d..b196ae4e4 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -48,8 +48,8 @@ char *strBuf; class SDLTextChunk { public: - SDLTextChunk(const std::string &text, const gcn::Color &color) : - img(0), text(text), color(color) + SDLTextChunk(const std::string &text0, const gcn::Color &color0) : + img(0), text(text0), color(color0) { } diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 763c190d6..f9d6ebfd0 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -548,7 +548,7 @@ void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) void ServerDialog::logic() { { - MutexLocker lock(&mMutex); + MutexLocker tempLock(&mMutex); if (mDownloadStatus == DOWNLOADING_COMPLETE) { mDownloadStatus = DOWNLOADING_OVER; @@ -636,11 +636,11 @@ void ServerDialog::loadServers(bool addNew) return; } - int version = XML::getProperty(rootNode, "version", 0); - if (version != 1) + int ver = XML::getProperty(rootNode, "version", 0); + if (ver != 1) { logger->log("Error: unsupported online server list version: %d", - version); + ver); return; } @@ -703,7 +703,7 @@ void ServerDialog::loadServers(bool addNew) server.version.first = gui->getFont()->getWidth(version); server.version.second = version; - MutexLocker lock(&mMutex); + MutexLocker tempLock(&mMutex); // Add the server to the local list if it's not already present bool found = false; for (unsigned int i = 0; i < mServers.size(); i++) diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 7bbcd9a2c..bc210075a 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -478,20 +478,20 @@ void Setup_Video::apply() fullscreen = !fullscreen; if (!mainGraphics->setFullscreen(fullscreen)) { - std::stringstream errorMessage; + std::stringstream errorMsg; if (fullscreen) { - errorMessage << _("Failed to switch to windowed mode " - "and restoration of old mode also " - "failed!") << std::endl; + errorMsg << _("Failed to switch to windowed mode " + "and restoration of old mode also " + "failed!") << std::endl; } else { - errorMessage << _("Failed to switch to fullscreen mode" - " and restoration of old mode also " - "failed!") << std::endl; + errorMsg << _("Failed to switch to fullscreen mode" + " and restoration of old mode also " + "failed!") << std::endl; } - logger->error(errorMessage.str()); + logger->error(errorMsg.str()); } } #if defined(WIN32) || defined(__APPLE__) diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 5cf1573bb..c62c3254c 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -596,7 +596,7 @@ void ShopWindow::sendMessage(const std::string &nick, if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); //here was true } diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 7feca8bf4..886894564 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -962,7 +962,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(true); ava->setLevel(level); ava->setType(MapItem::PRIORITY); @@ -997,7 +997,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(true); ava->setLevel(level); ava->setType(MapItem::ATTACK); @@ -1032,7 +1032,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(false); ava->setLevel(level); ava->setType(MapItem::IGNORE_); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 9d759c4a2..1e18da57a 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -61,11 +61,11 @@ class IconsModal : public gcn::ListModel public: IconsModal() { - std::map info = ItemDB::getItemInfos(); + std::map items = ItemDB::getItemInfos(); std::list tempStrings; for (std::map::const_iterator - i = info.begin(), i_end = info.end(); + i = items.begin(), i_end = items.end(); i != i_end; ++i) { if (i->first < 0) diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 3c19ee9c2..d0ae67746 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -443,10 +443,10 @@ void TradeWindow::initTrade(std::string nick) bool TradeWindow::checkItem(Item *item) { - Item *tradeItem = mMyInventory->findItem( + Item *tItem = mMyInventory->findItem( item->getId(), item->getColor()); - if (tradeItem && (tradeItem->getQuantity() > 1 + if (tItem && (tItem->getQuantity() > 1 || item->getQuantity() > 1)) { if (localChatTab) diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 568e0613e..e875000c4 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -46,10 +46,10 @@ #include "debug.h" -UnRegisterDialog::UnRegisterDialog(LoginData *loginData): +UnRegisterDialog::UnRegisterDialog(LoginData *data): Window(_("Unregister"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *userLabel = new Label(strprintf(_("Name: %s"), mLoginData-> username.c_str())); @@ -108,7 +108,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) logger->log("UnregisterDialog::unregistered, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; bool error = false; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -118,15 +118,15 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) if (password.length() < min) { // Pass too short - errorMessage << strprintf(_("The password needs to be at least %d " - "characters long."), min); + errorMsg << strprintf(_("The password needs to be at least %d " + "characters long."), min); error = true; } else if (password.length() > max - 1) { // Pass too long - errorMessage << strprintf(_("The password needs to be less than " - "%d characters long."), max); + errorMsg << strprintf(_("The password needs to be less than " + "%d characters long."), max); error = true; } @@ -134,7 +134,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) { mWrongDataNoticeListener->setTarget(this->mPasswordField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 073697459..461dd581d 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -489,7 +489,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (actorSpriteManager) { if (player_node != mHoverBeing || mSelfMouseHeal) - actorSpriteManager->heal(player_node, mHoverBeing); + actorSpriteManager->heal(mHoverBeing); } } else if (player_node->withinAttackRange(mHoverBeing) || diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 29fca7662..18dc48417 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -330,7 +330,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) Being* being = actorSpriteManager->findBeingByName(ava->getName(), Being::PLAYER); if (being) - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else { diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h index 5e9a46cfd..9484be0a5 100644 --- a/src/gui/widgets/mouseevent.h +++ b/src/gui/widgets/mouseevent.h @@ -28,12 +28,12 @@ class MouseEvent : public gcn::MouseEvent { public: - MouseEvent(gcn::Widget* source, bool isShiftPressed, - bool isControlPressed, bool isAltPressed, - bool isMetaPressed, unsigned int type, unsigned int button, + MouseEvent(gcn::Widget* source, bool shiftPressed, + bool controlPressed, bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, int y, int clickCount) : - gcn::MouseEvent(source, isShiftPressed, isControlPressed, - isAltPressed, isMetaPressed, type, button, x, y, + gcn::MouseEvent(source, shiftPressed, controlPressed, + altPressed, metaPressed, type, button, x, y, clickCount) { } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index eaec791ee..487035350 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -315,13 +315,13 @@ void WindowMenu::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) mTextPopup->hide(); } -void WindowMenu::showButton(std::string name, bool isVisible) +void WindowMenu::showButton(std::string name, bool visible) { Button *btn = dynamic_cast(mButtonNames[name]); if (!btn) return; - btn->setVisible(isVisible); + btn->setVisible(visible); updateButtons(); saveButtons(); } diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 6572fe470..739a302ba 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -72,7 +72,7 @@ class WindowMenu : public Container, std::vector &getButtons() { return mButtons; } - void showButton(std::string name, bool isVisible); + void showButton(std::string name, bool visible); void loadButtons(); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index fdbc4b0b7..b19b1b9af 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -3674,9 +3674,9 @@ void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2) { if (actorSpriteManager) { - Being *being = actorSpriteManager->findBeingByName( - mPlayerFollowed, Being::PLAYER); - setTarget(being); + Being *b = actorSpriteManager->findBeingByName( + mPlayerFollowed, Being::PLAYER); + setTarget(b); } } moveToTarget(); diff --git a/src/map.cpp b/src/map.cpp index e5b3632b6..86d1171f0 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -114,10 +114,10 @@ void TileAnimation::update(int ticks) } } -MapLayer::MapLayer(int x, int y, int width, int height, bool isFringeLayer): +MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer): mX(x), mY(y), mWidth(width), mHeight(height), - mIsFringeLayer(isFringeLayer), + mIsFringeLayer(fringeLayer), mHighlightAttackRange(config.getBoolValue("highlightAttackRange")) { const int size = mWidth * mHeight; @@ -1592,9 +1592,9 @@ void Map::addParticleEffect(const std::string &effectFile, particleEffects.push_back(newEffect); } -void Map::initializeParticleEffects(Particle *particleEngine) +void Map::initializeParticleEffects(Particle *engine) { - if (!particleEngine) + if (!engine) return; Particle *p; @@ -1605,7 +1605,7 @@ void Map::initializeParticleEffects(Particle *particleEngine) i = particleEffects.begin(); i != particleEffects.end(); ++i) { - p = particleEngine->addEffect(i->file, i->x, i->y); + p = engine->addEffect(i->file, i->x, i->y); if (p && i->w > 0 && i->h > 0) p->adjustEmitterSize(i->w, i->h); } diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index 685562d6f..f38d17a59 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -70,7 +70,7 @@ void BuySellHandler::requestSellList(std::string nick) else { if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } } @@ -89,7 +89,7 @@ void BuySellHandler::requestBuyList(std::string nick) else { if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } } @@ -102,12 +102,12 @@ void BuySellHandler::sendBuyRequest(std::string nick, ShopItem* item, return; } std::string data = strprintf("!buyitem %d %d %d", - item->getId(), item->getPrice(), amount); + item->getId(), item->getPrice(), amount); if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item, @@ -120,12 +120,12 @@ void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item, } std::string data = strprintf("!sellitem %d %d %d", - item->getId(), item->getPrice(), amount); + item->getId(), item->getPrice(), amount); if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } void BuySellHandler::processNpcBuySellChoice(Net::MessageIn &msg) diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 5737cc2b2..c18b1bb9a 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -125,7 +125,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) case 0x01: if (chatWindow) { - chatWindow->whisper(nick, + chatWindow->addWhisper(nick, strprintf(_("Whisper could not be " "sent, %s is offline."), nick.c_str()), BY_SERVER); } @@ -133,7 +133,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) case 0x02: if (chatWindow) { - chatWindow->whisper(nick, + chatWindow->addWhisper(nick, strprintf(_("Whisper could not " "be sent, ignored by %s."), nick.c_str()), BY_SERVER); @@ -183,7 +183,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (tradeBot) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::SELL); } @@ -193,7 +193,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (tradeBot) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::BUY); } @@ -201,7 +201,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) else if (chatMsg.find("!buyitem ") == 0) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { shopWindow->processRequest(nick, chatMsg, @@ -211,7 +211,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) else if (chatMsg.find("!sellitem ") == 0) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { shopWindow->processRequest(nick, chatMsg, @@ -223,7 +223,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) { chatMsg = chatMsg.erase(0, 2); if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) { @@ -232,12 +232,12 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) } else if (chatWindow) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } else if (chatWindow) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } else @@ -246,7 +246,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) || (chatMsg.find("!selllist") != 0 && chatMsg.find("!buylist") != 0))) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } } diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 4be4ddaa6..cb1e84673 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -114,15 +114,15 @@ class InventoryItem int refine; bool equip; - InventoryItem(int slot, int id, int quantity, int refine, - unsigned char color, bool equip) + InventoryItem(int slot0, int id0, int quantity0, int refine0, + unsigned char color0, bool equip0) { - this->slot = slot; - this->id = id; - this->quantity = quantity; - this->refine = refine; - this->color = color; - this->equip = equip; + slot = slot0; + id = id0; + quantity = quantity0; + refine = refine0; + color = color0; + equip = equip0; } }; diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp index 85323b11a..16552018e 100644 --- a/src/net/manaserv/chathandler.cpp +++ b/src/net/manaserv/chathandler.cpp @@ -231,7 +231,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg) std::string userNick = msg.readString(); std::string chatMsg = msg.readString(); - chatWindow->whisper(userNick, chatMsg); + chatWindow->addWhisper(userNick, chatMsg); } void ChatHandler::handleAnnouncement(Net::MessageIn &msg) diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index a332b04fa..5d5034938 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -89,7 +89,7 @@ void AdminHandler::localAnnounce(const std::string &text) outMsg.writeString(text, static_cast(text.length())); } -void AdminHandler::hide(bool hide A_UNUSED) +void AdminHandler::hide(bool h A_UNUSED) { MessageOut outMsg(CMSG_ADMIN_HIDE); outMsg.writeInt32(0); //unused diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index 79f41dece..53fd4831f 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -50,7 +50,7 @@ class AdminHandler : public MessageHandler, public Ea::AdminHandler void localAnnounce(const std::string &text); - void hide(bool hide); + void hide(bool h); void kick(int playerId); }; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index c087ab43d..845c30f19 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -445,7 +445,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) Being *dstBeing; int hairStyle, hairColor; unsigned char colors[9]; - Uint8 dir; + // An update about a player, potentially including movement. int id = msg.readInt32(); @@ -469,7 +469,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) return; } - dir = dstBeing->getDirectionDelayed(); + Uint8 dir = dstBeing->getDirectionDelayed(); if (dir) { if (dir != dstBeing->getDirection()) @@ -568,10 +568,10 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) if (srcX != dstX || srcY != dstY) { - int dir = dstBeing->calcDirection(dstX, dstY); + int d = dstBeing->calcDirection(dstX, dstY); - if (dir && dstBeing->getDirection() != dir) - dstBeing->setDirectionDelayed(static_cast(dir)); + if (d && dstBeing->getDirection() != d) + dstBeing->setDirectionDelayed(static_cast(d)); } if (player_node->getCurrentAction() != Being::STAND) @@ -584,7 +584,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) } else { - Uint8 dir; +// Uint8 dir; Uint16 x, y; msg.readCoordinates(x, y, dir); dstBeing->setTileCoords(x, y); diff --git a/src/party.cpp b/src/party.cpp index 9becee1cd..9da1a235d 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -119,9 +119,9 @@ void Party::removeMember(PartyMember *member) if ((*itr)->mId == member->mId && (*itr)->getName() == member->getName()) { - PartyMember *member = (*itr); + PartyMember *m = (*itr); mMembers.erase(itr); - delete member; + delete m; deleted = true; break; } diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index a61483940..b93c11ba6 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -38,12 +38,12 @@ struct Attack std::string particleEffect; std::string missileParticle; - Attack(std::string action, std::string particleEffect, - std::string missileParticle) + Attack(std::string action0, std::string particleEffect0, + std::string missileParticle0) { - this->action = action; - this->particleEffect = particleEffect; - this->missileParticle = missileParticle; + action = action0; + particleEffect = particleEffect0; + missileParticle = missileParticle0; } }; -- cgit v1.2.3-70-g09d2 From e3dabb7f0a22c6442dde5f261d3414f9e7369592 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 23:11:23 +0300 Subject: Last fix part of shadow variables/methods errors. --- src/actorsprite.cpp | 19 ++++++++------- src/being.cpp | 39 +++++++++++++++--------------- src/gui/buydialog.cpp | 24 +++++++++---------- src/gui/charselectdialog.cpp | 34 +++++++++++++------------- src/gui/itemamountwindow.cpp | 36 ++++++++++++++-------------- src/gui/quitdialog.cpp | 20 ++++++++-------- src/gui/quitdialog.h | 2 +- src/gui/register.cpp | 30 +++++++++++------------ src/gui/selldialog.cpp | 24 +++++++++---------- src/gui/setup_video.cpp | 14 +++++------ src/gui/shopwindow.cpp | 34 +++++++++++++------------- src/gui/textcommandeditor.cpp | 56 +++++++++++++++++++++---------------------- src/gui/tradewindow.cpp | 16 ++++++------- src/gui/updaterwindow.cpp | 16 ++++++------- src/guild.cpp | 4 ++-- src/net/messagein.cpp | 16 ++++++------- src/particleemitter.cpp | 14 +++++------ src/resources/beinginfo.cpp | 4 ++-- src/resources/image.cpp | 6 ++--- src/resources/itemdb.cpp | 2 +- 20 files changed, 203 insertions(+), 207 deletions(-) (limited to 'src/resources') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 2cc138047..082ceda14 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -68,7 +68,7 @@ ActorSprite::~ActorSprite() // Notify listeners of the destruction. for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(), - end = mActorSpriteListeners.end(); iter != end; ++iter) + e = mActorSpriteListeners.end(); iter != e; ++iter) { (*iter)->actorSpriteDestroyed(*this); } @@ -366,11 +366,12 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, //setup particle effects if (Particle::enabled && particleEngine) { - std::vector::const_iterator it, it_end; - for (it = display.particles.begin(), it_end = display.particles.end(); - it != it_end; ++it) + std::vector::const_iterator itr, itr_end; + for (itr = display.particles.begin(), + itr_end = display.particles.end(); + itr != itr_end; ++itr) { - Particle *p = particleEngine->addEffect(*it, 0, 0); + Particle *p = particleEngine->addEffect(*itr, 0, 0); controlParticle(p); } } @@ -435,7 +436,7 @@ static const char *cursorSize(int size) void ActorSprite::initTargetCursor() { - static std::string targetCursor = "graphics/target-cursor-%s-%s.png"; + static std::string targetCursorFile = "graphics/target-cursor-%s-%s.png"; static int targetWidths[NUM_TC] = {44, 62, 82}; static int targetHeights[NUM_TC] = {35, 44, 60}; @@ -444,9 +445,9 @@ void ActorSprite::initTargetCursor() { for (int type = TCT_NORMAL; type < NUM_TCT; type++) { - loadTargetCursor(strprintf(targetCursor.c_str(), cursorType(type), - cursorSize(size)), targetWidths[size], - targetHeights[size], type, size); + loadTargetCursor(strprintf(targetCursorFile.c_str(), + cursorType(type), cursorSize(size)), targetWidths[size], + targetHeights[size], type, size); } } } diff --git a/src/being.cpp b/src/being.cpp index eafc647fc..5381c5924 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -496,13 +496,13 @@ void Being::setSpeech(const std::string &text, int time) // Check for links std::string::size_type start = mSpeech.find('['); - std::string::size_type end = mSpeech.find(']', start); + std::string::size_type e = mSpeech.find(']', start); - while (start != std::string::npos && end != std::string::npos) + while (start != std::string::npos && e != std::string::npos) { // Catch multiple embeds and ignore them so it doesn't crash the client. while ((mSpeech.find('[', start + 1) != std::string::npos) && - (mSpeech.find('[', start + 1) < end)) + (mSpeech.find('[', start + 1) < e)) { start = mSpeech.find('[', start + 1); } @@ -510,7 +510,7 @@ void Being::setSpeech(const std::string &text, int time) std::string::size_type position = mSpeech.find('|'); if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@') { - mSpeech.erase(end, 1); + mSpeech.erase(e, 1); mSpeech.erase(start, (position - start) + 1); } position = mSpeech.find('@'); @@ -522,7 +522,7 @@ void Being::setSpeech(const std::string &text, int time) } start = mSpeech.find('[', start + 1); - end = mSpeech.find(']', start); + e = mSpeech.find(']', start); } if (!mSpeech.empty()) @@ -1393,17 +1393,16 @@ void Being::drawSpeech(int offsetX, int offsetY) else if (mSpeechTime > 0 && (speech == NAME_IN_BUBBLE || speech == NO_NAME_IN_BUBBLE)) { - const bool showName = (speech == NAME_IN_BUBBLE); + const bool isShowName = (speech == NAME_IN_BUBBLE); delete mText; mText = 0; - mSpeechBubble->setCaption(showName ? mName : "", mTextColor); + mSpeechBubble->setCaption(isShowName ? mName : "", mTextColor); - mSpeechBubble->setText(mSpeech, showName); + mSpeechBubble->setText(mSpeech, isShowName); mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2), - py - getHeight() - - (mSpeechBubble->getHeight())); + py - getHeight() - (mSpeechBubble->getHeight())); mSpeechBubble->setVisible(true); } else if (mSpeechTime > 0 && speech == TEXT_OVERHEAD) @@ -2157,28 +2156,28 @@ void Being::recalcSpritesOrder() if (spriteToItems) { - SpriteToItemMap::const_iterator it; + SpriteToItemMap::const_iterator itr; - for (it = spriteToItems->begin(); - it != spriteToItems->end(); ++it) + for (itr = spriteToItems->begin(); + itr != spriteToItems->end(); ++it) { - int removeSprite = it->first; - const std::map &itemReplacer = it->second; + int remSprite = itr->first; + const std::map &itemReplacer = itr->second; if (itemReplacer.empty()) { - mSpriteHide[removeSprite] = 1; + mSpriteHide[remSprite] = 1; } else { std::map::const_iterator repIt - = itemReplacer.find(mSpriteIDs[removeSprite]); + = itemReplacer.find(mSpriteIDs[remSprite]); if (repIt != itemReplacer.end()) { - mSpriteHide[removeSprite] = repIt->second; + mSpriteHide[remSprite] = repIt->second; if (repIt->second != 1) { - setSprite(removeSprite, repIt->second, - mSpriteColors[removeSprite], + setSprite(remSprite, repIt->second, + mSpriteColors[remSprite], 1, false, true); } } diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 4a03370a8..94c2b88ff 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -111,18 +111,18 @@ void BuyDialog::init() mSlider->addActionListener(this); mShopItemList->addSelectionListener(this); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mScrollArea, 8, 5).setPadding(3); - place(0, 5, mDecreaseButton); - place(1, 5, mSlider, 3); - place(4, 5, mIncreaseButton); - place(5, 5, mQuantityLabel, 2); - place(7, 5, mAddMaxButton); - place(0, 6, mMoneyLabel, 8); - place(6, 7, mBuyButton); - place(7, 7, mQuitButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mScrollArea, 8, 5).setPadding(3); + placer(0, 5, mDecreaseButton); + placer(1, 5, mSlider, 3); + placer(4, 5, mIncreaseButton); + placer(5, 5, mQuantityLabel, 2); + placer(7, 5, mAddMaxButton); + placer(0, 6, mMoneyLabel, 8); + placer(6, 7, mBuyButton); + placer(7, 7, mQuitButton); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index f926a90aa..e39b5ecfc 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -141,34 +141,34 @@ CharSelectDialog::CharSelectDialog(LoginData *data): int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); - ContainerPlacer place; - place = getPlacer(0, 0); + ContainerPlacer placer; + placer = getPlacer(0, 0); - place(0, 0, mAccountNameLabel, 2); - place(0, 1, mSwitchLoginButton); + placer(0, 0, mAccountNameLabel, 2); + placer(0, 1, mSwitchLoginButton); if (optionalActions & Net::LoginHandler::Unregister) { mUnregisterButton = new Button(_("Unregister"), "unregister", this); - place(3, 1, mUnregisterButton); + placer(3, 1, mUnregisterButton); } - place(0, 2, mChangePasswordButton); + placer(0, 2, mChangePasswordButton); if (optionalActions & Net::LoginHandler::ChangeEmail) { mChangeEmailButton = new Button(_("Change Email"), "change_email", this); - place(3, 2, mChangeEmailButton); + placer(3, 2, mChangeEmailButton); } - place = getPlacer(0, 1); + placer = getPlacer(0, 1); for (int i = 0; i < static_cast(mLoginData->characterSlots); i++) { mCharacterEntries.push_back(new CharacterDisplay(this)); - place(i % SLOTS_PER_ROW, static_cast(i) / SLOTS_PER_ROW, + placer(i % SLOTS_PER_ROW, static_cast(i) / SLOTS_PER_ROW, mCharacterEntries[i]); } @@ -410,14 +410,14 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): mDelete = new Button(_("Delete"), "delete", charSelectDialog); LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mPlayerBox, 3, 5); - place(0, 5, mName, 3); - place(0, 6, mLevel, 3); - place(0, 7, mMoney, 3); - place(0, 8, mButton, 3); - place(0, 9, mDelete, 3); + ContainerPlacer placer = h.getPlacer(0, 0); + + placer(0, 0, mPlayerBox, 3, 5); + placer(0, 5, mName, 3); + placer(0, 6, mLevel, 3); + placer(0, 7, mMoney, 3); + placer(0, 8, mButton, 3); + placer(0, 9, mDelete, 3); update(); diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index 9bd3f3ab3..d85b38ccb 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -213,21 +213,21 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, minusAmountButton->setWidth(plusAmountButton->getWidth()); // Set positions - ContainerPlacer place; - place = getPlacer(0, 0); + ContainerPlacer placer; + placer = getPlacer(0, 0); int n = 0; if (mUsage == ShopBuyAdd) { - place(0, n, mItemDropDown, 8); + placer(0, n, mItemDropDown, 8); n++; } - place(1, n, minusAmountButton); - place(2, n, mItemAmountTextField, 3); - place(5, n, plusAmountButton); - place(6, n, addAllButton); + placer(1, n, minusAmountButton); + placer(2, n, mItemAmountTextField, 3); + placer(5, n, plusAmountButton); + placer(6, n, addAllButton); - place(0, n, mItemIcon, 1, 3); - place(1, n + 1, mItemAmountSlide, 7); + placer(0, n, mItemIcon, 1, 3); + placer(1, n + 1, mItemAmountSlide, 7); if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd) { @@ -236,19 +236,19 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, minusPriceButton->adjustSize(); minusPriceButton->setWidth(plusPriceButton->getWidth()); - place(1, n + 2, minusPriceButton); - place(2, n + 2, mItemPriceTextField, 3); - place(5, n + 2, plusPriceButton); - place(6, n + 2, mGPLabel); + placer(1, n + 2, minusPriceButton); + placer(2, n + 2, mItemPriceTextField, 3); + placer(5, n + 2, plusPriceButton); + placer(6, n + 2, mGPLabel); - place(1, n + 3, mItemPriceSlide, 7); - place(4, n + 5, cancelButton); - place(5, n + 5, okButton); + placer(1, n + 3, mItemPriceSlide, 7); + placer(4, n + 5, cancelButton); + placer(5, n + 5, okButton); } else { - place(4, n + 2, cancelButton); - place(5, n + 2, okButton); + placer(4, n + 2, cancelButton); + placer(5, n + 2, okButton); } reflowLayout(225, 0); diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 96848f645..e71e291d1 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -55,7 +55,7 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): addKeyListener(this); - ContainerPlacer place = getPlacer(0, 0); + ContainerPlacer placer = getPlacer(0, 0); const State state = Client::getState(); @@ -67,25 +67,25 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): state == STATE_UPDATE || state == STATE_LOAD_DATA) { - placeOption(place, mForceQuit); + placeOption(placer, mForceQuit); } else { // Only added if we are connected to an accountserver or gameserver - placeOption(place, mLogoutQuit); - placeOption(place, mSwitchAccountServer); + placeOption(placer, mLogoutQuit); + placeOption(placer, mSwitchAccountServer); // Only added if we are connected to a gameserver if (state == STATE_GAME) - placeOption(place, mSwitchCharacter); + placeOption(placer, mSwitchCharacter); } mOptions[0]->setSelected(true); - place = getPlacer(0, 1); + placer = getPlacer(0, 1); - place(1, 0, mOkButton, 1); - place(2, 0, mCancelButton, 1); + placer(1, 0, mOkButton, 1); + placer(2, 0, mCancelButton, 1); reflowLayout(200, 0); setLocationRelativeTo(getParent()); @@ -109,9 +109,9 @@ QuitDialog::~QuitDialog() mSwitchCharacter = 0; } -void QuitDialog::placeOption(ContainerPlacer &place, gcn::RadioButton *option) +void QuitDialog::placeOption(ContainerPlacer &placer, gcn::RadioButton *option) { - place(0, static_cast(mOptions.size()), option, 3); + placer(0, static_cast(mOptions.size()), option, 3); mOptions.push_back(option); } diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h index 380a85528..5456be26b 100644 --- a/src/gui/quitdialog.h +++ b/src/gui/quitdialog.h @@ -61,7 +61,7 @@ class QuitDialog : public Window, public gcn::ActionListener, void keyPressed(gcn::KeyEvent &keyEvent); private: - void placeOption(ContainerPlacer &place, gcn::RadioButton *option); + void placeOption(ContainerPlacer &placer, gcn::RadioButton *option); std::vector mOptions; gcn::RadioButton *mLogoutQuit; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index e2c718359..603810a0b 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -81,15 +81,15 @@ RegisterDialog::RegisterDialog(LoginData *data): mRegisterButton = new Button(_("Register"), "register", this); mCancelButton = new Button(_("Cancel"), "cancel", this); - ContainerPlacer place; - place = getPlacer(0, 0); - place(0, 0, userLabel); - place(0, 1, passwordLabel); - place(0, 2, confirmLabel); + ContainerPlacer placer; + placer = getPlacer(0, 0); + placer(0, 0, userLabel); + placer(0, 1, passwordLabel); + placer(0, 2, confirmLabel); - place(1, 0, mUserField, 3).setPadding(2); - place(1, 1, mPasswordField, 3).setPadding(2); - place(1, 2, mConfirmField, 3).setPadding(2); + placer(1, 0, mUserField, 3).setPadding(2); + placer(1, 1, mPasswordField, 3).setPadding(2); + placer(1, 2, mConfirmField, 3).setPadding(2); int row = 3; @@ -97,8 +97,8 @@ RegisterDialog::RegisterDialog(LoginData *data): { mMaleButton = new RadioButton(_("Male"), "sex", true); mFemaleButton = new RadioButton(_("Female"), "sex", false); - place(1, row, mMaleButton); - place(2, row, mFemaleButton); + placer(1, row, mMaleButton); + placer(2, row, mFemaleButton); row++; } @@ -107,15 +107,15 @@ RegisterDialog::RegisterDialog(LoginData *data): { gcn::Label *emailLabel = new Label(_("Email:")); mEmailField = new TextField; - place(0, row, emailLabel); - place(1, row, mEmailField, 3).setPadding(2); + placer(0, row, emailLabel); + placer(1, row, mEmailField, 3).setPadding(2); row++; } - place = getPlacer(0, 2); - place(1, 0, mRegisterButton); - place(2, 0, mCancelButton); + placer = getPlacer(0, 2); + placer(1, 0, mRegisterButton); + placer(2, 0, mCancelButton); reflowLayout(250, 0); mUserField->addKeyListener(this); diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 5cbb4167e..82b4a1829 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -107,18 +107,18 @@ void SellDialog::init() mSlider->setActionEventId("slider"); mSlider->addActionListener(this); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mScrollArea, 8, 5).setPadding(3); - place(0, 5, mDecreaseButton); - place(1, 5, mSlider, 3); - place(4, 5, mIncreaseButton); - place(5, 5, mQuantityLabel, 2); - place(7, 5, mAddMaxButton); - place(0, 6, mMoneyLabel, 8); - place(6, 7, mSellButton); - place(7, 7, mQuitButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mScrollArea, 8, 5).setPadding(3); + placer(0, 5, mDecreaseButton); + placer(1, 5, mSlider, 3); + placer(4, 5, mIncreaseButton); + placer(5, 5, mQuantityLabel, 2); + placer(7, 5, mAddMaxButton); + placer(0, 6, mMoneyLabel, 8); + placer(6, 7, mSellButton); + placer(7, 7, mQuitButton); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index bc210075a..e0f03ec60 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -687,12 +687,12 @@ void Setup_Video::action(const gcn::ActionEvent &event) } else if (id == "fpslimitcheckbox" || id == "fpslimitslider") { - int fps = static_cast(mFpsSlider->getValue()); + int tempFps = static_cast(mFpsSlider->getValue()); if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled()) - fps = 60; + tempFps = 60; else - fps = fps > 0 ? fps : 60; - mFps = mFpsCheckBox->isSelected() ? fps : 0; + tempFps = tempFps > 0 ? tempFps : 60; + mFps = mFpsCheckBox->isSelected() ? tempFps : 0; const std::string text = mFps > 0 ? toString(mFps) : _("None"); mFpsLabel->setCaption(text); @@ -701,9 +701,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) } else if (id == "altfpslimitslider") { - int fps = static_cast(mAltFpsSlider->getValue()); - fps = fps > 0 ? fps : static_cast(mAltFpsSlider->getScaleStart()); - mAltFps = fps; + int tempFps = static_cast(mAltFpsSlider->getValue()); + tempFps = tempFps > 0 ? tempFps : static_cast(mAltFpsSlider->getScaleStart()); + mAltFps = tempFps; const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None"); mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text); diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index c62c3254c..ccfed3efc 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -127,28 +127,28 @@ ShopWindow::ShopWindow(): mAnnounceLinks = new CheckBox(_("Show links in announce"), false, this, "link announce"); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mBuyLabel, 8).setPadding(3); - place(8, 0, mSellLabel, 8).setPadding(3); - place(0, 1, mBuyScrollArea, 8, 5).setPadding(3); - place(8, 1, mSellScrollArea, 8, 5).setPadding(3); - place(0, 6, mBuyAddButton); - place(1, 6, mBuyDeleteButton); - place(3, 6, mBuyAnnounceButton); - place(8, 6, mSellAddButton); - place(9, 6, mSellDeleteButton); - place(11, 6, mSellAnnounceButton); - place(0, 7, mAnnounceLinks, 8); - place(15, 7, mCloseButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mBuyLabel, 8).setPadding(3); + placer(8, 0, mSellLabel, 8).setPadding(3); + placer(0, 1, mBuyScrollArea, 8, 5).setPadding(3); + placer(8, 1, mSellScrollArea, 8, 5).setPadding(3); + placer(0, 6, mBuyAddButton); + placer(1, 6, mBuyDeleteButton); + placer(3, 6, mBuyAnnounceButton); + placer(8, 6, mSellAddButton); + placer(9, 6, mSellDeleteButton); + placer(11, 6, mSellAnnounceButton); + placer(0, 7, mAnnounceLinks, 8); + placer(15, 7, mCloseButton); if (auctionManager && auctionManager->getEnableAuctionBot()) { mBuyAuctionButton = new Button(_("Auction"), "auction buy", this); mSellAuctionButton = new Button(_("Auction"), "auction sell", this); - place(4, 6, mBuyAuctionButton); - place(12, 6, mSellAuctionButton); + placer(4, 6, mBuyAuctionButton); + placer(12, 6, mSellAuctionButton); } else { diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 1e18da57a..214cbff76 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -254,34 +254,34 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): mSchoolDropDown->setSelected(command->getSchool() - MAGIC_START_ID); mSchoolLvlField->setValue(command->getSchoolLvl()); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mIsMagic, 1); - place(2, 0, mIsOther, 1); - place(0, 1, mSymbolLabel, 2).setPadding(3); - place(2, 1, mSymbolTextField, 3).setPadding(3); - place(0, 2, mCommandLabel, 2).setPadding(3); - place(2, 2, mCommandTextField, 4).setPadding(3); - place(0, 3, mTypeLabel, 2).setPadding(3); - place(2, 3, mTypeDropDown, 3).setPadding(3); - - place(0, 4, mIconLabel, 2).setPadding(3); - place(2, 4, mIconDropDown, 3).setPadding(3); - - place(0, 5, mManaLabel, 2).setPadding(3); - place(2, 5, mManaField, 3).setPadding(3); - place(0, 6, mMagicLvlLabel, 2).setPadding(3); - place(2, 6, mMagicLvlField, 3).setPadding(3); - - place(0, 7, mSchoolLabel, 2).setPadding(3); - place(2, 7, mSchoolDropDown, 3).setPadding(3); - place(0, 8, mSchoolLvlLabel, 2).setPadding(3); - place(2, 8, mSchoolLvlField, 3).setPadding(3); - - place(0, 9, mSaveButton, 2).setPadding(3); - place(2, 9, mCancelButton, 2).setPadding(3); - place(4, 9, mDeleteButton, 2).setPadding(3); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mIsMagic, 1); + placer(2, 0, mIsOther, 1); + placer(0, 1, mSymbolLabel, 2).setPadding(3); + placer(2, 1, mSymbolTextField, 3).setPadding(3); + placer(0, 2, mCommandLabel, 2).setPadding(3); + placer(2, 2, mCommandTextField, 4).setPadding(3); + placer(0, 3, mTypeLabel, 2).setPadding(3); + placer(2, 3, mTypeDropDown, 3).setPadding(3); + + placer(0, 4, mIconLabel, 2).setPadding(3); + placer(2, 4, mIconDropDown, 3).setPadding(3); + + placer(0, 5, mManaLabel, 2).setPadding(3); + placer(2, 5, mManaField, 3).setPadding(3); + placer(0, 6, mMagicLvlLabel, 2).setPadding(3); + placer(2, 6, mMagicLvlField, 3).setPadding(3); + + placer(0, 7, mSchoolLabel, 2).setPadding(3); + placer(2, 7, mSchoolDropDown, 3).setPadding(3); + placer(0, 8, mSchoolLvlLabel, 2).setPadding(3); + placer(2, 8, mSchoolLvlField, 3).setPadding(3); + + placer(0, 9, mSaveButton, 2).setPadding(3); + placer(2, 9, mCancelButton, 2).setPadding(3); + placer(4, 9, mDeleteButton, 2).setPadding(3); setWidth(w); setHeight(h); diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index d0ae67746..3874a8301 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -118,14 +118,14 @@ TradeWindow::TradeWindow(): place(1, 0, mMoneyLabel); place(0, 1, myScroll).setPadding(3); place(1, 1, partnerScroll).setPadding(3); - ContainerPlacer place; - place = getPlacer(0, 0); - place(0, 0, mMoneyLabel2); - place(1, 0, mMoneyField, 2); - place(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT); - place = getPlacer(0, 2); - place(0, 0, mAddButton); - place(1, 0, mOkButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + placer(0, 0, mMoneyLabel2); + placer(1, 0, mMoneyField, 2); + placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT); + placer = getPlacer(0, 2); + placer(0, 0, mAddButton); + placer(1, 0, mOkButton); Layout &layout = getLayout(); layout.extend(0, 2, 2, 1); layout.setRowHeight(1, Layout::AUTO_SET); diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 4ba1c9179..d6c74cc79 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -165,14 +165,14 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mBrowserBox->setOpaque(false); mPlayButton->setEnabled(false); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mScrollArea, 5, 3).setPadding(3); - place(0, 3, mLabel, 5); - place(0, 4, mProgressBar, 5); - place(3, 5, mCancelButton); - place(4, 5, mPlayButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mScrollArea, 5, 3).setPadding(3); + placer(0, 3, mLabel, 5); + placer(0, 4, mProgressBar, 5); + placer(3, 5, mCancelButton); + placer(4, 5, mPlayButton); reflowLayout(450, 400); diff --git a/src/guild.cpp b/src/guild.cpp index 234c7d32f..a2d9149eb 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -170,9 +170,9 @@ void Guild::removeMember(GuildMember *member) (*itr)->mCharId == member->mCharId && (*itr)->getName() == member->getName()) { - GuildMember *member = *itr; + GuildMember *m = *itr; mMembers.erase(itr); - delete member; + delete m; return; } ++itr; diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 5bfeefdb6..8f177f906 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -190,12 +190,11 @@ std::string MessageIn::readString(int length) char const *stringEnd = static_cast(memchr(stringBeg, '\0', length)); - std::string readString(stringBeg, - stringEnd ? stringEnd - stringBeg : length); + std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : length); mPos += length; PacketCounters::incInBytes(length); - DEBUGLOG("readString: " + readString); - return readString; + DEBUGLOG("readString: " + str); + return str; } std::string MessageIn::readRawString(int length) @@ -215,12 +214,11 @@ std::string MessageIn::readRawString(int length) char const *stringBeg = mData + mPos; char const *stringEnd = static_cast(memchr(stringBeg, '\0', length)); - std::string readString(stringBeg, - stringEnd ? stringEnd - stringBeg : length); + std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : length); mPos += length; PacketCounters::incInBytes(length); - DEBUGLOG("readString: " + readString); + DEBUGLOG("readString: " + str); if (stringEnd) { @@ -234,11 +232,11 @@ std::string MessageIn::readRawString(int length) { DEBUGLOG("readString2: " + hiddenPart); - return readString + "|" + hiddenPart; + return str + "|" + hiddenPart; } } - return readString; + return str; } } diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index fd1f07e16..9cad0864f 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -566,9 +566,9 @@ std::list ParticleEmitter::createParticles(int tick) newParticle->setFollow(mParticleFollow); newParticle->setDestination(mParticleTarget, - mParticleAcceleration.value(tick), - mParticleMomentum.value(tick) - ); + mParticleAcceleration.value(tick), + mParticleMomentum.value(tick)); + newParticle->setDieDistance(mParticleDieDistance.value(tick)); newParticle->setLifetime(mParticleLifetime.value(tick)); @@ -577,16 +577,14 @@ std::list ParticleEmitter::createParticles(int tick) newParticle->setAlpha(mParticleAlpha.value(tick)); for (std::list::const_iterator - i = mParticleChildEmitters.begin(); - i != mParticleChildEmitters.end(); ++i) + it = mParticleChildEmitters.begin(); + it != mParticleChildEmitters.end(); ++it) { - newParticle->addEmitter(new ParticleEmitter(*i)); + newParticle->addEmitter(new ParticleEmitter(*it)); } if (!mDeathEffect.empty()) - { newParticle->setDeathEffect(mDeathEffect, mDeathEffectConditions); - } newParticles.push_back(newParticle); } diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 8beea420d..4aa7515b1 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -94,10 +94,10 @@ void BeingInfo::addSound(SoundEvent event, const std::string &filename) const std::string &BeingInfo::getSound(SoundEvent event) const { - static std::string empty(""); + static std::string emptySound(""); SoundEvents::const_iterator i = mSounds.find(event); - return (i == mSounds.end() || !i->second) ? empty : + return (i == mSounds.end() || !i->second) ? emptySound : i->second->at(rand() % i->second->size()); } diff --git a/src/resources/image.cpp b/src/resources/image.cpp index e28cb2bc5..8f5ee1d2d 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -49,12 +49,12 @@ int Image::mTextureSize = 0; bool Image::mEnableAlphaCache = false; bool Image::mEnableAlpha = true; -Image::Image(SDL_Surface *image, bool hasAlphaChannel, Uint8 *alphaChannel): +Image::Image(SDL_Surface *image, bool hasAlphaChannel0, Uint8 *alphaChannel): mAlpha(1.0f), - mHasAlphaChannel(hasAlphaChannel), + mHasAlphaChannel(hasAlphaChannel0), mSDLSurface(image), mAlphaChannel(alphaChannel), - mIsAlphaVisible(hasAlphaChannel), + mIsAlphaVisible(hasAlphaChannel0), mIsAlphaCalculated(false) { #ifdef USE_OPENGL diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 89df407a6..9ff80de22 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -361,7 +361,7 @@ void ItemDB::load() mItemInfos[id] = itemInfo; if (!name.empty()) { - std::string temp = normalize(name); + temp = normalize(name); NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp); if (itr == mNamedItemInfos.end()) -- cgit v1.2.3-70-g09d2 From 13670eefeb4b256c20b603a845eb89f5221a32e5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 10 Sep 2011 15:48:22 +0300 Subject: Change empty strings initializations. --- src/being.cpp | 2 +- src/commandhandler.cpp | 4 +-- src/configuration.cpp | 2 +- src/gui/chatwindow.cpp | 2 +- src/gui/logindialog.cpp | 4 +-- src/gui/minimap.cpp | 2 +- src/gui/npcdialog.cpp | 4 +-- src/gui/setup_video.cpp | 2 +- src/gui/widgets/chattab.cpp | 2 +- src/map.cpp | 2 +- src/net/ea/gui/guildtab.cpp | 2 +- src/net/ea/partyhandler.cpp | 2 +- src/net/manaserv/charhandler.cpp | 4 +-- src/net/manaserv/generalhandler.cpp | 2 +- src/resources/iteminfo.cpp | 2 +- src/resources/spritedef.h | 2 +- src/spellmanager.cpp | 4 +-- src/textcommand.cpp | 62 ++++++++++++++++++------------------- src/utils/sha256.cpp | 2 +- src/utils/stringutils.cpp | 4 +-- 20 files changed, 55 insertions(+), 57 deletions(-) (limited to 'src/resources') diff --git a/src/being.cpp b/src/being.cpp index 883bde321..da83f1f73 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1277,7 +1277,7 @@ void Being::logic() case ATTACK: { - std::string particleEffect = ""; + std::string particleEffect(""); if (!mActionTime) break; diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index d16a7db27..5de5eb2cf 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -355,8 +355,8 @@ void CommandHandler::handleWho(const std::string &args A_UNUSED, void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) { - std::string recvnick = ""; - std::string msg = ""; + std::string recvnick(""); + std::string msg(""); if (args.substr(0, 1) == "\"") { diff --git a/src/configuration.cpp b/src/configuration.cpp index a6ef27815..94c0dce37 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -262,7 +262,7 @@ int Configuration::resetIntValue(const std::string &key) std::string Configuration::getStringValue(const std::string &key) const { GETLOG(); - std::string defaultValue = ""; + std::string defaultValue(""); Options::const_iterator iter = mOptions.find(key); if (iter == mOptions.end()) { diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index f3e4b88b8..2bada256c 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1074,7 +1074,7 @@ std::string ChatWindow::addColors(std::string &msg) return msg; } - std::string newMsg = ""; + std::string newMsg(""); int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8}; // rainbow diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index adf499f75..26248059c 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -50,8 +50,8 @@ static const int LOGIN_DIALOG_WIDTH = 300; static const int LOGIN_DIALOG_HEIGHT = 140; static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70; -std::string LoginDialog::savedPassword = ""; -std::string LoginDialog::savedPasswordKey = ""; +std::string LoginDialog::savedPassword(""); +std::string LoginDialog::savedPasswordKey(""); const char *UPDATE_TYPE_TEXT[3] = diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index a16da2b65..70bbc1dad 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -89,7 +89,7 @@ Minimap::~Minimap() void Minimap::setMap(Map *map) { - std::string caption = ""; + std::string caption(""); std::string minimapName; if (map) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index d941153b7..3956b47ac 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -228,8 +228,8 @@ void NpcDialog::action(const gcn::ActionEvent &event) } else if (mActionState == NPC_ACTION_INPUT) { - std::string printText = ""; // Text that will get printed - // in the textbox + std::string printText(""); // Text that will get printed + // in the textbox if (mInputState == NPC_INPUT_LIST) { diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index e9811a920..d3c1163dc 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -179,7 +179,7 @@ void ModeListModel::addCustomMode(std::string mode) int ModeListModel::getIndexOf(const std::string &widthXHeightMode) { - std::string currentMode = ""; + std::string currentMode(""); for (int i = 0; i < getNumberOfElements(); i++) { currentMode = getElementAt(i); diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 4f358c8e7..485e96e74 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -337,7 +337,7 @@ void ChatTab::chatInput(const std::string &message) start = msg.find('[', start + 1); } - std::string temp = ""; + std::string temp(""); if (start + 1 < msg.length() && end < msg.length() && end > start + 1) { diff --git a/src/map.cpp b/src/map.cpp index 86d1171f0..3e83f2e6c 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2217,7 +2217,7 @@ MapItem::~MapItem() void MapItem::setType(int type) { - std::string name = ""; + std::string name(""); mType = type; if (mImage) mImage->decRef(); diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index ab030be83..9836f5fa9 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -101,7 +101,7 @@ bool GuildTab::handleCommand(const std::string &type, const std::string &args) else if (type == "notice" && taGuild) { std::string str1 = args.substr(0, 60); - std::string str2 = ""; + std::string str2(""); if (args.size() > 60) str2 = args.substr(60); Net::getGuildHandler()->changeNotice(taGuild->getId(), str1, str2); diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index bd6f19d97..e006b9c71 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -203,7 +203,7 @@ void PartyHandler::processPartyInvited(Net::MessageIn &msg) { int id = msg.readInt32(); std::string partyName = msg.readString(24); - std::string nick = ""; + std::string nick(""); Being *being; if (actorSpriteManager) diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index 3b2306feb..42db6e621 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -138,7 +138,7 @@ void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg) if (errMsg != ERRMSG_OK) { // Character creation failed - std::string errorMessage = ""; + std::string errorMessage(""); switch (errMsg) { case ERRMSG_NO_LOGIN: @@ -212,7 +212,7 @@ void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg) else { // Character deletion failed - std::string errorMessage = ""; + std::string errorMessage(""); switch (errMsg) { case ERRMSG_NO_LOGIN: diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 9e32f139d..2eea6cdf6 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -64,7 +64,7 @@ namespace ManaServ Connection *accountServerConnection = 0; Connection *chatServerConnection = 0; Connection *gameServerConnection = 0; -std::string netToken = ""; +std::string netToken(""); ServerInfo gameServer; ServerInfo chatServer; diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 75e6e1d8c..a5b81081c 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -108,7 +108,7 @@ const std::string &ItemInfo::getSprite(Gender gender) const } else { - static const std::string empty = ""; + static const std::string empty(""); std::map::const_iterator i = mAnimationFiles.find(gender); diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index ccad62b1b..b2939fca1 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -86,7 +86,7 @@ namespace SpriteAction static const std::string CAST_MAGIC = "magic"; static const std::string USE_ITEM = "item"; static const std::string SPAWN = "spawn"; - static const std::string INVALID = ""; + static const std::string INVALID(""); } enum SpriteDirection diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index fcdf94039..9f777f9e4 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -184,8 +184,8 @@ std::string SpellManager::parseCommand(std::string command, if (!player_node) return command; - std::string name = ""; - std::string id = ""; + std::string name(""); + std::string id(""); std::string name2; if (target) diff --git a/src/textcommand.cpp b/src/textcommand.cpp index 665668c7e..33dff85aa 100644 --- a/src/textcommand.cpp +++ b/src/textcommand.cpp @@ -35,18 +35,18 @@ TextCommand::TextCommand(unsigned int id, std::string symbol, std::string icon, unsigned int basicLvl, MagicSchool school, unsigned int schoolLvl, int mana) : + mCommand(command), + mSymbol(symbol), + mTargetType(type), + mIcon(icon), + mId(id), + mMana(mana), + mSchool(school), + mBaseLvl(basicLvl), + mSchoolLvl(schoolLvl), + mCommandType(TEXT_COMMAND_MAGIC), mImage(0) { - mId = id; - mCommand = command; - mSymbol = symbol; - mTargetType = type; - mIcon = icon; - mBaseLvl = basicLvl; - mSchool = school; - mSchoolLvl = schoolLvl; - mMana = mana; - mCommandType = TEXT_COMMAND_MAGIC; loadImage(); } @@ -54,36 +54,34 @@ TextCommand::TextCommand(unsigned int id, std::string symbol, TextCommand::TextCommand(unsigned int id, std::string symbol, std::string command, SpellTarget type, std::string icon) : + mCommand(command), + mSymbol(symbol), + mTargetType(type), + mIcon(icon), + mId(id), + mMana(0), + mSchool(SKILL_MAGIC), + mBaseLvl(0), + mSchoolLvl(0), + mCommandType(TEXT_COMMAND_TEXT), mImage(0) { - mId = id; - mCommand = command; - mSymbol = symbol; - mTargetType = type; - mIcon = icon; - mCommandType = TEXT_COMMAND_TEXT; - mBaseLvl = 0; - mSchool = SKILL_MAGIC; - mSchoolLvl = 0; - mMana = 0; - mCommandType = TEXT_COMMAND_TEXT; loadImage(); } TextCommand::TextCommand(unsigned int id) : + mCommand(""), + mSymbol(""), + mTargetType(NOTARGET), + mIcon(""), + mId(id), + mMana(0), + mSchool(SKILL_MAGIC), + mBaseLvl(0), + mSchoolLvl(0), + mCommandType(TEXT_COMMAND_TEXT), mImage(0) { - mId = id; - mCommand = ""; - mSymbol = ""; - mTargetType = NOTARGET; - mIcon = ""; - mCommandType = TEXT_COMMAND_TEXT; - mBaseLvl = 0; - mSchool = SKILL_MAGIC; - mSchoolLvl = 0; - mMana = 0; - mCommandType = TEXT_COMMAND_TEXT; loadImage(); } diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index 5d3e4c1d2..1e7143300 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -283,7 +283,7 @@ std::string SHA256Hash(const char *src, int len) SHA256Final(&ctx, bytehash); // Convert it to hex const char* hxc = "0123456789abcdef"; - std::string hash = ""; + std::string hash(""); for (int i = 0; i < SHA256_DIGEST_SIZE; i++) { hash += hxc[bytehash[i] / 16]; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index efe5f9efb..6c50d4019 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -465,7 +465,7 @@ std::string combineDye2(std::string file, std::string dye) if (pos != std::string::npos) { std::string dye1 = file.substr(pos + 1); - std::string str = ""; + std::string str(""); file = file.substr(0, pos); std::list list1 = splitToStringList(dye1, ';'); std::list list2 = splitToStringList(dye, ';'); @@ -505,7 +505,7 @@ std::vector getLang() std::string packList(std::list &list) { std::list::const_iterator i = list.begin(); - std::string str = ""; + std::string str(""); while (i != list.end()) { str = str + (*i) + "|"; -- cgit v1.2.3-70-g09d2 From c0a5fffb45f849e224750f27fa8c3be5ac447ad6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 14 Sep 2011 01:46:13 +0300 Subject: Add more checks. Fix error in event.cpp from last commits. Improve party members sorting. --- src/event.cpp | 2 +- src/mumblemanager.cpp | 2 +- src/openglgraphics.cpp | 3 +++ src/particle.cpp | 10 +++++---- src/particle.h | 2 ++ src/particlecontainer.cpp | 1 - src/particleemitter.cpp | 9 ++------ src/particleemitterprop.h | 2 ++ src/party.cpp | 52 ++++++++++++++++++++++++++++------------------ src/playerrelations.cpp | 11 ++++++---- src/resources/animation.h | 6 ++++++ src/rotationalparticle.cpp | 5 ++++- src/shopitem.cpp | 4 ++-- 13 files changed, 68 insertions(+), 41 deletions(-) (limited to 'src/resources') diff --git a/src/event.cpp b/src/event.cpp index 6913e8660..7eaf8aea6 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -78,7 +78,7 @@ const std::string &Event::getString(const std::string &key) if (it == mData.end()) throw BAD_KEY; - if (!! it->second || it->second->getType() != VariableData::DATA_STRING) + if (!it->second || it->second->getType() != VariableData::DATA_STRING) throw BAD_VALUE; return static_cast(it->second)->getData(); diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index bace077cd..2b3f15afa 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -188,7 +188,7 @@ void MumbleManager::setAction(int action) case 3: /* SIT */ mLinkedMemCache.fAvatarPosition[1] = 1.0f; break; - case 4: /* DEAD */ + case 4: /* DEAD */ default: mLinkedMemCache.fAvatarPosition[1] = 0.0f; break; diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 332f79823..03d38e7e2 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -1023,6 +1023,9 @@ SDL_Surface* OpenGLGraphics::getScreenshot() w, h, 24, 0xff0000, 0x00ff00, 0x0000ff, 0x000000); + if (!screenshot) + return 0; + if (SDL_MUSTLOCK(screenshot)) SDL_LockSurface(screenshot); diff --git a/src/particle.cpp b/src/particle.cpp index 7d7a73e9a..874e49d9a 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -95,6 +95,8 @@ void Particle::setupEngine() Particle::maxCount = config.getIntValue("particleMaxCount"); Particle::fastPhysics = config.getIntValue("particleFastPhysics"); Particle::emitterSkip = config.getIntValue("particleEmitterSkip") + 1; + if (!Particle::emitterSkip) + Particle::emitterSkip = 1; Particle::enabled = config.getBoolValue("particleeffects"); disableAutoDelete(); logger->log1("Particle engine set up"); @@ -200,11 +202,11 @@ bool Particle::update() // Update child emitters if ((mLifetimePast - 1) % Particle::emitterSkip == 0) { - for (EmitterIterator e = mChildEmitters.begin(); + for (EmitterConstIterator e = mChildEmitters.begin(); e != mChildEmitters.end(); ++e) { Particles newParticles = (*e)->createParticles(mLifetimePast); - for (ParticleIterator p = newParticles.begin(); + for (ParticleConstIterator p = newParticles.begin(); p != newParticles.end(); ++p) { (*p)->moveBy(mPos); @@ -258,7 +260,7 @@ bool Particle::update() void Particle::moveBy(const Vector &change) { mPos += change; - for (ParticleIterator p = mChildParticles.begin(); + for (ParticleConstIterator p = mChildParticles.begin(); p != mChildParticles.end(); ++p) { if ((*p)->doesFollow()) @@ -451,7 +453,7 @@ void Particle::adjustEmitterSize(int w, int h) { if (mAllowSizeAdjust) { - for (EmitterIterator e = mChildEmitters.begin(); + for (EmitterConstIterator e = mChildEmitters.begin(); e != mChildEmitters.end(); ++e) { (*e)->adjustSize(w, h); diff --git a/src/particle.h b/src/particle.h index c2b33cc52..c360a5e94 100644 --- a/src/particle.h +++ b/src/particle.h @@ -42,8 +42,10 @@ class ParticleEmitter; typedef std::list Particles; typedef Particles::iterator ParticleIterator; +typedef Particles::const_iterator ParticleConstIterator; typedef std::list Emitters; typedef Emitters::iterator EmitterIterator; +typedef Emitters::const_iterator EmitterConstIterator; /** * A particle spawned by a ParticleEmitter. diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index 686390474..5f5b1b257 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -187,4 +187,3 @@ void ParticleVector::moveTo(float x, float y) } } } - diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index 9cad0864f..1add452a0 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -225,11 +225,6 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, int offsetX = XML::getProperty(frameNode, "offsetX", 0); int offsetY = XML::getProperty(frameNode, "offsetY", 0); int rand = XML::getProperty(frameNode, "rand", 100); - if (!imageset) - { - logger->log1("Error: no valid imageset"); - continue; - } offsetY -= imageset->getHeight() - 32; offsetX -= imageset->getWidth() / 2 - 16; @@ -532,12 +527,12 @@ std::list ParticleEmitter::createParticles(int tick) newParticle = new ImageParticle(mMap, mParticleImage); } - else if (mParticleRotation.getLength() > 0) + else if (!mParticleRotation.empty()) { Animation *newAnimation = new Animation(mParticleRotation); newParticle = new RotationalParticle(mMap, newAnimation); } - else if (mParticleAnimation.getLength() > 0) + else if (!mParticleAnimation.empty()) { Animation *newAnimation = new Animation(mParticleAnimation); newParticle = new AnimationParticle(mMap, newAnimation); diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h index 5b0b22e4f..76c855e4f 100644 --- a/src/particleemitterprop.h +++ b/src/particleemitterprop.h @@ -60,6 +60,8 @@ template struct ParticleEmitterProp changeFunc = func; changeAmplitude = amplitude; changePeriod = period; + if (!changePeriod) + changePeriod = 1; changePhase = phase; } diff --git a/src/party.cpp b/src/party.cpp index 9da1a235d..f561ca49f 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -25,6 +25,8 @@ #include "debug.h" +#include "utils/stringutils.h" + class SortPartyFunctor { public: @@ -37,7 +39,15 @@ class SortPartyFunctor if (p2->getLeader()) return false; - return p1->getName() < p2->getName(); + if (p1->getName() != p2->getName()) + { + std::string s1 = p1->getName(); + std::string s2 = p2->getName(); + toLower(s1); + toLower(s2); + return s1 < s2; + } + return false; } } partySorter; @@ -94,7 +104,7 @@ PartyMember *Party::getMember(const std::string &name) const itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->getName() == name) + if ((*itr) && (*itr)->getName() == name) return (*itr); ++itr; @@ -116,7 +126,7 @@ void Party::removeMember(PartyMember *member) itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == member->mId && + if ((*itr) && (*itr)->mId == member->mId && (*itr)->getName() == member->getName()) { PartyMember *m = (*itr); @@ -140,7 +150,7 @@ void Party::removeMember(int id) itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == id) + if ((*itr) && (*itr)->mId == id) { PartyMember *member = (*itr); mMembers.erase(itr); @@ -163,7 +173,7 @@ void Party::removeMember(const std::string &name) itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->getName() == name) + if ((*itr) && (*itr)->getName() == name) { PartyMember *member = (*itr); mMembers.erase(itr); @@ -213,11 +223,11 @@ bool Party::isMember(PartyMember *member) const if (member->mParty > 0 && member->mParty != this) return false; - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == member->mId && + if ((*itr) && (*itr)->mId == member->mId && (*itr)->getName() == member->getName()) { return true; @@ -230,11 +240,11 @@ bool Party::isMember(PartyMember *member) const bool Party::isMember(int id) const { - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->mId == id) + if ((*itr) && (*itr)->mId == id) return true; ++itr; } @@ -244,11 +254,11 @@ bool Party::isMember(int id) const bool Party::isMember(const std::string &name) const { - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { - if ((*itr)->getName() == name) + if ((*itr) && (*itr)->getName() == name) return true; ++itr; } @@ -259,11 +269,12 @@ bool Party::isMember(const std::string &name) const void Party::getNames(std::vector &names) const { names.clear(); - MemberList::const_iterator it = mMembers.begin(), - it_end = mMembers.end(); + MemberList::const_iterator it = mMembers.begin(); + MemberList::const_iterator it_end = mMembers.end(); while (it != it_end) { - names.push_back((*it)->getName()); + if (*it) + names.push_back((*it)->getName()); ++it; } } @@ -271,11 +282,12 @@ void Party::getNames(std::vector &names) const void Party::getNamesSet(std::set &names) const { names.clear(); - MemberList::const_iterator it = mMembers.begin(), - it_end = mMembers.end(); + MemberList::const_iterator it = mMembers.begin(); + MemberList::const_iterator it_end = mMembers.end(); while (it != it_end) { - names.insert((*it)->getName()); + if (*it) + names.insert((*it)->getName()); ++it; } } diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 8af37aa7d..00a9d1cad 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -67,7 +67,7 @@ class PlayerConfSerialiser : std::pair value, ConfigurationObject *cobj) { - if (!value.second) + if (!cobj || !value.second) return NULL; cobj->setValue(NAME, value.first); cobj->setValue(RELATION, toString( @@ -80,6 +80,8 @@ class PlayerConfSerialiser : readConfigItem(ConfigurationObject *cobj, std::map *container) { + if (!cobj) + return container; std::string name = cobj->getValue(NAME, ""); if (name.empty()) return container; @@ -154,6 +156,9 @@ int PlayerRelationsManager::getPlayerIgnoreStrategyIndex( std::vector *strategies = getPlayerIgnoreStrategies(); + if (!strategies) + return -1; + for (unsigned int i = 0; i < strategies->size(); i++) { if ((*strategies)[i]->mShortName == name) @@ -231,8 +236,6 @@ void PlayerRelationsManager::store() void PlayerRelationsManager::signalUpdate(const std::string &name) { -// store(); - for (std::list::const_iterator it = mListeners.begin(); it != mListeners.end(); ++it) { @@ -322,7 +325,7 @@ void PlayerRelationsManager::setRelation(const std::string &player_name, PlayerRelation::Relation relation) { PlayerRelation *r = mRelations[player_name]; - if (r == NULL) + if (!r) mRelations[player_name] = new PlayerRelation(relation); else r->mRelation = relation; diff --git a/src/resources/animation.h b/src/resources/animation.h index 0c6f45681..19b17eb54 100644 --- a/src/resources/animation.h +++ b/src/resources/animation.h @@ -84,6 +84,12 @@ class Animation unsigned int getLength() const { return static_cast(mFrames.size()); } + /** + * Check for empty animation. + */ + bool empty() const + { return mFrames.empty(); } + /** * Returns the duration of this animation. */ diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp index cd16ddf63..60d818cd9 100644 --- a/src/rotationalparticle.cpp +++ b/src/rotationalparticle.cpp @@ -55,10 +55,13 @@ bool RotationalParticle::update() // TODO: cache velocities to avoid spamming atan2() + int size = mAnimation->getLength(); + if (!size) + return false; + float rad = static_cast(atan2(mVelocity.x, mVelocity.y)); if (rad < 0) rad = static_cast(PI + (PI + rad)); - int size = mAnimation->getLength(); float range = static_cast(PI / size); diff --git a/src/shopitem.cpp b/src/shopitem.cpp index 5000ceb4d..3a9b63ca6 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -40,12 +40,12 @@ ShopItem::ShopItem(int inventoryIndex, int id, unsigned char color, if (serverVersion > 0) { mDisplayName = getInfo().getName(color) + " (" - + Units::formatCurrency(mPrice).c_str() + ") "; + + Units::formatCurrency(mPrice).c_str() + ") "; } else { mDisplayName = getInfo().getName() + " (" - + Units::formatCurrency(mPrice).c_str() + ") "; + + Units::formatCurrency(mPrice).c_str() + ") "; } if (quantity > 0) mDisplayName += "[" + toString(quantity) + "]"; -- cgit v1.2.3-70-g09d2 From 0abd36c63a6ffd16e998fe1552f822ca351ef2b2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 14 Sep 2011 15:36:47 +0300 Subject: Replace some size() calls to empty(). --- src/actorsprite.cpp | 2 +- src/compoundsprite.h | 3 +++ src/gui/serverdialog.cpp | 2 +- src/resources/iteminfo.cpp | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/resources') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index e90536b2d..6155bb7af 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -331,7 +331,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, } // Ensure that something is shown, if desired - if (size() == 0 && forceDisplay) + if (empty() && forceDisplay) { if (display.image.empty()) { diff --git a/src/compoundsprite.h b/src/compoundsprite.h index 2211cb80c..d1b019057 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -85,6 +85,9 @@ public: size_t size() const { return std::vector::size(); } + bool empty() const + { return std::vector::empty(); } + void addSprite(Sprite* sprite); void setSprite(int layer, Sprite* sprite); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 1b0dd22aa..5a00d4a76 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -367,7 +367,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): loadServers(false); - if (mServers.size() == 0) + if (mServers.empty()) downloadServerList(); } diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index a5b81081c..5b07724a1 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -139,7 +139,7 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const if (i == mSounds.end()) return empty; - return i->second.size() > 0 ? i->second[rand() % i->second.size()] : empty; + return (!i->second.empty()) ? i->second[rand() % i->second.size()] : empty; } std::map *ItemInfo::addReplaceSprite(int sprite, int direction) @@ -222,7 +222,7 @@ const std::string ItemInfo::replaceColors(std::string str, } str = replaceAll(str, "%color%", name); - if (name.size() > 0) + if (!name.empty()) name[0] = static_cast(toupper(name[0])); return replaceAll(str, "%Color%", name); -- cgit v1.2.3-70-g09d2