diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-27 21:18:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-08-27 21:44:17 +0300 |
commit | 7c79aa2b8e484319e3e511fa21db6d2448347024 (patch) | |
tree | 3c4fb4e72414dd8c0d93401a6bf2cc86b65a34a0 /src | |
parent | de476bb95242e10c833394ef007728072eabe60f (diff) | |
download | mv-7c79aa2b8e484319e3e511fa21db6d2448347024.tar.gz mv-7c79aa2b8e484319e3e511fa21db6d2448347024.tar.bz2 mv-7c79aa2b8e484319e3e511fa21db6d2448347024.tar.xz mv-7c79aa2b8e484319e3e511fa21db6d2448347024.zip |
Add const to more classes.
Diffstat (limited to 'src')
31 files changed, 326 insertions, 323 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 69bba3d93..fcef420bd 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -89,7 +89,7 @@ public: InventoryWindow::WindowList InventoryWindow::instances; -InventoryWindow::InventoryWindow(Inventory *inventory): +InventoryWindow::InventoryWindow(Inventory *const inventory): Window("Inventory", false, nullptr, "inventory.xml"), mInventory(inventory), mDropButton(nullptr), @@ -125,14 +125,14 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mItems = new ItemContainer(mInventory); mItems->addSelectionListener(this); - gcn::ScrollArea *invenScroll = new ScrollArea( + gcn::ScrollArea *const invenScroll = new ScrollArea( mItems, getOptionBool("showbackground"), "inventory_background.xml"); invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mSlotsLabel = new Label(_("Slots:")); mSlotsBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS); - int size = config.getIntValue("fontSize"); + const int size = config.getIntValue("fontSize"); mFilter = new TabStrip("filter_" + getWindowName(), size + 8); mFilter->addActionListener(this); mFilter->setActionEventId("tag_"); @@ -286,7 +286,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event) if (!inventoryWindow || !inventoryWindow->isVisible()) return; - Item *item = inventoryWindow->getSelectedItem(); + Item *const item = inventoryWindow->getSelectedItem(); if (!item) return; @@ -310,7 +310,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event) return; } - Item *item = mItems->getSelectedItem(); + Item *const item = mItems->getSelectedItem(); if (!item) return; @@ -411,7 +411,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT) { - Item *item = mItems->getSelectedItem(); + Item *const item = mItems->getSelectedItem(); if (!item) return; @@ -432,7 +432,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) if (event.getButton() == gcn::MouseEvent::LEFT || event.getButton() == gcn::MouseEvent::RIGHT) { - Item *item = mItems->getSelectedItem(); + Item *const item = mItems->getSelectedItem(); if (!item) return; @@ -545,7 +545,7 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED) if (!mInventory || !mInventory->isMainInventory()) return; - Item *item = mItems->getSelectedItem(); + Item *const item = mItems->getSelectedItem(); if (mSplit && item && Net::getInventoryHandler()-> canSplit(mItems->getSelectedItem())) @@ -556,12 +556,12 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED) updateButtons(item); } -void InventoryWindow::updateButtons(Item *item) +void InventoryWindow::updateButtons(const Item *item) { if (!mInventory || !mInventory->isMainInventory()) return; - Item *selectedItem = mItems->getSelectedItem(); + Item *const selectedItem = mItems->getSelectedItem(); if (item && selectedItem != item) return; @@ -605,7 +605,7 @@ void InventoryWindow::updateButtons(Item *item) } } -void InventoryWindow::setSplitAllowed(bool allowed) +void InventoryWindow::setSplitAllowed(const bool allowed) { mSplitButton->setVisible(allowed); } @@ -628,7 +628,7 @@ void InventoryWindow::processEvent(Channels channel A_UNUSED, { if (event.getName() == EVENT_UPDATEATTRIBUTE) { - int id = event.getInt("id"); + const int id = event.getInt("id"); if (id == PlayerInfo::TOTAL_WEIGHT || id == PlayerInfo::MAX_WEIGHT) updateWeight(); } @@ -639,8 +639,8 @@ void InventoryWindow::updateWeight() if (!isMainInventory()) return; - int total = PlayerInfo::getAttribute(PlayerInfo::TOTAL_WEIGHT); - int max = PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT); + const int total = PlayerInfo::getAttribute(PlayerInfo::TOTAL_WEIGHT); + const int max = PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT); if (max <= 0) return; @@ -652,7 +652,7 @@ void InventoryWindow::updateWeight() Units::formatWeight(max).c_str())); } -void InventoryWindow::slotsChanged(Inventory* inventory) +void InventoryWindow::slotsChanged(Inventory *const inventory) { if (inventory == mInventory) { @@ -682,14 +682,15 @@ void InventoryWindow::updateDropButton() } else { - Item *item = nullptr; if (mItems) - item = mItems->getSelectedItem(); + { + const Item *const item = mItems->getSelectedItem(); - if (item && item->getQuantity() > 1) - mDropButton->setCaption(_("Drop...")); - else - mDropButton->setCaption(_("Drop")); + if (item && item->getQuantity() > 1) + mDropButton->setCaption(_("Drop...")); + else + mDropButton->setCaption(_("Drop")); + } } } diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 7829c40b6..fd86db6ea 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -66,7 +66,7 @@ class InventoryWindow : public Window, /** * Constructor. */ - InventoryWindow(Inventory *inventory); + InventoryWindow(Inventory *const inventory); /** * Destructor. @@ -116,7 +116,7 @@ class InventoryWindow : public Window, /** * Sets whether the split button should be shown. */ - void setSplitAllowed(bool allowed); + void setSplitAllowed(const bool allowed); /** * Closes the Storage Window, as well as telling the server that the @@ -124,7 +124,7 @@ class InventoryWindow : public Window, */ void close(); - void slotsChanged(Inventory* inventory); + void slotsChanged(Inventory *const inventory); bool isMainInventory() const { return mInventory->isMainInventory(); } @@ -139,7 +139,7 @@ class InventoryWindow : public Window, void processEvent(Channels channel, const DepricatedEvent &event); - void updateButtons(Item *item = nullptr); + void updateButtons(const Item *item = nullptr); bool isInputFocused() const; diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index a9498f1b9..d950a1dd4 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -97,7 +97,8 @@ private: StringVect mStrings; }; -void ItemAmountWindow::finish(Item *item, int amount, int price, Usage usage) +void ItemAmountWindow::finish(Item *const item, const int amount, + const int price, const Usage usage) { switch (usage) { @@ -132,8 +133,8 @@ void ItemAmountWindow::finish(Item *item, int amount, int price, Usage usage) } } -ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, - int maxRange): +ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, + Item *const item, const int maxRange) : Window("", true, parent, "amount.xml"), mItemPriceTextField(nullptr), mGPLabel(nullptr), @@ -196,15 +197,15 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, } //Item icon - Image *image = item->getImage(); + Image *const image = item->getImage(); mItemIcon = new Icon(image); // Buttons - Button *minusAmountButton = new Button(_("-"), "dec", this); - Button *plusAmountButton = new Button(_("+"), "inc", this); - Button *okButton = new Button(_("OK"), "ok", this); - Button *cancelButton = new Button(_("Cancel"), "cancel", this); - Button *addAllButton = new Button(_("All"), "all", this); + Button *const minusAmountButton = new Button(_("-"), "dec", this); + Button *const plusAmountButton = new Button(_("+"), "inc", this); + Button *const okButton = new Button(_("OK"), "ok", this); + Button *const cancelButton = new Button(_("Cancel"), "cancel", this); + Button *const addAllButton = new Button(_("All"), "all", this); minusAmountButton->adjustSize(); minusAmountButton->setWidth(plusAmountButton->getWidth()); @@ -228,8 +229,8 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd) { - Button *minusPriceButton = new Button(_("-"), "decPrice", this); - Button *plusPriceButton = new Button(_("+"), "incPrice", this); + Button *const minusPriceButton = new Button(_("-"), "decPrice", this); + Button *const plusPriceButton = new Button(_("+"), "incPrice", this); minusPriceButton->adjustSize(); minusPriceButton->setWidth(plusPriceButton->getWidth()); @@ -347,7 +348,7 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) std::string str = mItemsModal->getElementAt( mItemDropDown->getSelected()); - int id = ItemDB::get(str).getId(); + const int id = ItemDB::get(str).getId(); mItem = new Item(id, 10000); @@ -356,8 +357,7 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) else if (!mMax) mMax = mItem->getQuantity(); - Image *image = mItem->getImage(); - mItemIcon->setImage(image); + mItemIcon->setImage(mItem->getImage()); } int amount = mItemAmountTextField->getValue(); @@ -416,8 +416,8 @@ void ItemAmountWindow::keyReleased(gcn::KeyEvent &keyEvent A_UNUSED) mItemAmountSlide->setValue(mItemAmountTextField->getValue()); } -void ItemAmountWindow::showWindow(Usage usage, Window *parent, Item *item, - int maxRange) +void ItemAmountWindow::showWindow(const Usage usage, Window *const parent, + Item *const item, int maxRange) { if (!item) return; diff --git a/src/gui/itemamountwindow.h b/src/gui/itemamountwindow.h index 0e692dac2..c06d9a618 100644 --- a/src/gui/itemamountwindow.h +++ b/src/gui/itemamountwindow.h @@ -86,16 +86,17 @@ class ItemAmountWindow : public Window, /** * Creates the dialog, or bypass it if there aren't enough items. */ - static void showWindow(Usage usage, Window *parent, Item *item, - int maxRange = 0); + static void showWindow(const Usage usage, Window *const parent, + Item *const item, int maxRange = 0); ~ItemAmountWindow(); private: - static void finish(Item *item, int amount, int price, Usage usage); + static void finish(Item *const item, const int amount, + const int price, const Usage usage); - ItemAmountWindow(Usage usage, Window *parent, Item *item, - int maxRange = 0); + ItemAmountWindow(const Usage usage, Window *const parent, + Item *const item, const int maxRange = 0); IntTextField *mItemAmountTextField; /**< Item amount caption. */ IntTextField *mItemPriceTextField; /**< Item price caption. */ diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index fa65c7a42..feb9a050d 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -98,7 +98,7 @@ ItemPopup::~ItemPopup() } } -void ItemPopup::setItem(const Item *item, bool showImage) +void ItemPopup::setItem(const Item *const item, const bool showImage) { if (!item) return; @@ -120,14 +120,14 @@ void ItemPopup::setItem(const Item *item, bool showImage) ii.getName().c_str(), item->getRefine(), ii.getId())); } mItemName->adjustSize(); - unsigned minWidth = mItemName->getWidth() + 8; + const unsigned minWidth = mItemName->getWidth() + 8; if (static_cast<unsigned>(getWidth()) < minWidth) setWidth(minWidth); } } -void ItemPopup::setItem(const ItemInfo &item, unsigned char color, - bool showImage, int id) +void ItemPopup::setItem(const ItemInfo &item, const unsigned char color, + const bool showImage, int id) { if (!mIcon || (item.getName() == mLastName && color == mLastColor)) return; @@ -137,26 +137,25 @@ void ItemPopup::setItem(const ItemInfo &item, unsigned char color, int space = 0; - Image *oldImage = mIcon->getImage(); + Image *const oldImage = mIcon->getImage(); if (oldImage) oldImage->decRef(); if (showImage) { - ResourceManager *resman = ResourceManager::getInstance(); - logger->log("img: " + combineDye2( - paths.getStringValue("itemIcons") - + item.getDisplay().image, item.getDyeColorsString(color))); - Image *image = resman->getImage(combineDye2( + ResourceManager *const resman = ResourceManager::getInstance(); +// logger->log("img: " + combineDye2( +// paths.getStringValue("itemIcons") +// + item.getDisplay().image, item.getDyeColorsString(color))); + Image *const image = resman->getImage(combineDye2( paths.getStringValue("itemIcons") + item.getDisplay().image, item.getDyeColorsString(color))); mIcon->setImage(image); if (image) { - int x = getPadding(); - int y = getPadding(); - mIcon->setPosition(x, y); + const int pad = getPadding(); + mIcon->setPosition(pad, pad); space = mIcon->getWidth(); } } @@ -233,7 +232,7 @@ void ItemPopup::setItem(const ItemInfo &item, unsigned char color, (numRowsDesc + getPadding()) * height); } -gcn::Color ItemPopup::getColor(ItemType type) +gcn::Color ItemPopup::getColor(const ItemType type) { switch (type) { diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index e6cda2eae..dd2bae83d 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -60,10 +60,10 @@ class ItemPopup : public Popup /** * Sets the info to be displayed given a particular item. */ - void setItem(const ItemInfo &item, unsigned char color, - bool showImage = false, int id = -1); + void setItem(const ItemInfo &item, const unsigned char color, + const bool showImage = false, int id = -1); - void setItem(const Item *item, bool showImage = false); + void setItem(const Item *const item, const bool showImage = false); void mouseMoved(gcn::MouseEvent &mouseEvent); @@ -77,7 +77,7 @@ class ItemPopup : public Popup std::string mLastName; unsigned char mLastColor; - static gcn::Color getColor(ItemType type); + static gcn::Color getColor(const ItemType type); }; #endif // ITEMPOPUP_H diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 564eba642..8c9fe8757 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -58,7 +58,7 @@ KillStats::KillStats(): setDefaultSize(250, 250, 350, 300); listen(CHANNEL_ATTRIBUTES); - int xp(PlayerInfo::getAttribute(PlayerInfo::EXP)); + const int xp(PlayerInfo::getAttribute(PlayerInfo::EXP)); int xpNextLevel(PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)); mResetButton = new Button(_("Reset stats"), "reset", this); @@ -184,7 +184,7 @@ void KillStats::gainXp(int xp) if (!mKillCounter) mKillCounter = 1; - float AvgExp = static_cast<float>(mExpCounter / mKillCounter); + const float AvgExp = static_cast<float>(mExpCounter / mKillCounter); int xpNextLevel(PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)); if (mKillTimer == 0) @@ -246,12 +246,12 @@ void KillStats::gainXp(int xp) void KillStats::recalcStats() { - int curTime = cur_time; + const int curTime = cur_time; // Need Update Exp Counter if (curTime - m1minExpTime > 60) { - int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); + const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); if (m1minExpTime != 0) m1minSpeed = newExp - m1minExpNum; else @@ -262,7 +262,7 @@ void KillStats::recalcStats() if (curTime - m5minExpTime > 60*5) { - int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); + const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); if (m5minExpTime != 0) m5minSpeed = newExp - m5minExpNum; else @@ -273,7 +273,7 @@ void KillStats::recalcStats() if (curTime - m15minExpTime > 60*15) { - int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); + const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); if (m15minExpTime != 0) m15minSpeed = newExp - m15minExpNum; else @@ -376,7 +376,7 @@ void KillStats::updateJackoLabel() } } -void KillStats::jackoDead(int id) +void KillStats::jackoDead(const int id) { if (id == mJackoId && mIsJackoAlive) { @@ -387,12 +387,6 @@ void KillStats::jackoDead(int id) } } -void KillStats::addLog(std::string str) -{ - if (debugChatTab) - debugChatTab->chatLog(str, BY_SERVER); -} - void KillStats::jackoAlive(int id) { if (!mIsJackoAlive) @@ -411,7 +405,7 @@ void KillStats::validateJacko() if (!actorSpriteManager || !player_node) return; - Map *currentMap = Game::instance()->getCurrentMap(); + const Map *const currentMap = Game::instance()->getCurrentMap(); if (currentMap) { if (currentMap->getProperty("_realfilename") == "018-1" @@ -422,7 +416,8 @@ void KillStats::validateJacko() && player_node->getTileY() >= 21 && player_node->getTileY() <= 46) { - Being *dstBeing = actorSpriteManager->findBeingByName( + const Being *const dstBeing + = actorSpriteManager->findBeingByName( "Jack O", Being::MONSTER); if (mIsJackoAlive && !dstBeing) { @@ -443,7 +438,7 @@ void KillStats::processEvent(Channels channel A_UNUSED, { if (event.getName() == EVENT_UPDATEATTRIBUTE) { - int id = event.getInt("id"); + const int id = event.getInt("id"); if (id == PlayerInfo::EXP || id == PlayerInfo::EXP_NEEDED) { gainXp(event.getInt("newValue") - event.getInt("oldValue")); diff --git a/src/gui/killstats.h b/src/gui/killstats.h index 6f21fc6ed..fdc932735 100644 --- a/src/gui/killstats.h +++ b/src/gui/killstats.h @@ -54,6 +54,7 @@ class KillStats : public Window, private gcn::ActionListener, public Listener * Stuff. */ void action(const gcn::ActionEvent &event); + void gainXp(int Xp); /** @@ -76,12 +77,10 @@ class KillStats : public Window, private gcn::ActionListener, public Listener */ void updateJackoLabel(); - void jackoDead(int id); + void jackoDead(const int id); void jackoAlive(int id); - void addLog(std::string str); - void processEvent(Channels channel A_UNUSED, const DepricatedEvent &event); diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 804a46bad..e105911e8 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -80,7 +80,7 @@ public: class UpdateListModel : public gcn::ListModel { public: - UpdateListModel(LoginData *data) : + UpdateListModel(LoginData *const data) : gcn::ListModel(), mLoginData(data) { @@ -107,18 +107,18 @@ class UpdateListModel : public gcn::ListModel LoginData *mLoginData; }; -LoginDialog::LoginDialog(LoginData *data, std::string serverName, - std::string *updateHost): +LoginDialog::LoginDialog(LoginData *const data, std::string serverName, + std::string *const updateHost): Window(_("Login"), false, nullptr, "login.xml"), mLoginData(data), mUpdateHost(updateHost), mServerName(serverName) { - gcn::Label *serverLabel1 = new Label(_("Server:")); - gcn::Label *serverLabel2 = new Label(serverName); + gcn::Label *const serverLabel1 = new Label(_("Server:")); + gcn::Label *const serverLabel2 = new Label(serverName); serverLabel2->adjustSize(); - gcn::Label *userLabel = new Label(_("Name:")); - gcn::Label *passLabel = new Label(_("Password:")); + gcn::Label *const userLabel = new Label(_("Name:")); + gcn::Label *const passLabel = new Label(_("Password:")); if (mLoginData && mLoginData->updateHosts.size() > 1) { mUpdateHostLabel = new Label(strprintf(_("Update host: %s"), diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h index 6adfd36bd..d85e88b8a 100644 --- a/src/gui/logindialog.h +++ b/src/gui/logindialog.h @@ -59,8 +59,8 @@ class LoginDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ - LoginDialog(LoginData *data, std::string serverName, - std::string *updateHost); + LoginDialog(LoginData *const data, std::string serverName, + std::string *const updateHost); ~LoginDialog(); diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 8cbeebad8..d928e6f8c 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -84,7 +84,7 @@ Minimap::~Minimap() } } -void Minimap::setMap(Map *map) +void Minimap::setMap(const Map *const map) { std::string caption(""); std::string minimapName; @@ -111,7 +111,7 @@ void Minimap::setMap(Map *map) { if (config.getBoolValue("showExtMinimaps")) { - SDL_Surface* surface = SDL_CreateRGBSurface(SDL_SWSURFACE, + SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_SWSURFACE, map->getWidth(), map->getHeight(), 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000); if (!surface) @@ -148,7 +148,7 @@ void Minimap::setMap(Map *map) { std::string tempname = paths.getStringValue("minimaps") + "graphics/minimaps/" + map->getFilename() + ".png"; - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); minimapName = map->getProperty("minimap"); @@ -208,7 +208,7 @@ void Minimap::draw(gcn::Graphics *graphics) if (!userPalette || !player_node || !viewport) return; - Graphics *graph = static_cast<Graphics*>(graphics); + Graphics *const graph = static_cast<Graphics*>(graphics); const gcn::Rectangle a = getChildrenArea(); @@ -256,7 +256,7 @@ void Minimap::draw(gcn::Graphics *graphics) if (!(*it) || (*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - const Being *being = static_cast<Being*>(*it); + const Being *const being = static_cast<const Being *const>(*it); if (!being) continue; @@ -318,11 +318,12 @@ void Minimap::draw(gcn::Graphics *graphics) if (player_node->isInParty()) { - Party *party = player_node->getParty(); + Party *const party = player_node->getParty(); if (party) { - PartyMember *m = party->getMember(player_node->getName()); - Party::MemberList *members = party->getMembers(); + const PartyMember *const m = party->getMember( + player_node->getName()); + Party::MemberList *const members = party->getMembers(); if (m && members) { const std::string curMap = m->getMap(); @@ -331,7 +332,7 @@ void Minimap::draw(gcn::Graphics *graphics) it_end = members->end(); while (it != it_end) { - PartyMember *member = *it; + const PartyMember *const member = *it; if (member && member->getMap() == curMap && member->getOnline() && member != m) { diff --git a/src/gui/minimap.h b/src/gui/minimap.h index 12835edd5..7a6f865f8 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -46,7 +46,7 @@ class Minimap : public Window /** * Sets the map image that should be displayed. */ - void setMap(Map *map); + void setMap(const Map *const map); /** * Toggles the displaying of the minimap. diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index e73cc5475..2c4fdda9c 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -69,8 +69,8 @@ MiniStatusWindow::MiniStatusWindow(): mMpBar = nullptr; } - int job = Net::getPlayerHandler()->getJobLocation() - && serverConfig.getValueBool("showJob", false); + const int job = Net::getPlayerHandler()->getJobLocation() + && serverConfig.getValueBool("showJob", false); mXpBar = createBar(0, 100, 20, Theme::PROG_EXP, "xp bar", _("experience bar")); @@ -111,7 +111,7 @@ MiniStatusWindow::MiniStatusWindow(): mTextPopup = new TextPopup(); addMouseListener(this); - Inventory *inv = PlayerInfo::getInventory(); + Inventory *const inv = PlayerInfo::getInventory(); if (inv) inv->addInventoyListener(this); @@ -129,7 +129,7 @@ MiniStatusWindow::~MiniStatusWindow() delete_all(mIcons); mIcons.clear(); - Inventory *inv = PlayerInfo::getInventory(); + Inventory *const inv = PlayerInfo::getInventory(); if (inv) inv->removeInventoyListener(this); @@ -144,11 +144,12 @@ MiniStatusWindow::~MiniStatusWindow() } } -ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height, - int color, std::string name, +ProgressBar *MiniStatusWindow::createBar(const float progress, + const int width, const int height, + const int color, std::string name, std::string description) { - ProgressBar *bar = new ProgressBar(progress, width, height, color); + ProgressBar *const bar = new ProgressBar(progress, width, height, color); bar->setActionEventId(name); bar->setId(description); mBars.push_back(bar); @@ -159,7 +160,7 @@ ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height, void MiniStatusWindow::updateBars() { int x = 0; - ProgressBar* lastBar = nullptr; + const ProgressBar *lastBar = nullptr; for (std::vector <ProgressBar*>::const_iterator it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) { @@ -168,7 +169,7 @@ void MiniStatusWindow::updateBars() for (std::vector <ProgressBar*>::const_iterator it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) { - ProgressBar *bar = *it; + ProgressBar *const bar = *it; if (!bar) continue; if (bar->isVisible()) @@ -187,7 +188,7 @@ void MiniStatusWindow::updateBars() } } -void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) +void MiniStatusWindow::setIcon(const int index, AnimatedSprite *const sprite) { if (index >= static_cast<int>(mIcons.size())) mIcons.resize(index + 1, nullptr); @@ -197,7 +198,7 @@ void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) mIcons[index] = sprite; } -void MiniStatusWindow::eraseIcon(int index) +void MiniStatusWindow::eraseIcon(const int index) { if (index < static_cast<int>(mIcons.size())) { @@ -206,7 +207,7 @@ void MiniStatusWindow::eraseIcon(int index) } } -void MiniStatusWindow::drawIcons(Graphics *graphics) +void MiniStatusWindow::drawIcons(Graphics *const graphics) { // Draw icons int icon_x = mStatusBar->getX() + mStatusBar->getWidth() + 4; @@ -225,7 +226,7 @@ void MiniStatusWindow::processEvent(Channels channel A_UNUSED, { if (event.getName() == EVENT_UPDATEATTRIBUTE) { - int id = event.getInt("id"); + const int id = event.getInt("id"); if (id == PlayerInfo::HP || id == PlayerInfo::MAX_HP) { StatusWindow::updateHPBar(mHpBar); @@ -339,7 +340,7 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) } else if (event.getSource() == mJobBar) { - std::pair<int, int> exp = PlayerInfo::getStatExperience( + const std::pair<int, int> exp = PlayerInfo::getStatExperience( Net::getPlayerHandler()->getJobLocation()); if (exp.first > exp.second) @@ -367,7 +368,7 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) } else if (event.getSource() == mInvSlotsBar) { - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (inv) { const int usedSlots = inv->getNumberOfSlotsUsed(); @@ -399,7 +400,7 @@ void MiniStatusWindow::mousePressed(gcn::MouseEvent &event) if (event.getButton() == gcn::MouseEvent::RIGHT) { - ProgressBar *bar = dynamic_cast<ProgressBar*>(event.getSource()); + ProgressBar *const bar = dynamic_cast<ProgressBar*>(event.getSource()); if (!bar) return; if (viewport) @@ -418,9 +419,9 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) mStatusPopup->hide(); } -void MiniStatusWindow::showBar(std::string name, bool visible) +void MiniStatusWindow::showBar(const std::string &name, const bool visible) { - ProgressBar *bar = mBarNames[name]; + ProgressBar *const bar = mBarNames[name]; if (!bar) return; bar->setVisible(visible); @@ -448,7 +449,7 @@ void MiniStatusWindow::loadBars() std::string str = config.getValue("ministatus" + toString(f), ""); if (str == "" || str == "status bar") continue; - ProgressBar *bar = mBarNames[str]; + ProgressBar *const bar = mBarNames[str]; if (!bar) continue; bar->setVisible(false); @@ -461,7 +462,7 @@ void MiniStatusWindow::saveBars() for (std::vector <ProgressBar*>::const_iterator it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) { - ProgressBar *bar = *it; + const ProgressBar *const bar = *it; if (!bar->isVisible()) { config.setValue("ministatus" + toString(i), @@ -475,7 +476,7 @@ void MiniStatusWindow::saveBars() config.setValue("ministatussaved", true); } -void MiniStatusWindow::slotsChanged(Inventory* inventory) +void MiniStatusWindow::slotsChanged(Inventory *const inventory) { if (!inventory) return; diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index dfc945689..d67cf8b03 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -53,11 +53,11 @@ class MiniStatusWindow : public Popup, /** * Sets one of the icons. */ - void setIcon(int index, AnimatedSprite *sprite); + void setIcon(const int index, AnimatedSprite *const sprite); - void eraseIcon(int index); + void eraseIcon(const int index); - void drawIcons(Graphics *graphics); + void drawIcons(Graphics *const graphics); void processEvent(Channels channel, const DepricatedEvent &event); @@ -73,13 +73,13 @@ class MiniStatusWindow : public Popup, void mouseExited(gcn::MouseEvent &event); - void showBar(std::string name, bool visible); + void showBar(const std::string &name, const bool visible); void updateBars(); void updateArrows(); - void slotsChanged(Inventory* inventory); + void slotsChanged(Inventory *const inventory); std::vector <ProgressBar*> &getBars() { return mBars; } @@ -87,9 +87,9 @@ class MiniStatusWindow : public Popup, private: bool isInBar(ProgressBar *bar, int x, int y) const; - ProgressBar *createBar(float progress, int width, int height, - int color, std::string name, - std::string description); + ProgressBar *createBar(const float progress, const int width, + const int height, const int color, + std::string name, std::string description); void loadBars(); diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 166cef5b1..85228c19a 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -59,7 +59,7 @@ NpcDialog::DialogList NpcDialog::instances; -NpcDialog::NpcDialog(int npcId) : +NpcDialog::NpcDialog(const int npcId) : Window(_("NPC"), false, nullptr, "npc.xml"), mNpcId(npcId), mLogInteraction(config.getBoolValue("logNpcInGui")), @@ -140,7 +140,7 @@ NpcDialog::NpcDialog(int npcId) : mPlusButton = new Button(_("+"), "inc", this); mMinusButton = new Button(_("-"), "dec", this); - gcn::Font *fnt = mButton->getFont(); + const gcn::Font *const fnt = mButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_WAITING), fnt->getWidth(CAPTION_NEXT)); width = std::max(width, fnt->getWidth(CAPTION_CLOSE)); @@ -226,7 +226,7 @@ void NpcDialog::setText(const std::string &text) } */ -void NpcDialog::addText(const std::string &text, bool save) +void NpcDialog::addText(const std::string &text, const bool save) { if (save || mLogInteraction) { @@ -279,7 +279,7 @@ void NpcDialog::action(const gcn::ActionEvent &event) if (mInputState == NPC_INPUT_LIST) { unsigned char choice = 0; - int selectedIndex = mItemList->getSelected(); + const int selectedIndex = mItemList->getSelected(); if (selectedIndex >= static_cast<int>(mItems.size()) || selectedIndex < 0 @@ -395,7 +395,7 @@ void NpcDialog::addChoice(const std::string &choice) void NpcDialog::parseListItems(const std::string &itemString) { std::istringstream iss(itemString); - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); std::string tmp; while (getline(iss, tmp, ':')) @@ -409,7 +409,8 @@ void NpcDialog::parseListItems(const std::string &itemString) else { mItems.push_back(tmp.substr(pos + 1)); - Image *img = resman->getImage(paths.getStringValue("guiIcons") + Image *const img = resman->getImage( + paths.getStringValue("guiIcons") + tmp.substr(0, pos) + ".png"); mImages.push_back(img); } @@ -464,7 +465,8 @@ bool NpcDialog::isAnyInputFocused() return false; } -void NpcDialog::integerRequest(int defaultValue, int min, int max) +void NpcDialog::integerRequest(const int defaultValue, const int min, + const int max) { mActionState = NPC_ACTION_INPUT; mInputState = NPC_INPUT_INTEGER; @@ -474,7 +476,7 @@ void NpcDialog::integerRequest(int defaultValue, int min, int max) buildLayout(); } -void NpcDialog::move(int amount) +void NpcDialog::move(const int amount) { if (mActionState != NPC_ACTION_INPUT) return; @@ -687,9 +689,9 @@ void NpcDialog::restoreCamera() mCameraMode = -1; } -void NpcDialog::showAvatar(int avatarId) +void NpcDialog::showAvatar(const int avatarId) { - bool needShow = (avatarId != 0); + const bool needShow = (avatarId != 0); if (needShow) { delete mAvatarBeing; @@ -698,13 +700,11 @@ void NpcDialog::showAvatar(int avatarId) if (!mAvatarBeing->empty()) { mAvatarBeing->logic(); - Sprite *sprite = mAvatarBeing->getSprite(0); + const Sprite *const sprite = mAvatarBeing->getSprite(0); if (sprite) { - int width = sprite->getWidth() + 2 * getPadding(); - mPlayerBox->setWidth(width); - int height = sprite->getHeight() + 2 * getPadding(); - mPlayerBox->setHeight(height); + mPlayerBox->setWidth(sprite->getWidth() + 2 * getPadding()); + mPlayerBox->setHeight(sprite->getHeight() + 2 * getPadding()); } } } @@ -725,16 +725,16 @@ void NpcDialog::showAvatar(int avatarId) } } -void NpcDialog::setAvatarDirection(uint8_t direction) +void NpcDialog::setAvatarDirection(const uint8_t direction) { - Being *being = mPlayerBox->getBeing(); + Being *const being = mPlayerBox->getBeing(); if (being) being->setDirection(direction); } -void NpcDialog::setAvatarAction(int actionId) +void NpcDialog::setAvatarAction(const int actionId) { - Being *being = mPlayerBox->getBeing(); + Being *const being = mPlayerBox->getBeing(); if (being) being->setAction(static_cast<Being::Action>(actionId)); } @@ -747,7 +747,7 @@ void NpcDialog::logic() mAvatarBeing->logic(); if (mPlayerBox->getWidth() < static_cast<signed>(3 * getPadding())) { - Sprite *sprite = mAvatarBeing->getSprite(0); + const Sprite *const sprite = mAvatarBeing->getSprite(0); if (sprite) { mPlayerBox->setWidth(sprite->getWidth() + 2 * getPadding()); diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index cd5f7fe57..2d7ed5149 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -64,7 +64,7 @@ class NpcDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ - NpcDialog(int npcId); + NpcDialog(const int npcId); ~NpcDialog(); @@ -86,7 +86,7 @@ class NpcDialog : public Window, public gcn::ActionListener, * * @param string The text to add. */ - void addText(const std::string &string, bool save = true); + void addText(const std::string &string, const bool save = true); /** * When called, the widget will show a "Next" button. @@ -155,10 +155,10 @@ class NpcDialog : public Window, public gcn::ActionListener, /** * Requests a interger from the user. */ - void integerRequest(int defaultValue = 0, int min = 0, - int max = 2147483647); + void integerRequest(const int defaultValue = 0, const int min = 0, + const int max = 2147483647); - void move(int amount); + void move(const int amount); void setVisible(bool visible); @@ -192,11 +192,11 @@ class NpcDialog : public Window, public gcn::ActionListener, void refocus(); - void showAvatar(int avatarId); + void showAvatar(const int avatarId); - void setAvatarDirection(uint8_t direction); + void setAvatarDirection(const uint8_t direction); - void setAvatarAction(int actionId); + void setAvatarAction(const int actionId); void logic(); diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index 30a6281eb..4b816794e 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -36,8 +36,8 @@ #include "debug.h" OkDialog::OkDialog(const std::string &title, const std::string &msg, - int soundEvent, bool modal, bool showCenter, - Window *parent): + const int soundEvent, const bool modal, + const bool showCenter, Window *const parent): Window(title, modal, parent, "ok.xml") { mTextBox = new TextBox; @@ -45,7 +45,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, mTextBox->setOpaque(false); mTextBox->setTextWrapped(msg, 260); - gcn::Button *okButton = new Button(_("OK"), "ok", this); + gcn::Button *const okButton = new Button(_("OK"), "ok", this); const int numRows = mTextBox->getNumberOfRows(); const int fontHeight = getFont()->getHeight(); diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h index b6f17480b..676fe4a80 100644 --- a/src/gui/okdialog.h +++ b/src/gui/okdialog.h @@ -52,8 +52,8 @@ class OkDialog : public Window, public gcn::ActionListener * @see Window::Window */ OkDialog(const std::string &title, const std::string &msg, - int soundEvent = DIALOG_OK, bool modal = true, - bool showCenter = true, Window *parent = nullptr); + const int soundEvent = DIALOG_OK, const bool modal = true, + const bool showCenter = true, Window *const parent = nullptr); /** * Called when receiving actions from the widgets. diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 93257c6c3..3095e7ce8 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -122,9 +122,9 @@ OutfitWindow::~OutfitWindow() save(); } -void OutfitWindow::load(bool oldConfig) +void OutfitWindow::load(const bool oldConfig) { - Configuration *cfg; + const Configuration *cfg; if (oldConfig) cfg = &config; else @@ -185,7 +185,7 @@ void OutfitWindow::save() bool good = false; for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++) { - int res = mItems[o][i] ? mItems[o][i] : -1; + const int res = mItems[o][i] ? mItems[o][i] : -1; if (res != -1) good = true; outfitStr += toString(res); @@ -252,11 +252,12 @@ void OutfitWindow::action(const gcn::ActionEvent &event) } } -void OutfitWindow::wearOutfit(int outfit, bool unwearEmpty, bool select) +void OutfitWindow::wearOutfit(const int outfit, const bool unwearEmpty, + const bool select) { bool isEmpty = true; - Item *item; + const Item *item; if (outfit < 0 || outfit > static_cast<int>(OUTFITS_COUNT)) return; @@ -286,12 +287,12 @@ void OutfitWindow::wearOutfit(int outfit, bool unwearEmpty, bool select) } } -void OutfitWindow::copyOutfit(int outfit) +void OutfitWindow::copyOutfit(const int outfit) { copyOutfit(outfit, mCurrentOutfit); } -void OutfitWindow::copyOutfit(int src, int dst) +void OutfitWindow::copyOutfit(const int src, const int dst) { if (src < 0 || src > static_cast<int>(OUTFITS_COUNT) || dst < 0 || dst > static_cast<int>(OUTFITS_COUNT)) @@ -306,7 +307,7 @@ void OutfitWindow::copyOutfit(int src, int dst) void OutfitWindow::draw(gcn::Graphics *graphics) { Window::draw(graphics); - Graphics *g = static_cast<Graphics*>(graphics); + Graphics *const g = static_cast<Graphics*>(graphics); for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++) { @@ -322,15 +323,15 @@ void OutfitWindow::draw(gcn::Graphics *graphics) continue; bool foundItem = false; - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (inv) { - Item *item = inv->findItem(mItems[mCurrentOutfit][i], + const Item *const item = inv->findItem(mItems[mCurrentOutfit][i], mItemColors[mCurrentOutfit][i]); if (item) { // Draw item icon. - Image* image = item->getImage(); + const Image *const image = item->getImage(); if (image) { g->drawImage(image, itemX, itemY); @@ -340,7 +341,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics) } if (!foundItem) { - Image *image = Item::getImage(mItems[mCurrentOutfit][i], + Image *const image = Item::getImage(mItems[mCurrentOutfit][i], mItemColors[mCurrentOutfit][i]); if (image) { @@ -352,7 +353,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics) if (mItemMoved) { // Draw the item image being dragged by the cursor. - Image* image = mItemMoved->getImage(); + const Image *const image = mItemMoved->getImage(); if (image) { const int tPosX = mCursorPosX - (image->mBounds.w / 2); @@ -385,10 +386,10 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event) } mMoved = false; event.consume(); - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (inv) { - Item *item = inv->findItem(itemId, itemColor); + Item *const item = inv->findItem(itemId, itemColor); if (item) mItemMoved = item; else @@ -468,7 +469,7 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event) Window::mouseReleased(event); } -int OutfitWindow::getIndexFromGrid(int pointX, int pointY) const +int OutfitWindow::getIndexFromGrid(const int pointX, const int pointY) const { const gcn::Rectangle tRect = gcn::Rectangle( 10, 25, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight); @@ -481,17 +482,17 @@ int OutfitWindow::getIndexFromGrid(int pointX, int pointY) const return index; } -void OutfitWindow::unequipNotInOutfit(int outfit) +void OutfitWindow::unequipNotInOutfit(const int outfit) const { // here we think that outfit is correct index - Inventory *inventory = PlayerInfo::getInventory(); + const Inventory *const inventory = PlayerInfo::getInventory(); if (!inventory) return; for (unsigned i = 0; i < inventory->getSize(); i++) { - Item *item = inventory->getItem(i); + const Item *const item = inventory->getItem(i); if (item && item->isEquipped()) { bool found = false; @@ -509,7 +510,7 @@ void OutfitWindow::unequipNotInOutfit(int outfit) } } -std::string OutfitWindow::keyName(int number) +std::string OutfitWindow::keyName(const int number) const { if (number < 0 || number >= SHORTCUT_EMOTES) return ""; @@ -544,7 +545,7 @@ void OutfitWindow::showCurrentOutfit() mAwayOutfitCheck->setSelected(mAwayOutfit == mCurrentOutfit); } -void OutfitWindow::wearNextOutfit(bool all) +void OutfitWindow::wearNextOutfit(const bool all) { next(); if (!all && mCurrentOutfit < static_cast<int>(OUTFITS_COUNT)) @@ -565,7 +566,7 @@ void OutfitWindow::wearNextOutfit(bool all) wearOutfit(mCurrentOutfit); } -void OutfitWindow::wearPreviousOutfit(bool all) +void OutfitWindow::wearPreviousOutfit(const bool all) { previous(); if (!all && mCurrentOutfit < static_cast<int>(OUTFITS_COUNT)) @@ -591,9 +592,9 @@ void OutfitWindow::copyFromEquiped() copyFromEquiped(mCurrentOutfit); } -void OutfitWindow::copyFromEquiped(int dst) +void OutfitWindow::copyFromEquiped(const int dst) { - Inventory *inventory = PlayerInfo::getInventory(); + const Inventory *const inventory = PlayerInfo::getInventory(); if (!inventory) return; @@ -601,7 +602,7 @@ void OutfitWindow::copyFromEquiped(int dst) for (unsigned i = 0, sz = inventory->getSize(); i < sz; i++) { - const Item *item = inventory->getItem(i); + const Item *const item = inventory->getItem(i); if (item && item->isEquipped()) { mItems[dst][outfitCell] = item->getId(); diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 9aae112e3..3d7bb33bc 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -65,9 +65,9 @@ class OutfitWindow : public Window, private gcn::ActionListener void mouseReleased(gcn::MouseEvent &event); - void load(bool oldConfig = false); + void load(const bool oldConfig = false); - void setItemSelected(int itemId) + void setItemSelected(const int itemId) { mItemSelected = itemId; } void setItemSelected(Item *item); @@ -75,26 +75,26 @@ class OutfitWindow : public Window, private gcn::ActionListener bool isItemSelected() const { return mItemSelected > 0; } - void wearOutfit(int outfit, bool unwearEmpty = true, - bool select = false); + void wearOutfit(const int outfit, const bool unwearEmpty = true, + const bool select = false); - void copyOutfit(int outfit); + void copyOutfit(const int outfit); - void copyOutfit(int src, int dst); + void copyOutfit(const int src, const int dst); void copyFromEquiped(); - void copyFromEquiped(int dst); + void copyFromEquiped(const int dst); - void unequipNotInOutfit(int outfit); + void unequipNotInOutfit(const int outfit) const; void next(); void previous(); - void wearNextOutfit(bool all = false); + void wearNextOutfit(const bool all = false); - void wearPreviousOutfit(bool all = false); + void wearPreviousOutfit(const bool all = false); void wearAwayOutfit(); @@ -102,7 +102,7 @@ class OutfitWindow : public Window, private gcn::ActionListener void showCurrentOutfit(); - std::string keyName(int number) A_PURE; + std::string keyName(const int number) const; void clearCurrentOutfit(); @@ -115,7 +115,7 @@ class OutfitWindow : public Window, private gcn::ActionListener CheckBox *mAwayOutfitCheck; Label *mKeyLabel; - int getIndexFromGrid(int pointX, int pointY) const; + int getIndexFromGrid(const int pointX, const int pointY) const; int mBoxWidth; int mBoxHeight; diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index f0380153f..94604c128 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -52,7 +52,7 @@ const gcn::Color Palette::RAINBOW_COLORS[7] = /** Number of Elemets of RAINBOW_COLORS */ const int Palette::RAINBOW_COLOR_COUNT = 7; -Palette::Palette(int size) : +Palette::Palette(const int size) : mRainbowTime(tick_time), mColors(Colors(size)) { @@ -64,9 +64,9 @@ Palette::~Palette() mInstances.erase(this); } -const gcn::Color& Palette::getColor(char c, bool &valid) +const gcn::Color& Palette::getColor(const char c, bool &valid) { - CharColors::const_iterator it = mCharColors.find(c); + const CharColors::const_iterator it = mCharColors.find(c); if (it != mCharColors.end()) { valid = true; @@ -94,7 +94,7 @@ void Palette::advanceGradient() // For slower systems, advance can be greater than one (advance > 1 // skips advance-1 steps). Should make gradient look the same // independent of the framerate. - int advance = get_elapsed_time(mRainbowTime) / 5; + const int advance = get_elapsed_time(mRainbowTime) / 5; double startColVal, destColVal; for (size_t i = 0, sz = mGradVector.size(); i < sz; i++) @@ -121,7 +121,7 @@ void Palette::advanceGradient() else colIndex = mGradVector[i]->gradientIndex; - ColorElem *elem = mGradVector[i]; + ColorElem *const elem = mGradVector[i]; gcn::Color &color = elem->color; if (elem->grad == PULSE) diff --git a/src/gui/palette.h b/src/gui/palette.h index a4ac5d44b..836ec77e6 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -65,7 +65,7 @@ class Palette * * @return the requested color or Palette::BLACK */ - const gcn::Color &getColor(char c, bool &valid); + const gcn::Color &getColor(const char c, bool &valid); /** * Gets the color associated with the type. Sets the alpha channel @@ -141,7 +141,7 @@ class Palette /** * Constructor */ - Palette(int size); + Palette(const int size); /** * Destructor diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp index d9f039fa8..51ad76505 100644 --- a/src/gui/questswindow.cpp +++ b/src/gui/questswindow.cpp @@ -47,7 +47,7 @@ struct QuestItemText { - QuestItemText(std::string text0, int type0) : + QuestItemText(std::string text0, const int type0) : text(text0), type(type0) { } @@ -168,7 +168,7 @@ QuestsWindow::~QuestsWindow() void QuestsWindow::loadXml() { XML::Document doc("quests.xml"); - XmlNodePtr root = doc.rootNode(); + const XmlNodePtr root = doc.rootNode(); if (!root) return; @@ -176,7 +176,7 @@ void QuestsWindow::loadXml() { if (xmlNameEqual(varNode, "var")) { - int id = XML::getProperty(varNode, "id", 0); + const int id = XML::getProperty(varNode, "id", 0); if (id < 0) continue; for_each_xml_child_node(questNode, varNode) @@ -188,7 +188,7 @@ void QuestsWindow::loadXml() } } -void QuestsWindow::loadQuest(int var, XmlNodePtr node) +void QuestsWindow::loadQuest(const int var, const XmlNodePtr node) { QuestItem *quest = new QuestItem(); quest->name = XML::langProperty(node, "name", _("unknown")); @@ -213,7 +213,7 @@ void QuestsWindow::loadQuest(int var, XmlNodePtr node) { if (!xmlTypeEqual(dataNode, XML_ELEMENT_NODE)) continue; - const char *data = reinterpret_cast<const char*>( + const char *const data = reinterpret_cast<const char*>( xmlNodeGetContent(dataNode)); if (!data) continue; @@ -232,7 +232,7 @@ void QuestsWindow::action(const gcn::ActionEvent &event) const std::string &eventId = event.getId(); if (eventId == "select") { - int id = mQuestsListBox->getSelected(); + const int id = mQuestsListBox->getSelected(); if (id < 0) return; showQuest(mQuestLinks[id]); @@ -243,12 +243,12 @@ void QuestsWindow::action(const gcn::ActionEvent &event) } } -void QuestsWindow::updateQuest(int var, int val) +void QuestsWindow::updateQuest(const int var, const int val) { mVars[var] = val; } -void QuestsWindow::rebuild(bool playSound) +void QuestsWindow::rebuild(const bool playSound) { mQuestsModel->clear(); mQuestLinks.clear(); @@ -262,15 +262,15 @@ void QuestsWindow::rebuild(bool playSound) for (std::map<int, int>::const_iterator it = mVars.begin(), it_end = mVars.end(); it != it_end; ++ it) { - int var = (*it).first; - int val = (*it).second; + const int var = (*it).first; + const int val = (*it).second; const std::vector<QuestItem*> &quests = mQuests[var]; for (std::vector<QuestItem*>::const_iterator it2 = quests.begin(), it2_end = quests.end(); it2 != it2_end; ++ it2) { if (!*it2) continue; - QuestItem *quest = *it2; + QuestItem *const quest = *it2; // complete quest if (quest->complete.find(val) != quest->complete.end()) complete.push_back(quest); @@ -285,7 +285,7 @@ void QuestsWindow::rebuild(bool playSound) for (std::vector<QuestItem*>::const_iterator it = complete.begin(), it_end = complete.end(); it != it_end; ++ it, k ++) { - QuestItem *quest = *it; + QuestItem *const quest = *it; if (quest->completeFlag == 0) { updatedQuest = k; @@ -308,7 +308,7 @@ void QuestsWindow::rebuild(bool playSound) for (std::vector<QuestItem*>::const_iterator it = incomplete.begin(), it_end = incomplete.end(); it != it_end; ++ it, k ++) { - QuestItem *quest = *it; + QuestItem *const quest = *it; if (quest->completeFlag == -1) { updatedQuest = k; @@ -353,7 +353,7 @@ void QuestsWindow::rebuild(bool playSound) } } -void QuestsWindow::showQuest(QuestItem *quest) +void QuestsWindow::showQuest(const QuestItem *const quest) { if (!quest) return; diff --git a/src/gui/questswindow.h b/src/gui/questswindow.h index 706f6ba1c..30815d751 100644 --- a/src/gui/questswindow.h +++ b/src/gui/questswindow.h @@ -58,16 +58,16 @@ class QuestsWindow : public Window, public gcn::ActionListener */ void action(const gcn::ActionEvent &event); - void updateQuest(int var, int val); + void updateQuest(const int var, const int val); - void rebuild(bool playSound); + void rebuild(const bool playSound); - void showQuest(QuestItem *quest); + void showQuest(const QuestItem *const quest); private: void loadXml(); - void loadQuest(int var, XmlNodePtr node); + void loadQuest(const int var, const XmlNodePtr node); QuestsModel *mQuestsModel; ExtendedListBox *mQuestsListBox; diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 64048dcc9..c84ddc122 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -46,7 +46,7 @@ #include "debug.h" -QuitDialog::QuitDialog(QuitDialog** pointerToMe): +QuitDialog::QuitDialog(QuitDialog **const pointerToMe): Window(_("Quit"), true, nullptr, "quit.xml"), mLogoutQuit(new RadioButton(_("Quit"), "quitdialog")), mForceQuit(new RadioButton(_("Quit"), "quitdialog")), @@ -113,7 +113,8 @@ QuitDialog::~QuitDialog() mSwitchCharacter = nullptr; } -void QuitDialog::placeOption(ContainerPlacer &placer, gcn::RadioButton *option) +void QuitDialog::placeOption(ContainerPlacer &placer, + gcn::RadioButton *const option) { placer(0, static_cast<int>(mOptions.size()), option, 3); mOptions.push_back(option); @@ -125,7 +126,7 @@ void QuitDialog::action(const gcn::ActionEvent &event) { if (viewport) { - Map *map = viewport->getCurrentMap(); + Map *const map = viewport->getCurrentMap(); if (map) map->saveExtraLayer(); } @@ -159,7 +160,7 @@ void QuitDialog::action(const gcn::ActionEvent &event) void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) { - int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); int dir = 0; switch (actionId) diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h index 175812bad..5a4134d3a 100644 --- a/src/gui/quitdialog.h +++ b/src/gui/quitdialog.h @@ -50,7 +50,7 @@ class QuitDialog : public Window, public gcn::ActionListener, * * @pointerToMe will be set to NULL when the QuitDialog is destroyed */ - QuitDialog(QuitDialog **pointerToMe); + QuitDialog(QuitDialog **const pointerToMe); /** * Destructor @@ -65,7 +65,8 @@ class QuitDialog : public Window, public gcn::ActionListener, void keyPressed(gcn::KeyEvent &keyEvent); private: - void placeOption(ContainerPlacer &placer, gcn::RadioButton *option); + void placeOption(ContainerPlacer &placer, + gcn::RadioButton *const option); std::vector<gcn::RadioButton*> mOptions; gcn::RadioButton *mLogoutQuit; diff --git a/src/guild.cpp b/src/guild.cpp index 11817c48d..8a611b1dd 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -31,7 +31,8 @@ class SortGuildFunctor { public: - bool operator() (GuildMember* m1, GuildMember* m2) + bool operator() (const GuildMember *const m1, + const GuildMember *const m2) const { if (!m1 || !m2) return false; @@ -54,15 +55,15 @@ class SortGuildFunctor } } guildSorter; -GuildMember::GuildMember(Guild *guild, int accountId, int charId, - const std::string &name): +GuildMember::GuildMember(Guild *const guild, const int accountId, + const int charId, const std::string &name): Avatar(name), mGuild(guild), mPos(0) { mId = accountId; mCharId = charId; } -GuildMember::GuildMember(Guild *guild, const std::string &name): +GuildMember::GuildMember(Guild *const guild, const std::string &name): Avatar(name), mGuild(guild), mPos(0) { } @@ -77,7 +78,7 @@ std::string GuildMember::getAdditionString() const Guild::GuildMap Guild::guilds; -Guild::Guild(short id): +Guild::Guild(const short id): mId(id), mCanInviteUsers(false), mEmblemId(0), @@ -91,7 +92,7 @@ Guild::~Guild() clearMembers(); } -GuildMember *Guild::addMember(int accountId, int charId, +GuildMember *Guild::addMember(const int accountId, const int charId, const std::string &name) { GuildMember *m; @@ -118,10 +119,10 @@ GuildMember *Guild::addMember(const std::string &name) return m; } -GuildMember *Guild::getMember(int id) const +GuildMember *Guild::getMember(const int id) const { - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + const MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { if ((*itr) && (*itr)->mId == id) @@ -132,10 +133,10 @@ GuildMember *Guild::getMember(int id) const return nullptr; } -GuildMember *Guild::getMember(int accountId, int charId) const +GuildMember *Guild::getMember(const int accountId, const int charId) const { - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + const MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { if ((*itr) && (*itr)->mId == accountId && (*itr)->mCharId == charId) @@ -148,8 +149,8 @@ GuildMember *Guild::getMember(int accountId, int charId) const GuildMember *Guild::getMember(const std::string &name) const { - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + const MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { if ((*itr) && (*itr)->getName() == name) @@ -160,10 +161,10 @@ GuildMember *Guild::getMember(const std::string &name) const return nullptr; } -void Guild::removeMember(GuildMember *member) +void Guild::removeMember(const GuildMember *const member) { - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::iterator itr = mMembers.begin(); + const MemberList::iterator itr_end = mMembers.end(); while (itr != itr_end) { if (!*itr) @@ -181,14 +182,14 @@ void Guild::removeMember(GuildMember *member) } } -void Guild::removeMember(int id) +void Guild::removeMember(const int id) { bool deleted = true; while (deleted) { deleted = false; - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::iterator itr = mMembers.begin(); + const MemberList::iterator itr_end = mMembers.end(); while (itr != itr_end) { if ((*itr) && (*itr)->mId == id) @@ -210,8 +211,8 @@ void Guild::removeMember(const std::string &name) while (deleted) { deleted = false; - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::iterator itr = mMembers.begin(); + const MemberList::iterator itr_end = mMembers.end(); while (itr != itr_end) { if ((*itr) && (*itr)->getName() == name) @@ -233,29 +234,29 @@ void Guild::removeFromMembers() return; MemberList::const_iterator itr = mMembers.begin(); - MemberList::const_iterator itr_end = mMembers.end(); + const MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { - Being *b = actorSpriteManager->findBeing((*itr)->getID()); + Being *const b = actorSpriteManager->findBeing((*itr)->getID()); if (b) b->removeGuild(getId()); ++itr; } } -Avatar *Guild::getAvatarAt(int index) +Avatar *Guild::getAvatarAt(const int index) { return mMembers[index]; } -void Guild::setRights(short rights) +void Guild::setRights(const short rights) { // to invite, rights must be greater than 0 if (rights > 0) mCanInviteUsers = true; } -bool Guild::isMember(GuildMember *member) const +bool Guild::isMember(const GuildMember *const member) const { if (!member) return false; @@ -263,8 +264,8 @@ bool Guild::isMember(GuildMember *member) const if (member->mGuild && member->mGuild != this) return false; - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + const MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { if ((*itr) && (*itr)->mId == member->mId && @@ -278,10 +279,10 @@ bool Guild::isMember(GuildMember *member) const return false; } -bool Guild::isMember(int id) const +bool Guild::isMember(const int id) const { - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + const MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { if ((*itr) && (*itr)->mId == id) @@ -294,8 +295,8 @@ bool Guild::isMember(int id) const bool Guild::isMember(const std::string &name) const { - MemberList::const_iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + const MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { if ((*itr) && (*itr)->getName() == name) @@ -309,8 +310,8 @@ bool Guild::isMember(const std::string &name) const void Guild::getNames(StringVect &names) const { names.clear(); - MemberList::const_iterator it = mMembers.begin(), - it_end = mMembers.end(); + MemberList::const_iterator it = mMembers.begin(); + const MemberList::const_iterator it_end = mMembers.end(); while (it != it_end) { @@ -320,25 +321,25 @@ void Guild::getNames(StringVect &names) const } } -void Guild::addPos(int id, std::string name) +void Guild::addPos(const int id, std::string name) { mPositions[id] = name; } -Guild *Guild::getGuild(short id) +Guild *Guild::getGuild(const short id) { - GuildMap::const_iterator it = guilds.find(id); + const GuildMap::const_iterator it = guilds.find(id); if (it != guilds.end()) return it->second; - Guild *guild = new Guild(id); + Guild *const guild = new Guild(id); guilds[id] = guild; return guild; } -std::string Guild::getPos(int id) const +std::string Guild::getPos(const int id) const { - PositionsMap::const_iterator it = mPositions.find(id); + const PositionsMap::const_iterator it = mPositions.find(id); if (it == mPositions.end()) return ""; else diff --git a/src/guild.h b/src/guild.h index f637009d6..e5a382eea 100644 --- a/src/guild.h +++ b/src/guild.h @@ -45,7 +45,7 @@ public: int getPos() const { return mPos; } - void setPos(int pos) + void setPos(const int pos) { mPos = pos; } std::string getAdditionString() const; @@ -53,9 +53,10 @@ public: protected: friend class Guild; - GuildMember(Guild *guild, int id, int accountId, const std::string &name); + GuildMember(Guild *const guild, const int id, const int accountId, + const std::string &name); - GuildMember(Guild *guild, const std::string &name); + GuildMember(Guild *const guild, const std::string &name); Guild *mGuild; int mPos; @@ -75,7 +76,8 @@ public: /** * Adds member to the list. */ - GuildMember *addMember(int accountId, int charId, const std::string &name); + GuildMember *addMember(const int accountId, const int charId, + const std::string &name); /** * Adds member to the list. @@ -87,14 +89,14 @@ public: * * @return the member with the given ID, or NULL if they don't exist. */ - GuildMember *getMember(int id) const; + GuildMember *getMember(const int id) const; /** * Find a member by account ID and char ID. * * @return the member with the given ID, or NULL if they don't exist. */ - GuildMember *getMember(int accountId, int charId) const; + GuildMember *getMember(const int accountId, const int charId) const; /** * Find a member by name. @@ -120,12 +122,12 @@ public: /** * Removes a member from the guild. */ - void removeMember(GuildMember *member); + void removeMember(const GuildMember *const member); /** * Removes a member from the guild. */ - void removeMember(int id); + void removeMember(const int id); /** * Removes a member from the guild. @@ -144,7 +146,7 @@ public: int getNumberOfElements() { return static_cast<int>(mMembers.size()); } - Avatar *getAvatarAt(int i); + Avatar *getAvatarAt(const int i); /** * Get whether user can invite users to this guild. @@ -153,28 +155,28 @@ public: bool getInviteRights() const { return mCanInviteUsers; } - void setRights(short rights); + void setRights(const short rights); - bool isMember(GuildMember *member) const; + bool isMember(const GuildMember *const member) const; - bool isMember(int id) const; + bool isMember(const int id) const; bool isMember(const std::string &name) const; void getNames(StringVect &names) const; - void addPos(int id, std::string name); + void addPos(const int id, std::string name); void sort(); std::string getPos(int id) const; - static Guild *getGuild(short id); + static Guild *getGuild(const short id); const PositionsMap &getPositions() const { return mPositions; } - void setEmblemId(int id) + void setEmblemId(const int id) { mEmblemId = id; } int getEmblemId() const @@ -182,7 +184,7 @@ public: static void clearGuilds(); - void setServerGuild(bool b) + void setServerGuild(const bool b) { mServerGuild = b; } bool getServerGuild() const @@ -195,7 +197,7 @@ private: /** * Constructor with guild id passed to it. */ - Guild(short id); + Guild(const short id); typedef std::vector<GuildMember*> MemberList; MemberList mMembers; diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 51fa22224..f1c908807 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -94,7 +94,7 @@ void GuildManager::reload() if (socialWindow) { - Guild *guild = Guild::getGuild(1); + Guild *const guild = Guild::getGuild(1); if (guild && socialWindow) socialWindow->removeTab(guild); } @@ -102,7 +102,7 @@ void GuildManager::reload() mTab = nullptr; } -void GuildManager::send(std::string msg) +void GuildManager::send(std::string msg) const { Net::getChatHandler()->privateMessage("guild", msg); } @@ -118,7 +118,7 @@ void GuildManager::chat(std::string msg) void GuildManager::getNames(StringVect &names) { - Guild *guild = createGuild(); + const Guild *const guild = createGuild(); if (guild) guild->getNames(names); } @@ -148,22 +148,22 @@ void GuildManager::requestGuildInfo() void GuildManager::updateList() { - Guild *guild = Guild::getGuild(1); + Guild *const guild = Guild::getGuild(1); if (guild) { guild->setServerGuild(false); StringVectCIter it = mTempList.begin(); - StringVectCIter it_end = mTempList.end(); + const StringVectCIter it_end = mTempList.end(); int i = 0; while (it != it_end) { std::string name = *it; if (name.size() > 1) { - int status = atoi(name.substr(name.size() - 1).c_str()); + const int status = atoi(name.substr(name.size() - 1).c_str()); name = name.substr(0, name.size() - 1); - GuildMember *m = guild->addMember(i, 0, name); + GuildMember *const m = guild->addMember(i, 0, name); if (m) { m->setOnline(status & 1); @@ -195,7 +195,7 @@ void GuildManager::updateList() mGotInfo = true; } -void GuildManager::createTab(Guild *guild) +void GuildManager::createTab(Guild *const guild) { if (!mTab) { @@ -206,9 +206,9 @@ void GuildManager::createTab(Guild *guild) } } -Guild *GuildManager::createGuild() +Guild *GuildManager::createGuild() const { - Guild *guild = Guild::getGuild(1); + Guild *const guild = Guild::getGuild(1); if (!guild) return nullptr; @@ -218,7 +218,7 @@ Guild *GuildManager::createGuild() bool GuildManager::processGuildMessage(std::string msg) { - bool res = process(msg); + const bool res = process(msg); if (!mRequest) requestGuildInfo(); @@ -231,11 +231,11 @@ bool GuildManager::process(std::string msg) if (msg.size() > 4 && msg[0] == '#' && msg[1] == '#') msg = msg.substr(3); - bool haveNick = (msg.find(": ") != std::string::npos); + const bool haveNick = (msg.find(": ") != std::string::npos); if (!haveNick && findCutLast(msg, " is now Offline.")) { - Guild *guild = createGuild(); + Guild *const guild = createGuild(); if (!guild) return false; if (msg.size() < 4) @@ -243,7 +243,7 @@ bool GuildManager::process(std::string msg) if (msg[0] == '#' && msg[1] == '#') msg = msg.substr(3); - GuildMember *m = guild->addMember(msg); + GuildMember *const m = guild->addMember(msg); if (m) m->setOnline(false); guild->sort(); @@ -252,14 +252,14 @@ bool GuildManager::process(std::string msg) } else if (!haveNick && findCutLast(msg, " is now Online.")) { - Guild *guild = createGuild(); + Guild *const guild = createGuild(); if (!guild) return false; if (msg.size() < 4) return false; if (msg[0] == '#' && msg[1] == '#') msg = msg.substr(3); - GuildMember *m = guild->addMember(msg); + GuildMember *const m = guild->addMember(msg); if (m) m->setOnline(true); guild->sort(); @@ -268,7 +268,7 @@ bool GuildManager::process(std::string msg) } else if (findCutFirst(msg, "Welcome to the ")) { - Guild *guild = createGuild(); + Guild *const guild = createGuild(); if (!guild) return false; // logger->log("welcome message: %s", msg.c_str()); @@ -286,7 +286,7 @@ bool GuildManager::process(std::string msg) } else if (findCutFirst(msg, "Player name: ")) { - Guild *guild = createGuild(); + Guild *const guild = createGuild(); if (!guild) return false; size_t pos = msg.find("Access Level: "); @@ -301,7 +301,7 @@ bool GuildManager::process(std::string msg) if (pos == std::string::npos) return false; - int level = atoi(msg.substr(0, pos).c_str()); + const int level = atoi(msg.substr(0, pos).c_str()); if (level >= 10) mHavePower = true; else @@ -360,7 +360,7 @@ bool GuildManager::process(std::string msg) else if (!haveNick && (findCutLast(msg, " has been removed " "from the Guild.") || findCutLast(msg, " has left the Guild."))) { - Guild *guild = createGuild(); + Guild *const guild = createGuild(); if (!guild) return false; if (msg.size() < 4) @@ -370,7 +370,7 @@ bool GuildManager::process(std::string msg) if (actorSpriteManager) { - Being *b = actorSpriteManager->findBeingByName( + Being *const b = actorSpriteManager->findBeingByName( msg, Being::PLAYER); if (b) @@ -391,7 +391,7 @@ bool GuildManager::process(std::string msg) } else { - Guild *guild = createGuild(); + Guild *const guild = createGuild(); if (!guild) return false; if (!mTab) @@ -451,17 +451,17 @@ void GuildManager::notice(std::string msg) send("!setmotd " + msg); } -void GuildManager::clear() +void GuildManager::clear() const { if (socialWindow) { - Guild *guild = Guild::getGuild(1); + Guild *const guild = Guild::getGuild(1); if (guild) socialWindow->removeTab(guild); } } -void GuildManager::inviteResponse(bool response) +void GuildManager::inviteResponse(const bool response) { if (response) send("yes"); @@ -471,7 +471,7 @@ void GuildManager::inviteResponse(bool response) bool GuildManager::afterRemove() { - Guild *guild = createGuild(); + Guild *const guild = createGuild(); if (!guild) return false; guild->removeFromMembers(); diff --git a/src/guildmanager.h b/src/guildmanager.h index a2b6f7c0d..75cc59eb6 100644 --- a/src/guildmanager.h +++ b/src/guildmanager.h @@ -39,7 +39,7 @@ class GuildManager void chat(std::string msg); - void send(std::string msg); + void send(std::string msg) const; bool processGuildMessage(std::string msg); @@ -60,15 +60,15 @@ class GuildManager void notice(std::string msg); - void createTab(Guild *guild); + void createTab(Guild *const guild); - Guild *createGuild(); + Guild *createGuild() const; - void clear(); + void clear() const; void reload(); - void inviteResponse(bool response); + void inviteResponse(const bool response); bool afterRemove(); diff --git a/src/inventory.h b/src/inventory.h index 74f3e695d..6cfcc3f86 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -37,7 +37,7 @@ class InventoryListener virtual ~InventoryListener() { } - virtual void slotsChanged(Inventory* inventory) = 0; + virtual void slotsChanged(Inventory *const inventory) = 0; protected: InventoryListener() |