diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-29 23:40:41 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-08-29 23:40:41 +0300 |
commit | 1feb7f7edc5f8f383e594b256ef4cab0fae75b99 (patch) | |
tree | 68fe26fdd1ef25645deef894c296b6fbc80b0e13 /src | |
parent | 41044107cc0a17125ebd806c9934b6eb636dafe6 (diff) | |
download | ManaVerse-1feb7f7edc5f8f383e594b256ef4cab0fae75b99.tar.gz ManaVerse-1feb7f7edc5f8f383e594b256ef4cab0fae75b99.tar.bz2 ManaVerse-1feb7f7edc5f8f383e594b256ef4cab0fae75b99.tar.xz ManaVerse-1feb7f7edc5f8f383e594b256ef4cab0fae75b99.zip |
Add const to more classes.
Diffstat (limited to 'src')
41 files changed, 361 insertions, 321 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 5809eeec7..3f8215eda 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -816,14 +816,16 @@ void ActorSpriteManager::clear() Being *ActorSpriteManager::findNearestLivingBeing(const int x, const int y, const int maxTileDist, const ActorSprite::Type type, - Being *const excluded) const + const Being *const + excluded) const { const int maxDist = maxTileDist * 32; return findNearestLivingBeing(nullptr, maxDist, type, x, y, excluded); } -Being *ActorSpriteManager::findNearestLivingBeing(Being *const aroundBeing, +Being *ActorSpriteManager::findNearestLivingBeing(const Being *const + aroundBeing, const int maxDist, const Being::Type type) const { @@ -834,11 +836,12 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *const aroundBeing, aroundBeing->getTileX(), aroundBeing->getTileY(), aroundBeing); } -Being *ActorSpriteManager::findNearestLivingBeing(Being *const aroundBeing, - int maxDist, +Being *ActorSpriteManager::findNearestLivingBeing(const Being *const + aroundBeing, int maxDist, const Being::Type type, const int x, const int y, - Being *const excluded) const + const Being *const + excluded) const { if (!aroundBeing || !player_node) return nullptr; diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h index 1272d1e86..a3f5b3941 100644 --- a/src/actorspritemanager.h +++ b/src/actorspritemanager.h @@ -126,7 +126,8 @@ class ActorSpriteManager: public ConfigListener int maxTileDist, const ActorSprite::Type type = Being::UNKNOWN, - Being *const excluded = nullptr) const; + const Being *const + excluded = nullptr) const; /** * Returns a being nearest to another being. @@ -136,7 +137,7 @@ class ActorSpriteManager: public ConfigListener * larger, no being is returned. * @param type The type of being to look for. */ - Being *findNearestLivingBeing(Being *const aroundBeing, + Being *findNearestLivingBeing(const Being *const aroundBeing, const int maxTileDist, const ActorSprite::Type type = Being::UNKNOWN @@ -298,9 +299,12 @@ class ActorSpriteManager: public ConfigListener const Being *const excluded = nullptr, const int maxCost = 20) const; - Being *findNearestLivingBeing(Being *aroundBeing, int maxdist, - Being::Type type, int x, int y, - Being *excluded = nullptr) const; + Being *findNearestLivingBeing(const Being *const aroundBeing, + const int maxdist, + const Being::Type type, + const int x, const int y, + const Being *const + excluded = nullptr) const; void loadAttackList(); void storeAttackList(); diff --git a/src/client.cpp b/src/client.cpp index fe84a765c..4e2cbcd7f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2428,7 +2428,7 @@ const std::string Client::getNpcsDirectory() return instance()->mNpcsDir; } -void Client::setGuiAlpha(float n) +void Client::setGuiAlpha(const float n) { instance()->mGuiAlpha = n; } diff --git a/src/client.h b/src/client.h index 82a5a3983..e311cdecb 100644 --- a/src/client.h +++ b/src/client.h @@ -270,7 +270,7 @@ public: const bool always = false) { instance()->resizeVideo(width, height, always); } - static void setGuiAlpha(float n); + static void setGuiAlpha(const float n); static float getGuiAlpha(); diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 12baf0af0..37ee853b0 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -1063,11 +1063,11 @@ void CommandHandler::handleCacheInfo(const std::string &args A_UNUSED, if (!chatWindow || !debugChatTab) return; - SDLFont *font = dynamic_cast<SDLFont *>(chatWindow->getFont()); + SDLFont *const font = dynamic_cast<SDLFont *const>(chatWindow->getFont()); if (!font) return; - std::list<SDLTextChunk> *cache = font->getCache(); + const std::list<SDLTextChunk> *const cache = font->getCache(); if (!cache) return; @@ -1180,7 +1180,7 @@ void CommandHandler::outStringNormal(ChatTab *const tab, { if (!player_node) return; - const Guild *guild = player_node->getGuild(); + const Guild *const guild = player_node->getGuild(); if (guild) { if (guild->getServerGuild()) @@ -1192,7 +1192,8 @@ void CommandHandler::outStringNormal(ChatTab *const tab, } case ChatTab::TAB_WHISPER: { - WhisperTab *whisper = static_cast<WhisperTab*>(tab); + const WhisperTab *const whisper + = static_cast<WhisperTab *const>(tab); tab->chatLog(player_node->getName(), str); Net::getChatHandler()->privateMessage(whisper->getNick(), str); break; @@ -1320,7 +1321,7 @@ void CommandHandler::replaceVars(std::string &str) if (str.find("<PLAYER>") != std::string::npos) { - Being *target = player_node->getTarget(); + const Being *target = player_node->getTarget(); if (!target || target->getType() != ActorSprite::PLAYER) { target = actorSpriteManager->findNearestLivingBeing( @@ -1333,7 +1334,7 @@ void CommandHandler::replaceVars(std::string &str) } if (str.find("<MONSTER>") != std::string::npos) { - Being *target = player_node->getTarget(); + const Being *target = player_node->getTarget(); if (!target || target->getType() != ActorSprite::MONSTER) { target = actorSpriteManager->findNearestLivingBeing( @@ -1366,7 +1367,7 @@ void CommandHandler::replaceVars(std::string &str) { StringVect names; std::string newStr = ""; - Party *party = nullptr; + const Party *party = nullptr; if (player_node->isInParty() && (party = player_node->getParty())) { party->getNames(names); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index fcef420bd..a5849315b 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -561,7 +561,7 @@ void InventoryWindow::updateButtons(const Item *item) if (!mInventory || !mInventory->isMainInventory()) return; - Item *const selectedItem = mItems->getSelectedItem(); + const Item *const selectedItem = mItems->getSelectedItem(); if (item && selectedItem != item) return; diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 8c9fe8757..f5c73fe88 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -387,7 +387,7 @@ void KillStats::jackoDead(const int id) } } -void KillStats::jackoAlive(int id) +void KillStats::jackoAlive(const int id) { if (!mIsJackoAlive) { diff --git a/src/gui/killstats.h b/src/gui/killstats.h index fdc932735..6587ca462 100644 --- a/src/gui/killstats.h +++ b/src/gui/killstats.h @@ -79,7 +79,7 @@ class KillStats : public Window, private gcn::ActionListener, public Listener void jackoDead(const int id); - void jackoAlive(int id); + void jackoAlive(const int id); void processEvent(Channels channel A_UNUSED, const DepricatedEvent &event); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 3095e7ce8..cf66fae76 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -624,7 +624,7 @@ void OutfitWindow::unwearAwayOutfit() wearOutfit(OUTFITS_COUNT); } -void OutfitWindow::setItemSelected(Item *item) +void OutfitWindow::setItemSelected(const Item *const item) { if (item) { diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 3d7bb33bc..19ad53a6f 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -70,7 +70,7 @@ class OutfitWindow : public Window, private gcn::ActionListener void setItemSelected(const int itemId) { mItemSelected = itemId; } - void setItemSelected(Item *item); + void setItemSelected(const Item *const item); bool isItemSelected() const { return mItemSelected > 0; } diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 0f32f34a8..8d0ce5ea1 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -58,7 +58,7 @@ class SortFriendsFunctor { public: - bool operator() (Avatar* m1, Avatar* m2) + bool operator() (const Avatar *const m1, const Avatar *const m2) const { if (!m1 || !m2) return false; @@ -92,7 +92,7 @@ public: virtual void resetDamage(std::string name) = 0; - virtual void selectIndex(unsigned num A_UNUSED) + virtual void selectIndex(const unsigned num A_UNUSED) { } protected: @@ -132,7 +132,7 @@ protected: class SocialGuildTab : public SocialTab, public gcn::ActionListener { public: - SocialGuildTab(Guild *guild, bool showBackground): + SocialGuildTab(Guild *const guild, const bool showBackground): mGuild(guild) { setCaption(_("Guild")); @@ -231,7 +231,7 @@ private: class SocialGuildTab2 : public SocialTab, public gcn::ActionListener { public: - SocialGuildTab2(Guild *guild, bool showBackground): + SocialGuildTab2(Guild *const guild, const bool showBackground): mGuild(guild) { setCaption(_("Guild")); @@ -286,7 +286,7 @@ private: class SocialPartyTab : public SocialTab, public gcn::ActionListener { public: - SocialPartyTab(Party *party, bool showBackground): + SocialPartyTab(Party *const party, const bool showBackground): mParty(party) { setCaption(_("Party")); @@ -415,7 +415,7 @@ public: class SocialPlayersTab : public SocialTab { public: - SocialPlayersTab(std::string name, bool showBackground) : + SocialPlayersTab(std::string name, const bool showBackground) : mBeings(new BeingsListModal()) { mList = new AvatarListBox(mBeings); @@ -449,19 +449,19 @@ public: if (!actorSpriteManager) return; - Avatar *avatar = findAvatarbyName(name); + Avatar *const avatar = findAvatarbyName(name); if (!avatar) return; if (Party::getParty(1)) { - PartyMember *pm = Party::getParty(1)->getMember(name); + const PartyMember *const pm = Party::getParty(1)->getMember(name); if (pm && pm->getMaxHp() > 0) { avatar->setMaxHp(pm->getMaxHp()); avatar->setHp(pm->getHp()); } } - Being* being = actorSpriteManager->findBeingByName( + const Being *const being = actorSpriteManager->findBeingByName( name, Being::PLAYER); if (being) { @@ -477,11 +477,11 @@ public: if (!actorSpriteManager) return; - Avatar *avatar = findAvatarbyName(name); + Avatar *const avatar = findAvatarbyName(name); if (!avatar) return; avatar->setDamageHp(0); - Being* being = actorSpriteManager->findBeingByName( + Being *const being = actorSpriteManager->findBeingByName( name, Being::PLAYER); if (being) @@ -490,13 +490,13 @@ public: Avatar* findAvatarbyName(std::string name) { - std::vector<Avatar*> *avatars = mBeings->getMembers(); + std::vector<Avatar*> *const avatars = mBeings->getMembers(); if (!avatars) return nullptr; Avatar *ava = nullptr; std::vector<Avatar*>::const_iterator i = avatars->begin(); - std::vector<Avatar*>::const_iterator i_end = avatars->end(); + const std::vector<Avatar*>::const_iterator i_end = avatars->end(); while (i != i_end) { ava = (*i); @@ -512,7 +512,7 @@ public: void getPlayersAvatars() { - std::vector<Avatar*> *avatars = mBeings->getMembers(); + std::vector<Avatar*> *const avatars = mBeings->getMembers(); if (!avatars) return; @@ -525,12 +525,12 @@ public: while (ai != avatars->end()) { bool finded = false; - Avatar *ava = (*ai); + const Avatar *const ava = (*ai); if (!ava) break; StringVectCIter i = names.begin(); - StringVectCIter i_end = names.end(); + const StringVectCIter i_end = names.end(); while (i != i_end) { if (ava->getName() == (*i) && (*i) != "") @@ -553,7 +553,7 @@ public: } StringVectCIter i = names.begin(); - StringVectCIter i_end = names.end(); + const StringVectCIter i_end = names.end(); while (i != i_end) { @@ -618,18 +618,18 @@ public: if (!socialWindow || !player_node) return; - Map* map = socialWindow->getMap(); + Map *const map = socialWindow->getMap(); if (!map || map->empty()) return; if (socialWindow->getProcessedPortals()) return; - std::vector<Avatar*> *avatars = mBeings->getMembers(); + std::vector<Avatar*> *const avatars = mBeings->getMembers(); std::vector<MapItem*> portals = map->getPortals(); std::vector<MapItem*>::const_iterator i = portals.begin(); - SpecialLayer *specialLayer = map->getSpecialLayer(); + const SpecialLayer *const specialLayer = map->getSpecialLayer(); std::vector<Avatar*>::iterator ia = avatars->begin(); @@ -648,13 +648,13 @@ public: if (!portal) continue; - int x = portal->getX(); - int y = portal->getY(); + const int x = portal->getX(); + const int y = portal->getY(); std::string name = strprintf("%s [%d %d]", portal->getComment().c_str(), x, y); - Avatar *ava = new Avatar(name); + Avatar *const ava = new Avatar(name); if (player_node) ava->setOnline(player_node->isReachable(x, y, 0)); else @@ -667,7 +667,8 @@ public: if (config.getBoolValue("drawHotKeys") && idx < 80 && outfitWindow) { - Being *being = actorSpriteManager->findPortalByTile(x, y); + Being *const being = actorSpriteManager + ->findPortalByTile(x, y); if (being) { being->setName(keyboard.getKeyShortString( @@ -693,16 +694,16 @@ public: } - virtual void selectIndex(unsigned num) + virtual void selectIndex(const unsigned num) { if (!player_node) return; - std::vector<Avatar*> *avatars = mBeings->getMembers(); + std::vector<Avatar*> *const avatars = mBeings->getMembers(); if (!avatars || avatars->size() <= num) return; - Avatar *ava = avatars->at(num); + const Avatar *const ava = avatars->at(num); if (ava && player_node) player_node->navigateTo(ava->getX(), ava->getY()); } @@ -712,24 +713,24 @@ public: if (!socialWindow) return; - std::vector<Avatar*> *avatars = mBeings->getMembers(); + std::vector<Avatar*> *const avatars = mBeings->getMembers(); if (!avatars) return; - Map *map = socialWindow->getMap(); + const Map *const map = socialWindow->getMap(); if (!map) return; Avatar *ava = nullptr; std::vector<Avatar*>::const_iterator i = avatars->begin(); - std::vector<Avatar*>::const_iterator i_end = avatars->end(); + const std::vector<Avatar*>::const_iterator i_end = avatars->end(); while (i != i_end) { ava = (*i); if (!ava) break; - MapItem *item = map->findPortalXY(ava->getX(), ava->getY()); + const MapItem *const item = map->findPortalXY(ava->getX(), ava->getY()); if (item) { std::string name = strprintf("%s [%d %d]", @@ -742,22 +743,22 @@ public: } } - int getPortalIndex(int x, int y) + int getPortalIndex(const int x, const int y) { if (!socialWindow) return -1; - std::vector<Avatar*> *avatars = mBeings->getMembers(); + std::vector<Avatar*> *const avatars = mBeings->getMembers(); if (!avatars) return -1; - Map *map = socialWindow->getMap(); + const Map *const map = socialWindow->getMap(); if (!map) return 01; - Avatar *ava = nullptr; + const Avatar *ava = nullptr; std::vector<Avatar*>::const_iterator i = avatars->begin(); - std::vector<Avatar*>::const_iterator i_end = avatars->end(); + const std::vector<Avatar*>::const_iterator i_end = avatars->end(); unsigned num = 0; while (i != i_end) { @@ -775,28 +776,28 @@ public: return -1; } - void addPortal(int x, int y) + void addPortal(const int x, const int y) { if (!socialWindow || !player_node) return; - Map* map = socialWindow->getMap(); + const Map *const map = socialWindow->getMap(); if (!map) return; - std::vector<Avatar*> *avatars = mBeings->getMembers(); + std::vector<Avatar*> *const avatars = mBeings->getMembers(); if (!avatars) return; - MapItem *portal = map->findPortalXY(x, y); + const MapItem *const portal = map->findPortalXY(x, y); if (!portal) return; std::string name = strprintf("%s [%d %d]", portal->getComment().c_str(), x, y); - Avatar *ava = new Avatar(name); + Avatar *const ava = new Avatar(name); if (player_node) ava->setOnline(player_node->isReachable(x, y, 0)); else @@ -808,22 +809,22 @@ public: avatars->push_back(ava); } - void removePortal(int x, int y) + void removePortal(const int x, const int y) { if (!socialWindow || !player_node) return; - Map* map = socialWindow->getMap(); + const Map *const map = socialWindow->getMap(); if (!map) return; - std::vector<Avatar*> *avatars = mBeings->getMembers(); + std::vector<Avatar*> *const avatars = mBeings->getMembers(); if (!avatars) return; std::vector<Avatar*>::iterator i = avatars->begin(); - std::vector<Avatar*>::iterator i_end = avatars->end(); + const std::vector<Avatar*>::iterator i_end = avatars->end(); while (i != i_end) { @@ -898,7 +899,7 @@ protected: #define updateAtkListStart() \ if (!socialWindow || !player_node || !actorSpriteManager)\ return;\ - std::vector<Avatar*> *avatars = mBeings->getMembers();\ + std::vector<Avatar*> *const avatars = mBeings->getMembers();\ std::vector<Avatar*>::iterator ia = avatars->begin();\ while (ia != avatars->end())\ {\ @@ -1024,7 +1025,7 @@ private: class SocialFriendsTab : public SocialTab { public: - SocialFriendsTab(std::string name, bool showBackground) : + SocialFriendsTab(std::string name, const bool showBackground) : mBeings(new BeingsListModal()) { mList = new AvatarListBox(mBeings); @@ -1288,7 +1289,7 @@ SocialWindow::~SocialWindow() mFriends = nullptr; } -bool SocialWindow::addTab(Guild *guild) +bool SocialWindow::addTab(Guild *const guild) { if (mGuilds.find(guild) != mGuilds.end()) return false; @@ -1307,9 +1308,9 @@ bool SocialWindow::addTab(Guild *guild) return true; } -bool SocialWindow::removeTab(Guild *guild) +bool SocialWindow::removeTab(Guild *const guild) { - GuildMap::iterator it = mGuilds.find(guild); + const GuildMap::iterator it = mGuilds.find(guild); if (it == mGuilds.end()) return false; @@ -1322,12 +1323,12 @@ bool SocialWindow::removeTab(Guild *guild) return true; } -bool SocialWindow::addTab(Party *party) +bool SocialWindow::addTab(Party *const party) { if (mParties.find(party) != mParties.end()) return false; - SocialPartyTab *tab = new SocialPartyTab(party, + SocialPartyTab *const tab = new SocialPartyTab(party, getOptionBool("showbackground")); mParties[party] = tab; @@ -1338,9 +1339,9 @@ bool SocialWindow::addTab(Party *party) return true; } -bool SocialWindow::removeTab(Party *party) +bool SocialWindow::removeTab(Party *const party) { - PartyMap::iterator it = mParties.find(party); + const PartyMap::iterator it = mParties.find(party); if (it == mParties.end()) return false; @@ -1601,7 +1602,7 @@ void SocialWindow::updateActiveList() void SocialWindow::slowLogic() { - unsigned int nowTime = cur_time; + const unsigned int nowTime = cur_time; if (mNeedUpdate && nowTime - mLastUpdateTime > 1) { mPlayers->updateList(); @@ -1632,7 +1633,7 @@ void SocialWindow::updateButtons() if (!mTabs) return; - bool hasTabs = mTabs->getNumberOfTabs() > 0; + const bool hasTabs = mTabs->getNumberOfTabs() > 0; mInviteButton->setEnabled(hasTabs); mLeaveButton->setEnabled(hasTabs); } @@ -1649,13 +1650,13 @@ void SocialWindow::updatePortalNames() static_cast<SocialNavigationTab*>(mNavigation)->updateNames(); } -void SocialWindow::selectPortal(unsigned num) +void SocialWindow::selectPortal(const unsigned num) { if (mNavigation) mNavigation->selectIndex(num); } -int SocialWindow::getPortalIndex(int x, int y) +int SocialWindow::getPortalIndex(const int x, const int y) { if (mNavigation) { @@ -1668,13 +1669,13 @@ int SocialWindow::getPortalIndex(int x, int y) } } -void SocialWindow::addPortal(int x, int y) +void SocialWindow::addPortal(const int x, const int y) { if (mNavigation) static_cast<SocialNavigationTab*>(mNavigation)->addPortal(x, y); } -void SocialWindow::removePortal(int x, int y) +void SocialWindow::removePortal(const int x, const int y) { if (mNavigation) static_cast<SocialNavigationTab*>(mNavigation)->removePortal(x, y); diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index 246f3e127..0806c8d10 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -56,13 +56,13 @@ public: ~SocialWindow(); - bool addTab(Guild *guild); + bool addTab(Guild *const guild); - bool removeTab(Guild *guild); + bool removeTab(Guild *const guild); - bool addTab(Party *party); + bool addTab(Party *const party); - bool removeTab(Party *party); + bool removeTab(Party *const party); /** * Handle events. @@ -91,11 +91,11 @@ public: void updatePortalNames(); - int getPortalIndex(int x, int y); + int getPortalIndex(const int x, const int y); - void addPortal(int x, int y); + void addPortal(const int x, const int y); - void removePortal(int x, int y); + void removePortal(const int x, const int y); void nextTab(); @@ -104,16 +104,16 @@ public: Map* getMap() const { return mMap; } - void setMap(Map *map) + void setMap(Map *const map) { mMap = map; mProcessedPortals = false; } bool getProcessedPortals() const { return mProcessedPortals; } - void setProcessedPortals(bool n) + void setProcessedPortals(const bool n) { mProcessedPortals = n; } - void selectPortal(unsigned num); + void selectPortal(const unsigned num); void updateAttackFilter(); diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 6188b5c2d..31877f310 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -52,14 +52,15 @@ SpeechBubble::SpeechBubble(): add(mSpeechBox); } -void SpeechBubble::setCaption(const std::string &name, const gcn::Color *color) +void SpeechBubble::setCaption(const std::string &name, + const gcn::Color *const color) { mCaption->setCaption(name); mCaption->adjustSize(); mCaption->setForegroundColor(*color); } -void SpeechBubble::setText(const std::string &text, bool showName) +void SpeechBubble::setText(const std::string &text, const bool showName) { if (text == mText && (mCaption->getWidth() <= mSpeechBox->getMinWidth())) return; diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 0208941c4..c6b512c83 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -47,13 +47,13 @@ class SpeechBubble : public Popup * Sets the name displayed for the speech bubble, and in what color. */ void setCaption(const std::string &name, - const gcn::Color *color = + const gcn::Color *const color = &Theme::getThemeColor(Theme::BUBBLE_NAME)); /** * Sets the text to be displayed. */ - void setText(const std::string &text, bool showName = true); + void setText(const std::string &text, const bool showName = true); private: std::string mText; diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index af7a2a619..9267e76df 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -55,7 +55,7 @@ SpellPopup::~SpellPopup() { } -void SpellPopup::setItem(TextCommand *spell) +void SpellPopup::setItem(const TextCommand *const spell) { if (spell) { @@ -93,7 +93,7 @@ void SpellPopup::setItem(TextCommand *spell) } } -void SpellPopup::view(int x, int y) +void SpellPopup::view(const int x, const int y) { const int distance = 20; diff --git a/src/gui/spellpopup.h b/src/gui/spellpopup.h index 0cb66ca9a..403112e85 100644 --- a/src/gui/spellpopup.h +++ b/src/gui/spellpopup.h @@ -56,12 +56,12 @@ class SpellPopup : public Popup /** * Sets the info to be displayed given a particular item. */ - void setItem(TextCommand *spell); + void setItem(const TextCommand *const spell); /** * Sets the location to display the item popup. */ - void view(int x, int y); + void view(const int x, const int y); void mouseMoved(gcn::MouseEvent &mouseEvent); diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 36917b250..a593f2fe3 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -165,7 +165,7 @@ void StatusPopup::update() + mDisableGameModifiers->getHeight() + 2 * getPadding()); } -void StatusPopup::view(int x, int y) +void StatusPopup::view(const int x, const int y) { const int distance = 20; @@ -184,14 +184,16 @@ void StatusPopup::view(int x, int y) requestMoveToTop(); } -void StatusPopup::setLabelText(gcn::Label *label, const char *text, int key) +void StatusPopup::setLabelText(gcn::Label *const label, const char *const text, + int const key) const { label->setCaption(strprintf("%s %s", text, inputManager.getKeyValueString(key).c_str())); } -void StatusPopup::setLabelText2(gcn::Label *label, std::string text, - Input::KeyAction key) +void StatusPopup::setLabelText2(gcn::Label *const label, + const std::string &text, + const Input::KeyAction key) const { label->setCaption(strprintf("%s %s", text.c_str(), inputManager.getKeyValueString(static_cast<int>(key)).c_str())); diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h index 0921fbb7f..181bc9401 100644 --- a/src/gui/statuspopup.h +++ b/src/gui/statuspopup.h @@ -58,7 +58,7 @@ class StatusPopup : public Popup /** * Sets the location to display the item popup. */ - void view(int x, int y); + void view(const int x, const int y); // void mouseMoved(gcn::MouseEvent &mouseEvent); @@ -67,10 +67,11 @@ class StatusPopup : public Popup private: void updateLabels(); - void setLabelText(gcn::Label *label, const char *text, int key); + void setLabelText(gcn::Label *const label, const char *const text, + const int key) const; - void setLabelText2(gcn::Label *label, std::string text, - Input::KeyAction key); + void setLabelText2(gcn::Label *const label, const std::string &text, + const Input::KeyAction key) const; gcn::Label *mMoveType; gcn::Label *mCrazyMoveType; diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 6354fe42e..a4c47553c 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -68,7 +68,7 @@ class AttrDisplay : public Container virtual Type getType() const { return UNKNOWN; } - std::string getValue() + std::string getValue() const { if (!mValue) return "-"; @@ -77,7 +77,7 @@ class AttrDisplay : public Container } protected: - AttrDisplay(int id, const std::string &name); + AttrDisplay(const int id, const std::string &name); const int mId; const std::string mName; @@ -90,7 +90,7 @@ class AttrDisplay : public Container class DerDisplay : public AttrDisplay { public: - DerDisplay(int id, const std::string &name); + DerDisplay(const int id, const std::string &name); virtual Type getType() const { return DERIVED; } @@ -99,7 +99,7 @@ class DerDisplay : public AttrDisplay class ChangeDisplay : public AttrDisplay, gcn::ActionListener { public: - ChangeDisplay(int id, const std::string &name); + ChangeDisplay(const int id, const std::string &name); std::string update(); @@ -163,9 +163,9 @@ StatusWindow::StatusWindow(): / static_cast<float>(max): static_cast<float>(0), 80, 15, Theme::PROG_EXP); - bool magicBar = Net::getGameHandler()->canUseMagicBar(); + const bool magicBar = Net::getGameHandler()->canUseMagicBar(); - int job = Net::getPlayerHandler()->getJobLocation() + const int job = Net::getPlayerHandler()->getJobLocation() && serverConfig.getValueBool("showJob", false); if (magicBar) @@ -349,7 +349,7 @@ void StatusWindow::processEvent(Channels channel A_UNUSED, } else if (event.getName() == EVENT_UPDATESTAT) { - int id = event.getInt("id"); + const int id = event.getInt("id"); if (id == Net::getPlayerHandler()->getJobLocation()) { if (mJobLvlLabel) @@ -357,8 +357,8 @@ void StatusWindow::processEvent(Channels channel A_UNUSED, int lvl = PlayerInfo::getStatBase( static_cast<PlayerInfo::Attribute>(id)); - int oldExp = event.getInt("oldValue1"); - std::pair<int, int> exp = PlayerInfo::getStatExperience( + const int oldExp = event.getInt("oldValue1"); + const std::pair<int, int> exp = PlayerInfo::getStatExperience( static_cast<PlayerInfo::Attribute>(id)); if (!lvl) @@ -401,7 +401,7 @@ void StatusWindow::processEvent(Channels channel A_UNUSED, else { updateMPBar(mMpBar, true); - Attrs::const_iterator it = mAttrs.find(id); + const Attrs::const_iterator it = mAttrs.find(id); if (it != mAttrs.end() && it->second) { if (it->second) @@ -411,20 +411,20 @@ void StatusWindow::processEvent(Channels channel A_UNUSED, } } -void StatusWindow::setPointsNeeded(int id, int needed) +void StatusWindow::setPointsNeeded(const int id, const int needed) { - Attrs::const_iterator it = mAttrs.find(id); + const Attrs::const_iterator it = mAttrs.find(id); if (it != mAttrs.end()) { - AttrDisplay *disp = it->second; + AttrDisplay *const disp = it->second; if (disp && disp->getType() == AttrDisplay::CHANGEABLE) static_cast<ChangeDisplay*>(disp)->setPointsNeeded(needed); } } -void StatusWindow::addAttribute(int id, const std::string &name, - bool modifiable, +void StatusWindow::addAttribute(const int id, const std::string &name, + const bool modifiable, const std::string &description A_UNUSED) { AttrDisplay *disp; @@ -454,7 +454,7 @@ void StatusWindow::clearAttributes() mAttrs.clear(); } -void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax) +void StatusWindow::updateHPBar(ProgressBar *const bar, const bool showMax) { if (!bar) return; @@ -479,7 +479,7 @@ void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax) bar->setProgress(prog); } -void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax) +void StatusWindow::updateMPBar(ProgressBar *const bar, const bool showMax) { if (!bar) return; @@ -519,8 +519,8 @@ void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax) bar->setProgress(prog); } -void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max, - bool percent) +void StatusWindow::updateProgressBar(ProgressBar *const bar, const int value, + const int max, const bool percent) { if (!bar) return; @@ -533,8 +533,8 @@ void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max, } else { - float progress = static_cast<float>(value) - / static_cast<float>(max); + const float progress = static_cast<float>(value) + / static_cast<float>(max); if (percent) { @@ -550,7 +550,7 @@ void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max, } } -void StatusWindow::updateXPBar(ProgressBar *bar, bool percent) +void StatusWindow::updateXPBar(ProgressBar *const bar, const bool percent) { if (!bar) return; @@ -559,24 +559,25 @@ void StatusWindow::updateXPBar(ProgressBar *bar, bool percent) PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED), percent); } -void StatusWindow::updateJobBar(ProgressBar *bar, bool percent) +void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent) { if (!bar) return; - std::pair<int, int> exp = PlayerInfo::getStatExperience( + const std::pair<int, int> exp = PlayerInfo::getStatExperience( Net::getPlayerHandler()->getJobLocation()); updateProgressBar(bar, exp.first, exp.second, percent); } -void StatusWindow::updateProgressBar(ProgressBar *bar, int id, bool percent) +void StatusWindow::updateProgressBar(ProgressBar *const bar, const int id, + const bool percent) const { - std::pair<int, int> exp = PlayerInfo::getStatExperience( + const std::pair<int, int> exp = PlayerInfo::getStatExperience( static_cast<PlayerInfo::Attribute>(id)); updateProgressBar(bar, exp.first, exp.second, percent); } -void StatusWindow::updateWeightBar(ProgressBar *bar) +void StatusWindow::updateWeightBar(ProgressBar *const bar) { if (!bar) return; @@ -588,7 +589,7 @@ void StatusWindow::updateWeightBar(ProgressBar *bar) } else { - float progress = static_cast<float>(PlayerInfo::getAttribute( + const float progress = static_cast<float>(PlayerInfo::getAttribute( PlayerInfo::TOTAL_WEIGHT)) / static_cast<float>( PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT)); @@ -601,16 +602,16 @@ void StatusWindow::updateWeightBar(ProgressBar *bar) } } -void StatusWindow::updateMoneyBar(ProgressBar *bar) +void StatusWindow::updateMoneyBar(ProgressBar *const bar) { if (!bar) return; - int money = PlayerInfo::getAttribute(PlayerInfo::MONEY); + const int money = PlayerInfo::getAttribute(PlayerInfo::MONEY); bar->setText(Units::formatCurrency(money).c_str()); if (money > 0) { - float progress = static_cast<float>(money) + const float progress = static_cast<float>(money) / static_cast<float>(1000000000); bar->setProgress(progress); } @@ -620,12 +621,12 @@ void StatusWindow::updateMoneyBar(ProgressBar *bar) } } -void StatusWindow::updateArrowsBar(ProgressBar *bar) +void StatusWindow::updateArrowsBar(ProgressBar *const bar) { if (!bar || !equipmentWindow) return; - Item *item = equipmentWindow->getEquipment( + const Item *const item = equipmentWindow->getEquipment( Equipment::EQUIP_PROJECTILE_SLOT); if (item && item->getQuantity() > 0) @@ -634,12 +635,12 @@ void StatusWindow::updateArrowsBar(ProgressBar *bar) bar->setText("0"); } -void StatusWindow::updateInvSlotsBar(ProgressBar *bar) +void StatusWindow::updateInvSlotsBar(ProgressBar *const bar) { if (!bar) return; - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) return; @@ -655,10 +656,10 @@ void StatusWindow::updateInvSlotsBar(ProgressBar *bar) bar->setText(strprintf("%d", usedSlots)); } -std::string StatusWindow::translateLetter(const char* letters) +std::string StatusWindow::translateLetter(const char *const letters) { char buf[2]; - char *str = gettext(letters); + char *const str = gettext(letters); if (strlen(str) != 3) return letters; @@ -675,7 +676,8 @@ std::string StatusWindow::translateLetter2(std::string letters) return std::string(gettext(letters.substr(1, 1).c_str())); } -void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED) +void StatusWindow::updateStatusBar(ProgressBar *const bar, + const bool percent A_UNUSED) { if (!player_node || !viewport) return; @@ -722,11 +724,12 @@ void StatusWindow::action(const gcn::ActionEvent &event) if (event.getId() == "copy") { Attrs::const_iterator it = mAttrs.begin(); - Attrs::const_iterator it_end = mAttrs.end(); + const Attrs::const_iterator it_end = mAttrs.end(); std::string str; while (it != it_end) { - ChangeDisplay *attr = dynamic_cast<ChangeDisplay*>((*it).second); + ChangeDisplay *const attr = dynamic_cast<ChangeDisplay*>( + (*it).second); if (attr) str += attr->getValue() + " "; ++ it; @@ -735,7 +738,7 @@ void StatusWindow::action(const gcn::ActionEvent &event) } } -AttrDisplay::AttrDisplay(int id, const std::string &name): +AttrDisplay::AttrDisplay(const int id, const std::string &name): mId(id), mName(name) { @@ -757,9 +760,9 @@ AttrDisplay::~AttrDisplay() std::string AttrDisplay::update() { - int base = PlayerInfo::getStatBase( + const int base = PlayerInfo::getStatBase( static_cast<PlayerInfo::Attribute>(mId)); - int bonus = PlayerInfo::getStatMod( + const int bonus = PlayerInfo::getStatMod( static_cast<PlayerInfo::Attribute>(mId)); std::string value = toString(base + bonus); if (bonus) @@ -768,7 +771,7 @@ std::string AttrDisplay::update() return mName; } -DerDisplay::DerDisplay(int id, const std::string &name): +DerDisplay::DerDisplay(const int id, const std::string &name): AttrDisplay(id, name) { // Do the layout @@ -781,7 +784,7 @@ DerDisplay::DerDisplay(int id, const std::string &name): update(); } -ChangeDisplay::ChangeDisplay(int id, const std::string &name): +ChangeDisplay::ChangeDisplay(const int id, const std::string &name): AttrDisplay(id, name), mNeeded(1) { mPoints = new Label(_("Max")); @@ -826,7 +829,7 @@ std::string ChangeDisplay::update() return AttrDisplay::update(); } -void ChangeDisplay::setPointsNeeded(int needed) +void ChangeDisplay::setPointsNeeded(const int needed) { mNeeded = needed; @@ -838,15 +841,15 @@ void ChangeDisplay::action(const gcn::ActionEvent &event) if (Net::getPlayerHandler()->canCorrectAttributes() && event.getSource() == mDec) { - int newcorpoints = PlayerInfo::getAttribute( + const int newcorpoints = PlayerInfo::getAttribute( PlayerInfo::CORR_POINTS) - 1; PlayerInfo::setAttribute(PlayerInfo::CORR_POINTS, newcorpoints); - int newpoints = PlayerInfo::getAttribute( + const int newpoints = PlayerInfo::getAttribute( PlayerInfo::CHAR_POINTS) + 1; PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints); - int newbase = PlayerInfo::getStatBase( + const int newbase = PlayerInfo::getStatBase( static_cast<PlayerInfo::Attribute>(mId)) - 1; PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( mId), newbase); @@ -863,11 +866,11 @@ void ChangeDisplay::action(const gcn::ActionEvent &event) cnt = 10; } - int newpoints = PlayerInfo::getAttribute( + const int newpoints = PlayerInfo::getAttribute( PlayerInfo::CHAR_POINTS) - cnt; PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints); - int newbase = PlayerInfo::getStatBase( + const int newbase = PlayerInfo::getStatBase( static_cast<PlayerInfo::Attribute>(mId)) + cnt; PlayerInfo::setStatBase(static_cast<PlayerInfo::Attribute>( mId), newbase); diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 936ea68eb..4002ee741 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -59,31 +59,36 @@ class StatusWindow : public Window, void processEvent(Channels channel, const DepricatedEvent &event); - void setPointsNeeded(int id, int needed); + void setPointsNeeded(const int id, const int needed); - void addAttribute(int id, const std::string &name, bool modifiable, + void addAttribute(const int id, const std::string &name, + const bool modifiable, const std::string &description); - static void updateHPBar(ProgressBar *bar, bool showMax = false); + static void updateHPBar(ProgressBar *const bar, + const bool showMax = false); static void updateMPBar(ProgressBar *bar, bool showMax = false); - static void updateJobBar(ProgressBar *bar, bool percent = true); - static void updateXPBar(ProgressBar *bar, bool percent = true); - static void updateWeightBar(ProgressBar *bar); - static void updateInvSlotsBar(ProgressBar *bar); - static void updateMoneyBar(ProgressBar *bar); - static void updateArrowsBar(ProgressBar *bar); - static void updateStatusBar(ProgressBar *bar, bool percent = true); - static void updateProgressBar(ProgressBar *bar, int value, int max, - bool percent); - void updateProgressBar(ProgressBar *bar, int id, - bool percent = true); + static void updateJobBar(ProgressBar *const bar, + const bool percent = true); + static void updateXPBar(ProgressBar *const bar, + const bool percent = true); + static void updateWeightBar(ProgressBar *const bar); + static void updateInvSlotsBar(ProgressBar *const bar); + static void updateMoneyBar(ProgressBar *const bar); + static void updateArrowsBar(ProgressBar *const bar); + static void updateStatusBar(ProgressBar *const bar, + const bool percent = true); + static void updateProgressBar(ProgressBar *const bar, const int value, + const int max, const bool percent); + void updateProgressBar(ProgressBar *const bar, const int id, + const bool percent = true) const; void action(const gcn::ActionEvent &event); void clearAttributes(); private: - static std::string translateLetter(const char* letters); + static std::string translateLetter(const char *const letters); static std::string translateLetter2(std::string letters); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 04dbffd51..b071c78d4 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -161,7 +161,7 @@ public: }; -TextCommandEditor::TextCommandEditor(TextCommand *command) : +TextCommandEditor::TextCommandEditor(TextCommand *const command) : Window(_("Command Editor"), false, nullptr, "commandeditor.xml"), mIsMagicCommand(command->getCommandType() == TEXT_COMMAND_MAGIC), mCommand(command), @@ -193,8 +193,8 @@ TextCommandEditor::TextCommandEditor(TextCommand *command) : mDeleteButton(new Button(_("Delete"), "delete", this)), mEnabledKeyboard(keyboard.isEnabled()) { - int w = 350; - int h = 370; + const int w = 350; + const int h = 370; keyboard.setEnabled(false); @@ -341,7 +341,7 @@ void TextCommandEditor::reset() { } -void TextCommandEditor::showControls(bool show) +void TextCommandEditor::showControls(const bool show) { mManaField->setVisible(show); mManaLabel->setVisible(show); diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h index 2221a9507..65274098d 100644 --- a/src/gui/textcommandeditor.h +++ b/src/gui/textcommandeditor.h @@ -48,7 +48,7 @@ class TextCommandEditor : public Window, public gcn::ActionListener /** * Constructor. */ - TextCommandEditor(TextCommand *command); + TextCommandEditor(TextCommand *const command); /** * Destructor. @@ -66,7 +66,7 @@ class TextCommandEditor : public Window, public gcn::ActionListener void scheduleDelete(); private: - void showControls(bool show); + void showControls(const bool show); void save(); diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp index b7f8a6ce3..3e49eea97 100644 --- a/src/gui/textdialog.cpp +++ b/src/gui/textdialog.cpp @@ -37,7 +37,7 @@ int TextDialog::instances = 0; TextDialog::TextDialog(const std::string &title, const std::string &msg, - Window *parent, bool isPassword): + Window *const parent, const bool isPassword): Window(title, true, parent, "textdialog.xml"), mTextField(nullptr), mPasswordField(nullptr) @@ -45,9 +45,9 @@ TextDialog::TextDialog(const std::string &title, const std::string &msg, mEnabledKeyboard = keyboard.isEnabled(); keyboard.setEnabled(false); - gcn::Label *textLabel = new Label(msg); + gcn::Label *const textLabel = new Label(msg); mOkButton = new Button(_("OK"), "OK", this); - gcn::Button *cancelButton = new Button(_("Cancel"), "CANCEL", this); + gcn::Button *const cancelButton = new Button(_("Cancel"), "CANCEL", this); place(0, 0, textLabel, 4); if (isPassword) @@ -63,7 +63,7 @@ TextDialog::TextDialog(const std::string &title, const std::string &msg, place(2, 2, mOkButton); place(3, 2, cancelButton); - gcn::Font *font = getFont(); + const gcn::Font *const font = getFont(); if (font) { int width = font->getWidth(title); diff --git a/src/gui/textdialog.h b/src/gui/textdialog.h index 289b62283..a05dc3107 100644 --- a/src/gui/textdialog.h +++ b/src/gui/textdialog.h @@ -49,7 +49,7 @@ public: * @see Window::Window */ TextDialog(const std::string &title, const std::string &msg, - Window *parent = nullptr, bool isPassword = false); + Window *const parent = nullptr, const bool isPassword = false); ~TextDialog(); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index b7967e32d..c65c34804 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -61,7 +61,7 @@ TextPopup::~TextPopup() { } -void TextPopup::show(int x, int y, const std::string &str1, +void TextPopup::show(const int x, const int y, const std::string &str1, const std::string &str2, const std::string &str3) { mText1->setCaption(str1); diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h index dd901d580..5e425abca 100644 --- a/src/gui/textpopup.h +++ b/src/gui/textpopup.h @@ -54,7 +54,7 @@ class TextPopup : public Popup /** * Sets the text to be displayed. */ - void show(int x, int y, const std::string &str1) + void show(const int x, const int y, const std::string &str1) { show(x, y, str1, static_cast<const char*>(""), static_cast<const char*>("")); @@ -63,14 +63,14 @@ class TextPopup : public Popup /** * Sets the text to be displayed. */ - void show(int x, int y, const std::string &str1, + void show(const int x, const int y, const std::string &str1, const std::string &str2) { show(x, y, str1, str2, static_cast<const char*>("")); } /** * Sets the text to be displayed. */ - void show(int x, int y, const std::string &str1, + void show(const int x, const int y, const std::string &str1, const std::string &str2, const std::string &str3); void mouseMoved(gcn::MouseEvent &mouseEvent); diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index a21c5a860..a6b94c4d4 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -50,7 +50,7 @@ Theme *Theme::mInstance = nullptr; // Set the theme path... static void initDefaultThemePath() { - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); defaultThemePath = branding.getStringValue("guiThemePath"); logger->log("defaultThemePath: " + defaultThemePath); @@ -60,9 +60,10 @@ static void initDefaultThemePath() defaultThemePath = "themes/"; } -Skin::Skin(ImageRect skin, ImageRect images, const std::string &filePath, - const std::string &name, int padding, int titlePadding, - std::map<std::string, int> *options): +Skin::Skin(const ImageRect skin, const ImageRect images, + const std::string &filePath, const std::string &name, + const int padding, const int titlePadding, + std::map<std::string, int> *const options): instances(1), mFilePath(filePath), mName(name), @@ -210,13 +211,13 @@ void Theme::deleteInstance() mInstance = nullptr; } -gcn::Color Theme::getProgressColor(int type, float progress) +gcn::Color Theme::getProgressColor(const int type, const float progress) { int color[3] = {0, 0, 0}; if (mInstance) { - DyePalette *dye = mInstance->mProgressColors[type]; + const DyePalette *const dye = mInstance->mProgressColors[type]; if (dye) dye->getColor(progress, color); @@ -228,11 +229,11 @@ gcn::Color Theme::getProgressColor(int type, float progress) } Skin *Theme::load(const std::string &filename, const std::string &filename2, - bool full, const std::string &defaultPath) + const bool full, const std::string &defaultPath) { // Check if this skin was already loaded - SkinIterator skinIterator = mSkins.find(filename); + const SkinIterator skinIterator = mSkins.find(filename); if (mSkins.end() != skinIterator) { if (skinIterator->second) @@ -273,7 +274,7 @@ Skin *Theme::load(const std::string &filename, const std::string &filename2, return skin; } -void Theme::unload(Skin *skin) +void Theme::unload(Skin *const skin) { if (!skin) return; @@ -282,7 +283,7 @@ void Theme::unload(Skin *skin) if (!skin->instances) { SkinIterator it = mSkins.begin(); - SkinIterator it_end = mSkins.end(); + const SkinIterator it_end = mSkins.end(); while (it != it_end) { if (it->second == skin) @@ -296,7 +297,7 @@ void Theme::unload(Skin *skin) } } -void Theme::setMinimumOpacity(float minimumOpacity) +void Theme::setMinimumOpacity(const float minimumOpacity) { if (minimumOpacity > 1.0f) return; @@ -385,7 +386,7 @@ struct SkinHelper Image *image; ResourceManager *resman; - bool loadList(SkinParameter *params, size_t size) + bool loadList(const SkinParameter *const params, const size_t size) { for (unsigned f = 0; f < size; f ++) { @@ -402,7 +403,7 @@ struct SkinHelper } }; -Skin *Theme::readSkin(const std::string &filename, bool full) +Skin *Theme::readSkin(const std::string &filename, const bool full) { if (filename.empty()) return nullptr; @@ -410,7 +411,7 @@ Skin *Theme::readSkin(const std::string &filename, bool full) // logger->log("Loading skin '%s'.", filename.c_str()); XML::Document doc(resolveThemePath(filename)); - XmlNodePtr rootNode = doc.rootNode(); + const XmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlNameEqual(rootNode, "skinset")) return nullptr; @@ -423,14 +424,15 @@ Skin *Theme::readSkin(const std::string &filename, bool full) return nullptr; } - Image *dBorders = Theme::getImageFromTheme(skinSetImage); + Image *const dBorders = Theme::getImageFromTheme(skinSetImage); ImageRect border; ImageRect images; memset(&border, 0, sizeof(ImageRect)); memset(&images, 0, sizeof(ImageRect)); int padding = 3; int titlePadding = 4; - std::map<std::string, int> *mOptions = new std::map<std::string, int>(); + std::map<std::string, int> *const mOptions + = new std::map<std::string, int>(); // iterate <widget>'s for_each_xml_child_node(widgetNode, rootNode) @@ -499,7 +501,7 @@ Skin *Theme::readSkin(const std::string &filename, bool full) if (dBorders) dBorders->decRef(); - Skin *skin = new Skin(border, images, filename, "", padding, + Skin *const skin = new Skin(border, images, filename, "", padding, titlePadding, mOptions); skin->updateAlpha(mMinimumOpacity); return skin; @@ -613,7 +615,7 @@ void Theme::prepareThemePath() std::string Theme::resolveThemePath(const std::string &path) { // Need to strip off any dye info for the existence tests - int pos = static_cast<int>(path.find('|')); + const int pos = static_cast<int>(path.find('|')); std::string file; if (pos > 0) file = path.substr(0, pos); @@ -640,20 +642,20 @@ std::string Theme::resolveThemePath(const std::string &path) Image *Theme::getImageFromTheme(const std::string &path) { - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); return resman->getImage(resolveThemePath(path)); } ImageSet *Theme::getImageSetFromTheme(const std::string &path, - int w, int h) + const int w, const int h) { - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); return resman->getImageSet(resolveThemePath(path), w, h); } static int readColorType(const std::string &type) { - static std::string colors[] = + static const std::string colors[] = { "BROWSERBOX", "TEXT", @@ -740,7 +742,7 @@ static int readColorType(const std::string &type) static gcn::Color readColor(const std::string &description) { - int size = static_cast<int>(description.length()); + const int size = static_cast<const int>(description.length()); if (size < 7 || description[0] != '#') { logger->log("Error, invalid theme color palette: %s", @@ -751,7 +753,7 @@ static gcn::Color readColor(const std::string &description) int v = 0; for (int i = 1; i < 7; ++i) { - char c = description[i]; + const char c = description[i]; int n; if ('0' <= c && c <= '9') @@ -781,7 +783,7 @@ static gcn::Color readColor(const std::string &description) static Palette::GradientType readColorGradient(const std::string &grad) { - static std::string grads[] = + static const std::string grads[] = { "STATIC", "PULSE", @@ -803,7 +805,7 @@ static Palette::GradientType readColorGradient(const std::string &grad) static int readProgressType(const std::string &type) { - static std::string colors[] = + static const std::string colors[] = { "DEFAULT", "HP", @@ -838,7 +840,7 @@ void Theme::loadColors(std::string file) file += "/colors.xml"; XML::Document doc(resolveThemePath(file)); - XmlNodePtr root = doc.rootNode(); + const XmlNodePtr root = doc.rootNode(); if (!root || !xmlNameEqual(root, "colors")) { @@ -882,10 +884,11 @@ void Theme::loadColors(std::string file) } } -void Theme::loadRect(ImageRect &image, std::string name, std::string name2, - int start, int end) +void Theme::loadRect(ImageRect &image, const std::string &name, + const std::string &name2, + const int start, const int end) { - Skin *skin = load(name, name2, false); + Skin *const skin = load(name, name2, false); if (skin) { const ImageRect &rect = skin->getBorder(); @@ -901,10 +904,11 @@ void Theme::loadRect(ImageRect &image, std::string name, std::string name2, } } -Skin *Theme::loadSkinRect(ImageRect &image, std::string name, - std::string name2, int start, int end) +Skin *Theme::loadSkinRect(ImageRect &image, const std::string &name, + const std::string &name2, const int start, + const int end) { - Skin *skin = load(name, name2); + Skin *const skin = load(name, name2); if (skin) { const ImageRect &rect = skin->getBorder(); @@ -920,7 +924,8 @@ Skin *Theme::loadSkinRect(ImageRect &image, std::string name, return skin; } -void Theme::unloadRect(ImageRect &rect, int start, int end) +void Theme::unloadRect(const ImageRect &rect, const int start, + const int end) const { for (int f = start; f <= end; f ++) { @@ -932,14 +937,14 @@ void Theme::unloadRect(ImageRect &rect, int start, int end) Image *Theme::getImageFromThemeXml(const std::string &name, const std::string &name2) { - Theme *theme = Theme::instance(); - Skin *skin = theme->load(name, name2, false); + Theme *const theme = Theme::instance(); + Skin *const skin = theme->load(name, name2, false); if (skin) { const ImageRect &rect = skin->getBorder(); if (rect.grid[0]) { - Image *image = rect.grid[0]; + Image *const image = rect.grid[0]; image->incRef(); theme->unload(skin); return image; @@ -951,19 +956,19 @@ Image *Theme::getImageFromThemeXml(const std::string &name, ImageSet *Theme::getImageSetFromThemeXml(const std::string &name, const std::string &name2, - int w, int h) + const int w, const int h) const { - Theme *theme = Theme::instance(); - Skin *skin = theme->load(name, name2, false); + Theme *const theme = Theme::instance(); + Skin *const skin = theme->load(name, name2, false); if (skin) { const ImageRect &rect = skin->getBorder(); if (rect.grid[0]) { - Image *image = rect.grid[0]; + Image *const image = rect.grid[0]; - ResourceManager *resman = ResourceManager::getInstance(); - ImageSet *imageSet = resman->getSubImageSet(image, w, h); + ResourceManager *const resman = ResourceManager::getInstance(); + ImageSet *const imageSet = resman->getSubImageSet(image, w, h); // image->incRef(); theme->unload(skin); diff --git a/src/gui/theme.h b/src/gui/theme.h index 79569808f..5498996dd 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -42,10 +42,10 @@ class ProgressBar; class Skin { public: - Skin(ImageRect skin, ImageRect images, const std::string &filePath, - const std::string &name = "", int padding = 3, - int titlePadding = 4, - std::map<std::string, int> *options = nullptr); + Skin(const ImageRect skin, const ImageRect images, + const std::string &filePath, const std::string &name = "", + const int padding = 3, const int titlePadding = 4, + std::map<std::string, int> *const options = nullptr); ~Skin(); @@ -78,7 +78,7 @@ class Skin /** * Returns the image used by a sticky button for this skin. */ - Image *getStickyImage(bool state) const + Image *getStickyImage(const bool state) const { return state ? mStickyImageDown : mStickyImageUp; } /** @@ -156,11 +156,11 @@ class Theme : public Palette, public ConfigListener static Image *getImageFromTheme(const std::string &path); static ImageSet *getImageSetFromTheme(const std::string &path, - int w, int h); + const int w, const int h); ImageSet *getImageSetFromThemeXml(const std::string &name, const std::string &name2, - int w, int h); + const int w, const int h) const; enum ThemePalette { BROWSERBOX = 0, @@ -257,26 +257,28 @@ class Theme : public Palette, public ConfigListener * * @return the requested color */ - inline static const gcn::Color &getThemeColor(int type, - int alpha = 255) + inline static const gcn::Color &getThemeColor(const int type, + const int alpha = 255) { return mInstance->getColor(type, alpha); } - static const gcn::Color &getThemeColor(char c, bool &valid) + static const gcn::Color &getThemeColor(const char c, bool &valid) { return mInstance->getColor(c, valid); } - static gcn::Color getProgressColor(int type, float progress); + static gcn::Color getProgressColor(const int type, + const float progress); /** * Loads a skin. */ Skin *load(const std::string &filename, const std::string &filename2, - bool full = true, const std::string + const bool full = true, const std::string &defaultPath = getThemePath()); - Skin *loadSkinRect(ImageRect &image, std::string name, - std::string name2, int start = 0, int end = 8); + Skin *loadSkinRect(ImageRect &image, const std::string &name, + const std::string &name2, const int start = 0, + const int end = 8); - void unload(Skin *skin); + void unload(Skin *const skin); /** * Updates the alpha values of all of the skins. @@ -286,21 +288,23 @@ class Theme : public Palette, public ConfigListener /** * Get the minimum opacity allowed to skins. */ - float getMinimumOpacity() + float getMinimumOpacity() const { return mMinimumOpacity; } /** * Set the minimum opacity allowed to skins. * Set a negative value to free the minimum allowed. */ - void setMinimumOpacity(float minimumOpacity); + void setMinimumOpacity(const float minimumOpacity); void optionChanged(const std::string &); - void loadRect(ImageRect &image, std::string name, std::string name2, - int start = 0, int end = 8); + void loadRect(ImageRect &image, const std::string &name, + const std::string &name2, const int start = 0, + const int end = 8); - void unloadRect(ImageRect &rect, int start = 0, int end = 8); + void unloadRect(const ImageRect &rect, const int start = 0, + const int end = 8) const; static Image *getImageFromThemeXml(const std::string &name, const std::string &name2); @@ -309,7 +313,7 @@ class Theme : public Palette, public ConfigListener Theme(); ~Theme(); - Skin *readSkin(const std::string &filename0, bool full); + Skin *readSkin(const std::string &filename0, const bool full); // Map containing all window skins typedef std::map<std::string, Skin*> Skins; diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 56ba3aa7b..e2db704f6 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -172,7 +172,7 @@ void TradeWindow::setMoney(const int amount) } void TradeWindow::addItem(const int id, const bool own, const int quantity, - const int refine, const unsigned char color) + const int refine, const unsigned char color) const { if (own) mMyInventory->addItem(id, quantity, refine, color); @@ -182,7 +182,7 @@ void TradeWindow::addItem(const int id, const bool own, const int quantity, void TradeWindow::addItem2(const int id, const bool own, const int quantity, const int refine, const unsigned char color, - const bool equipment) + const bool equipment) const { if (own) mMyInventory->addItem(id, quantity, refine, color, equipment); @@ -191,7 +191,7 @@ void TradeWindow::addItem2(const int id, const bool own, const int quantity, } void TradeWindow::changeQuantity(const int index, const bool own, - const int quantity) + const int quantity) const { if (own) { @@ -206,7 +206,7 @@ void TradeWindow::changeQuantity(const int index, const bool own, } void TradeWindow::increaseQuantity(const int index, const bool own, - const int quantity) + const int quantity) const { if (own) { @@ -254,7 +254,7 @@ void TradeWindow::receivedOk(const bool own) } void TradeWindow::tradeItem(Item *const item, const int quantity, - const bool check) + const bool check) const { if (check && !checkItem(item)) return; diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h index 09c918794..892255fb6 100644 --- a/src/gui/tradewindow.h +++ b/src/gui/tradewindow.h @@ -71,7 +71,7 @@ class TradeWindow : public Window, * Add an item to the trade window. */ void addItem(const int id, const bool own, const int quantity, - const int refine, const unsigned char color); + const int refine, const unsigned char color) const; /** * Reset both item containers @@ -83,18 +83,18 @@ class TradeWindow : public Window, */ void addItem2(const int id, const bool own, const int quantity, const int refine, const unsigned char color, - const bool equipment); + const bool equipment) const; /** * Change quantity of an item. */ void changeQuantity(const int index, const bool own, - const int quantity); + const int quantity) const; /** * Increase quantity of an item. */ - void increaseQuantity(int index, bool own, int quantity); + void increaseQuantity(int index, bool own, int quantity) const; /** * Player received ok message from server @@ -105,7 +105,7 @@ class TradeWindow : public Window, * Send trade packet. */ void tradeItem(Item *const item, const int quantity, - const bool check = false); + const bool check = false) const; /** * Updates the labels and makes sure only one item is selected in diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 5e1850daa..6464ce7e7 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -44,14 +44,14 @@ #include "debug.h" -UnRegisterDialog::UnRegisterDialog(LoginData *data): +UnRegisterDialog::UnRegisterDialog(LoginData *const data): Window(_("Unregister"), true, nullptr, "unregister.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { - gcn::Label *userLabel = new Label(strprintf(_("Name: %s"), mLoginData-> - username.c_str())); - gcn::Label *passwordLabel = new Label(_("Password:")); + gcn::Label *const userLabel = new Label(strprintf(_("Name: %s"), + mLoginData->username.c_str())); + gcn::Label *const passwordLabel = new Label(_("Password:")); mPasswordField = new PasswordField(mLoginData->password); mUnRegisterButton = new Button(_("Unregister"), "unregister", this); mCancelButton = new Button(_("Cancel"), "cancel", this); @@ -109,8 +109,10 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) std::stringstream errorMsg; bool error = false; - unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); - unsigned int max = Net::getLoginHandler()->getMaxPasswordLength(); + const unsigned int min = Net::getLoginHandler() + ->getMinPasswordLength(); + const unsigned int max = Net::getLoginHandler() + ->getMaxPasswordLength(); // Check password if (password.length() < min) @@ -132,7 +134,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) { mWrongDataNoticeListener->setTarget(this->mPasswordField); - OkDialog *dlg = new OkDialog(_("Error"), + OkDialog *const dlg = new OkDialog(_("Error"), errorMsg.str(), DIALOG_ERROR); dlg->addActionListener(mWrongDataNoticeListener); } diff --git a/src/gui/unregisterdialog.h b/src/gui/unregisterdialog.h index 0126fa01b..8a3be85d9 100644 --- a/src/gui/unregisterdialog.h +++ b/src/gui/unregisterdialog.h @@ -50,7 +50,7 @@ class UnRegisterDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - UnRegisterDialog(LoginData *loginData); + UnRegisterDialog(LoginData *const loginData); ~UnRegisterDialog(); diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 7ca6d665c..71e2a1022 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -67,7 +67,7 @@ std::vector<updateFile> loadXMLFile(const std::string &fileName) { std::vector<updateFile> files; XML::Document doc(fileName, false); - XmlNodePtr rootNode = doc.rootNode(); + const XmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlNameEqual(rootNode, "updates")) { @@ -134,8 +134,8 @@ std::vector<updateFile> loadTxtFile(const std::string &fileName) UpdaterWindow::UpdaterWindow(const std::string &updateHost, const std::string &updatesDir, - bool applyUpdates, - int updateType): + const bool applyUpdates, + const int updateType): Window(_("Updating..."), false, nullptr, "update.xml"), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), @@ -213,7 +213,7 @@ UpdaterWindow::~UpdaterWindow() free(mMemoryBuffer); } -void UpdaterWindow::setProgress(float p) +void UpdaterWindow::setProgress(const float p) { // Do delayed progress bar update, since Guichan isn't thread-safe MutexLocker lock(&mDownloadMutex); @@ -296,7 +296,7 @@ void UpdaterWindow::loadNews() mMemoryBuffer[mDownloadedBytes] = '\0'; mBrowserBox->clearRows(); // Tokenize and add each line separately - char *line = strtok(mMemoryBuffer, "\n"); + const char *line = strtok(mMemoryBuffer, "\n"); std::string newsName = mUpdatesDir + "/local/help/news.txt"; mkdir_r((mUpdatesDir + "/local/help/").c_str()); @@ -310,7 +310,7 @@ void UpdaterWindow::loadNews() { firstLine = false; std::string str = line; - size_t i = str.find("##9 Latest client version: ##6"); + const size_t i = str.find("##9 Latest client version: ##6"); if (!i) { line = strtok(nullptr, "\n"); @@ -397,7 +397,7 @@ void UpdaterWindow::loadPatch() int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status, size_t dt, size_t dn) { - UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(ptr); + UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(ptr); if (!uw) return -1; @@ -453,8 +453,8 @@ int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status, size_t UpdaterWindow::memoryWrite(void *ptr, size_t size, size_t nmemb, void *stream) { - UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(stream); - size_t totalMem = size * nmemb; + UpdaterWindow *const uw = reinterpret_cast<UpdaterWindow *>(stream); + const size_t totalMem = size * nmemb; uw->mMemoryBuffer = static_cast<char*>(realloc(uw->mMemoryBuffer, uw->mDownloadedBytes + totalMem)); if (uw->mMemoryBuffer) @@ -514,7 +514,7 @@ void UpdaterWindow::download() void UpdaterWindow::loadUpdates() { - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); if (mUpdateFiles.empty()) { // updates not downloaded @@ -538,9 +538,9 @@ void UpdaterWindow::loadUpdates() loadManaPlusUpdates(mUpdatesDir, resman); } -void UpdaterWindow::loadLocalUpdates(std::string dir) +void UpdaterWindow::loadLocalUpdates(const std::string &dir) { - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); std::vector<updateFile> updateFiles = loadXMLFile(dir + "/" + xmlUpdateFile); @@ -563,8 +563,8 @@ void UpdaterWindow::loadLocalUpdates(std::string dir) loadManaPlusUpdates(dir, resman); } -void UpdaterWindow::loadManaPlusUpdates(std::string dir, - ResourceManager *resman) +void UpdaterWindow::loadManaPlusUpdates(const std::string &dir, + ResourceManager *const resman) { std::string fixPath = dir + "/fix"; std::vector<updateFile> updateFiles @@ -584,9 +584,11 @@ void UpdaterWindow::loadManaPlusUpdates(std::string dir, } } -void UpdaterWindow::addUpdateFile(ResourceManager *resman, std::string path, - std::string fixPath, std::string file, - bool append) +void UpdaterWindow::addUpdateFile(ResourceManager *const resman, + const std::string &path, + const std::string &fixPath, + const std::string &file, + const bool append) { if (!append) resman->addToSearchPath(path + "/" + file, append); @@ -825,13 +827,14 @@ void UpdaterWindow::logic() } } -bool UpdaterWindow::validateFile(std::string filePath, unsigned long hash) +bool UpdaterWindow::validateFile(const std::string &filePath, + const unsigned long hash) { FILE *file = fopen(filePath.c_str(), "rb"); if (!file) return false; - unsigned long adler = Net::Download::fadler32(file); + const unsigned long adler = Net::Download::fadler32(file); fclose(file); return adler == hash; } diff --git a/src/gui/updaterwindow.h b/src/gui/updaterwindow.h index 90bd06847..616b0d824 100644 --- a/src/gui/updaterwindow.h +++ b/src/gui/updaterwindow.h @@ -79,7 +79,7 @@ class UpdaterWindow : public Window, */ UpdaterWindow(const std::string &updateHost, const std::string &updatesDir, - bool applyUpdates, int updateType); + const bool applyUpdates, const int updateType); /** * Destructor @@ -89,7 +89,7 @@ class UpdaterWindow : public Window, /** * Set's progress bar status */ - void setProgress(float p); + void setProgress(const float p); /** * Set's label above progress @@ -117,13 +117,16 @@ class UpdaterWindow : public Window, void handleLink(const std::string &link, gcn::MouseEvent *event A_UNUSED); - static void loadLocalUpdates(std::string dir); + static void loadLocalUpdates(const std::string &dir); - static void addUpdateFile(ResourceManager *resman, std::string path, - std::string fixPath, std::string file, - bool append); + static void addUpdateFile(ResourceManager *const resman, + const std::string &path, + const std::string &fixPath, + const std::string &file, + const bool append); - static void loadManaPlusUpdates(std::string dir, ResourceManager *resman); + static void loadManaPlusUpdates(const std::string &dir, + ResourceManager *const resman); int updateState; @@ -148,7 +151,8 @@ private: static size_t memoryWrite(void *ptr, size_t size, size_t nmemb, void *stream); - bool validateFile(std::string filePath, unsigned long hash); + static bool validateFile(const std::string &filePath, + const unsigned long hash); enum UpdateDownloadStatus { diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index e6193baf7..a808e865b 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -96,7 +96,7 @@ class UserPalette : public Palette, public gcn::ListModel * * @return the requested committed color */ - inline const gcn::Color &getCommittedColor(int type) + inline const gcn::Color &getCommittedColor(const int type) const { return mColors[type].committedColor; } @@ -108,7 +108,7 @@ class UserPalette : public Palette, public gcn::ListModel * * @return the requested test color */ - inline const gcn::Color &getTestColor(int type) const + inline const gcn::Color &getTestColor(const int type) const { return mColors[type].testColor; } /** @@ -117,7 +117,7 @@ class UserPalette : public Palette, public gcn::ListModel * @param type the color type requested * @param color the color that should be tested */ - inline void setTestColor(int type, gcn::Color color) + inline void setTestColor(const int type, const gcn::Color color) { mColors[type].testColor = color; } /** @@ -142,7 +142,7 @@ class UserPalette : public Palette, public gcn::ListModel * * @param grad gradient type to set */ - void setGradientDelay(int type, int delay) + void setGradientDelay(const int type, const int delay) { mColors[type].delay = delay; } /** diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index f1c908807..29b438fea 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -116,7 +116,7 @@ void GuildManager::chat(std::string msg) mTab->chatLog(player_node->getName(), msg); } -void GuildManager::getNames(StringVect &names) +void GuildManager::getNames(StringVect &names) const { const Guild *const guild = createGuild(); if (guild) @@ -428,22 +428,22 @@ bool GuildManager::process(std::string msg) return false; } -void GuildManager::kick(std::string msg) +void GuildManager::kick(std::string msg) const { send("!remove " + msg); } -void GuildManager::invite(std::string msg) +void GuildManager::invite(std::string msg) const { send("!invite " + msg); } -void GuildManager::leave() +void GuildManager::leave() const { send("!leave"); } -void GuildManager::notice(std::string msg) +void GuildManager::notice(std::string msg) const { if (msg.empty()) send("!removemotd"); @@ -461,7 +461,7 @@ void GuildManager::clear() const } } -void GuildManager::inviteResponse(const bool response) +void GuildManager::inviteResponse(const bool response) const { if (response) send("yes"); diff --git a/src/guildmanager.h b/src/guildmanager.h index 75cc59eb6..4aa2901e6 100644 --- a/src/guildmanager.h +++ b/src/guildmanager.h @@ -43,7 +43,7 @@ class GuildManager bool processGuildMessage(std::string msg); - void getNames(StringVect &names); + void getNames(StringVect &names) const; void requestGuildInfo(); @@ -52,13 +52,13 @@ class GuildManager static bool getEnableGuildBot() { return mEnableGuildBot; } - void kick(std::string msg); + void kick(std::string msg) const; - void invite(std::string msg); + void invite(std::string msg) const; - void leave(); + void leave() const; - void notice(std::string msg); + void notice(std::string msg) const; void createTab(Guild *const guild); @@ -68,7 +68,7 @@ class GuildManager void reload(); - void inviteResponse(const bool response); + void inviteResponse(const bool response) const; bool afterRemove(); diff --git a/src/map.cpp b/src/map.cpp index 082c45857..c1905e3bb 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1259,7 +1259,7 @@ void Map::updatePortalTile(const std::string &name, int type, } } -MapItem *Map::findPortalXY(int x, int y) +MapItem *Map::findPortalXY(int x, int y) const { for (std::vector<MapItem*>::const_iterator it = mMapPortals.begin(), it_end = mMapPortals.end(); it != it_end; ++it) @@ -346,7 +346,7 @@ class Map : public Properties, public ConfigListener void optionChanged(const std::string &value); - MapItem *findPortalXY(int x, int y); + MapItem *findPortalXY(int x, int y) const; int getActorsCount() const { return static_cast<int>(mActors.size()); } diff --git a/src/maplayer.h b/src/maplayer.h index 03bb86409..19201ec43 100644 --- a/src/maplayer.h +++ b/src/maplayer.h @@ -257,13 +257,13 @@ class MapItem int getY() const { return mY; } - std::string &getComment() + const std::string &getComment() const { return mComment; } void setComment(std::string comment) { mComment = comment; } - std::string &getName() + const std::string &getName() const { return mName; } void setName(std::string name) diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp index 32ab1f6c2..5e0fc8a5c 100644 --- a/src/normalopenglgraphics.cpp +++ b/src/normalopenglgraphics.cpp @@ -220,7 +220,8 @@ bool NormalOpenGLGraphics::drawImage2(const Image *const image, srcY += image->mBounds.y; if (!useColor) - glColor4f(1.0f, 1.0f, 1.0f, image->mAlpha); + glColor4ub(255, 255, 255, image->mAlpha * 255); +// glColor4f(1.0f, 1.0f, 1.0f, image->mAlpha); #ifdef DEBUG_BIND_TEXTURE debugBindTexture(image); |