From a33a8dc48761d7cb2b4c1c468e1e3b188bcbf709 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 26 Aug 2012 21:29:59 +0300 Subject: Add const to some classes. --- src/commandhandler.cpp | 12 ++++--- src/commandhandler.h | 4 +-- src/defaults.cpp | 2 +- src/defaults.h | 2 +- src/game.h | 2 +- src/graphics.cpp | 2 +- src/graphics.h | 2 +- src/graphicsvertexes.cpp | 6 ++-- src/graphicsvertexes.h | 16 ++++----- src/gui/beingpopup.cpp | 2 +- src/gui/beingpopup.h | 2 +- src/gui/buydialog.cpp | 17 ++++----- src/gui/buydialog.h | 7 ++-- src/gui/buyselldialog.cpp | 7 ++-- src/gui/buyselldialog.h | 2 +- src/gui/changepassworddialog.cpp | 14 ++++---- src/gui/changepassworddialog.h | 2 +- src/gui/charcreatedialog.cpp | 32 +++++++++-------- src/gui/charcreatedialog.h | 9 ++--- src/gui/charselectdialog.cpp | 54 ++++++++++++++++------------- src/gui/charselectdialog.h | 15 ++++---- src/guichan/actionevent.cpp | 2 +- src/guichan/basiccontainer.cpp | 10 +++--- src/guichan/focushandler.cpp | 20 +++++------ src/guichan/font.cpp | 2 +- src/guichan/graphics.cpp | 2 +- src/guichan/gui.cpp | 24 ++++++------- src/guichan/include/guichan/actionevent.hpp | 2 +- src/guichan/include/guichan/font.hpp | 6 ++-- src/guichan/sdl/sdlgraphics.cpp | 22 ++++++------ src/guichan/widget.cpp | 15 ++++---- src/guichan/widgets/checkbox.cpp | 2 +- src/guichan/widgets/dropdown.cpp | 6 ++-- src/guichan/widgets/label.cpp | 2 +- src/guichan/widgets/radiobutton.cpp | 2 +- src/guichan/widgets/scrollarea.cpp | 29 ++++++++-------- src/guichan/widgets/slider.cpp | 4 +-- src/guichan/widgets/tabbedarea.cpp | 8 ++--- src/guichan/widgets/textbox.cpp | 2 +- src/guichan/widgets/textfield.cpp | 3 +- src/net/buysellhandler.h | 10 +++--- src/net/ea/buysellhandler.cpp | 10 +++--- src/net/ea/buysellhandler.h | 10 +++--- 43 files changed, 214 insertions(+), 190 deletions(-) diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 502034fe8..12baf0af0 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -78,13 +78,15 @@ CommandHandler::CommandHandler() { } -void CommandHandler::handleCommands(const std::string &command, ChatTab *tab) +void CommandHandler::handleCommands(const std::string &command, + ChatTab *const tab) { // here need add splitting commands handleCommand(command, tab); } -void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) +void CommandHandler::handleCommand(const std::string &command, + ChatTab *const tab) { size_t pos = command.find(' '); std::string type(command, 0, pos); @@ -448,7 +450,7 @@ void CommandHandler::outString(ChatTab *const tab, const std::string &str, { if (!player_node) return; - const Guild *guild = player_node->getGuild(); + const Guild *const guild = player_node->getGuild(); if (guild) { if (guild->getServerGuild()) @@ -814,7 +816,7 @@ void CommandHandler::handleHeal(const std::string &args, if (!args.empty()) { - Being *const being = actorSpriteManager->findBeingByName( + const Being *const being = actorSpriteManager->findBeingByName( args, Being::PLAYER); if (being) actorSpriteManager->heal(being); @@ -864,7 +866,7 @@ void CommandHandler::handleUndress(const std::string &args, if (!actorSpriteManager) return; - Being* target = actorSpriteManager->findNearestByName(args); + Being *const target = actorSpriteManager->findNearestByName(args); if (target) Net::getBeingHandler()->undress(target); } diff --git a/src/commandhandler.h b/src/commandhandler.h index 279673653..3a6510661 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -55,10 +55,10 @@ class CommandHandler * Parse and handle the given command. */ static void handleCommand(const std::string &command, - ChatTab *tab = localChatTab); + ChatTab *const tab = localChatTab); static void handleCommands(const std::string &command, - ChatTab *tab = localChatTab); + ChatTab *const tab = localChatTab); static void replaceVars(std::string &str); diff --git a/src/defaults.cpp b/src/defaults.cpp index 92c11164e..024521d62 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -51,7 +51,7 @@ VariableData* createData(const std::string &defData) return new StringData(defData); } -VariableData* createData(const char* defData) +VariableData* createData(const char *const defData) { return new StringData(defData); } diff --git a/src/defaults.h b/src/defaults.h index 3fb274e85..45a050eb7 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -32,7 +32,7 @@ VariableData* createData(const int defData); VariableData* createData(const double defData); VariableData* createData(const float defData); VariableData* createData(const std::string &defData); -VariableData* createData(const char* defData); +VariableData* createData(const char *const defData); VariableData* createData(const bool defData); DefaultsData* getConfigDefaults(); DefaultsData* getBrandingDefaults(); diff --git a/src/game.h b/src/game.h index 5ea45863a..874149758 100644 --- a/src/game.h +++ b/src/game.h @@ -102,7 +102,7 @@ class Game void resetAdjustLevel(); - void setAdjustLevel(int n) + void setAdjustLevel(const int n) { mAdjustLevel = n; } static void closeDialogs(); diff --git a/src/graphics.cpp b/src/graphics.cpp index c217fed05..40cda110a 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -892,7 +892,7 @@ bool Graphics::calcWindow(GraphicsVertexes *const vert, int Graphics::SDL_FakeUpperBlit(const SDL_Surface *const src, SDL_Rect *const srcrect, - SDL_Surface *const dst, + const SDL_Surface *const dst, SDL_Rect *dstrect) const { SDL_Rect fulldst; diff --git a/src/graphics.h b/src/graphics.h index bee74850b..ce3a6ea2a 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -337,7 +337,7 @@ class Graphics : public gcn::SDLGraphics int SDL_FakeUpperBlit(const SDL_Surface *const src, SDL_Rect *const srcrect, - SDL_Surface *const dst, + const SDL_Surface *const dst, SDL_Rect *dstrect) const; int mBpp; diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp index 189f28348..b6451a3e4 100644 --- a/src/graphicsvertexes.cpp +++ b/src/graphicsvertexes.cpp @@ -189,7 +189,7 @@ GraphicsVertexes::~GraphicsVertexes() { } -void GraphicsVertexes::init(int x, int y, int w, int h) +void GraphicsVertexes::init(const int x, const int y, const int w, const int h) { mPtr = 0; mX = x; @@ -213,9 +213,9 @@ void GraphicsVertexes::setLoadAsOpenGL(int useOpenGL) } #endif -void GraphicsVertexes::pushSDL(SDL_Rect r1, SDL_Rect r2) +void GraphicsVertexes::pushSDL(const SDL_Rect r1, const SDL_Rect r2) { - DoubleRect *r = new DoubleRect(); + DoubleRect *const r = new DoubleRect(); r->src = r1; r->dst = r2; sdl[mPtr].mList.push_back(r); diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h index 31eb401f2..f0c19d4bc 100644 --- a/src/graphicsvertexes.h +++ b/src/graphicsvertexes.h @@ -151,18 +151,18 @@ class GraphicsVertexes NormalOpenGLGraphicsVertexes ogl[5]; #endif - void init(int x, int y, int w, int h); + void init(const int x, const int y, const int w, const int h); - void pushSDL(SDL_Rect r1, SDL_Rect r2); + void pushSDL(const SDL_Rect r1, const SDL_Rect r2); void clearSDL(); std::vector *getRectsSDL(); - void incPtr(int num = 1) + void incPtr(const int num = 1) { mPtr += num; } - void setPtr(int num) + void setPtr(const int num) { mPtr = num; } #ifdef USE_OPENGL @@ -170,16 +170,16 @@ class GraphicsVertexes { return &ogl[mPtr]; } #endif - int getX() + int getX() const { return mX; } - int getY() + int getY() const { return mY; } - int getW() + int getW() const { return mW; } - int getH() + int getH() const { return mH; } int mX, mY, mW, mH; diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index 89bc1e084..19c2e0d03 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -74,7 +74,7 @@ BeingPopup::~BeingPopup() { } -void BeingPopup::show(int x, int y, Being *b) +void BeingPopup::show(const int x, const int y, Being *const b) { if (!b) { diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h index a029f739a..f58921cf2 100644 --- a/src/gui/beingpopup.h +++ b/src/gui/beingpopup.h @@ -46,7 +46,7 @@ class BeingPopup : public Popup /** * Sets the info to be displayed given a particular player. */ - void show(int x, int y, Being *b); + void show(const int x, const int y, Being *const b); // TODO: Add a version for monsters, NPCs, etc? diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 2cb24bb13..ffbe042e5 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -50,7 +50,7 @@ BuyDialog::DialogList BuyDialog::instances; -BuyDialog::BuyDialog(int npcId): +BuyDialog::BuyDialog(const int npcId): Window(_("Buy"), false, nullptr, "buy.xml"), mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("") { @@ -154,7 +154,7 @@ BuyDialog::~BuyDialog() instances.remove(this); } -void BuyDialog::setMoney(int amount) +void BuyDialog::setMoney(const int amount) { mMoney = amount; mShopItemList->setPlayersMoney(amount); @@ -174,7 +174,8 @@ void BuyDialog::reset() setMoney(0); } -void BuyDialog::addItem(int id, unsigned char color, int amount, int price) +void BuyDialog::addItem(const int id, const unsigned char color, + const int amount, const int price) { mShopItems->addItem(id, color, amount, price); mShopItemList->adjustSize(); @@ -188,7 +189,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) return; } - int selectedItem = mShopItemList->getSelected(); + const int selectedItem = mShopItemList->getSelected(); // The following actions require a valid selection if (selectedItem < 0 || @@ -238,7 +239,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) { if (mNpcId != -1) { - ShopItem *item = mShopItems->at(selectedItem); + const ShopItem *const item = mShopItems->at(selectedItem); Net::getNpcHandler()->buyItem(mNpcId, item->getId(), item->getColor(), mAmountItems); @@ -254,7 +255,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) } else if (tradeWindow) { - ShopItem *item = mShopItems->at(selectedItem); + const ShopItem *const item = mShopItems->at(selectedItem); if (item) { Net::getBuySellHandler()->sendBuyRequest(mNick, @@ -289,10 +290,10 @@ void BuyDialog::updateButtonsAndLabels() if (selectedItem > -1) { - ShopItem * item = mShopItems->at(selectedItem); + const ShopItem *const item = mShopItems->at(selectedItem); if (item) { - int itemPrice = item->getPrice(); + const int itemPrice = item->getPrice(); // Calculate how many the player can afford if (itemPrice) diff --git a/src/gui/buydialog.h b/src/gui/buydialog.h index ea449e06e..50d8a4d0b 100644 --- a/src/gui/buydialog.h +++ b/src/gui/buydialog.h @@ -55,7 +55,7 @@ class BuyDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ - BuyDialog(int npcId); + BuyDialog(const int npcId); /** * Constructor. @@ -77,12 +77,13 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Sets the amount of available money. */ - void setMoney(int amount); + void setMoney(const int amount); /** * Adds an item to the shop inventory. */ - void addItem(int id, unsigned char color, int amount, int price); + void addItem(const int id, const unsigned char color, + const int amount, const int price); /** * Called when receiving actions from the widgets. diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index cdcf90be9..7fff70fc0 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -34,7 +34,7 @@ BuySellDialog::DialogList BuySellDialog::instances; -BuySellDialog::BuySellDialog(int npcId): +BuySellDialog::BuySellDialog(const int npcId): Window(_("Shop"), false, nullptr, "buysell.xml"), mNpcId(npcId), mNick(""), @@ -63,11 +63,12 @@ void BuySellDialog::init() N_("Buy"), N_("Sell"), N_("Cancel"), nullptr }; const int buttonPadding = getOption("buttonpadding", 10); - int x = buttonPadding, y = buttonPadding; + int x = buttonPadding; + const int y = buttonPadding; for (const char **curBtn = buttonNames; *curBtn; curBtn++) { - Button *btn = new Button(gettext(*curBtn), *curBtn, this); + Button *const btn = new Button(gettext(*curBtn), *curBtn, this); if (!mBuyButton) mBuyButton = btn; // For focus request btn->setPosition(x, y); diff --git a/src/gui/buyselldialog.h b/src/gui/buyselldialog.h index 9636f4e0a..dfc59415e 100644 --- a/src/gui/buyselldialog.h +++ b/src/gui/buyselldialog.h @@ -46,7 +46,7 @@ class BuySellDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - BuySellDialog(int npcId); + BuySellDialog(const int npcId); BuySellDialog(std::string nick); diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 5751efba4..0d38bab4e 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -44,13 +44,13 @@ #include "debug.h" -ChangePasswordDialog::ChangePasswordDialog(LoginData *data): +ChangePasswordDialog::ChangePasswordDialog(LoginData *const data): Window(_("Change Password"), true, nullptr, "changepassword.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { - gcn::Label *accountLabel = new Label( - strprintf(_("Account: %s"), mLoginData->username.c_str())); + gcn::Label *const accountLabel = new Label( + strprintf(_("Account: %s"), mLoginData->username.c_str())); mOldPassField = new PasswordField; mFirstPassField = new PasswordField; mSecondPassField = new PasswordField; @@ -102,8 +102,10 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) std::stringstream errorMsg; int error = 0; - 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 old Password if (oldPassword.empty()) @@ -142,7 +144,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) else if (error == 3) mWrongDataNoticeListener->setTarget(this->mSecondPassField); - OkDialog *dlg = new OkDialog(_("Error"), + OkDialog *const dlg = new OkDialog(_("Error"), errorMsg.str(), DIALOG_ERROR); dlg->addActionListener(mWrongDataNoticeListener); } diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index a548638a4..e6cb18c7e 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -50,7 +50,7 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangePasswordDialog(LoginData *data); + ChangePasswordDialog(LoginData *const data); /** * Destructor diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index ba2e06661..4c553f5e1 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -64,7 +64,8 @@ static const uint8_t directions[] = Being::DOWN, Being::RIGHT, Being::UP, Being::LEFT }; -CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): +CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, + const int slot) : Window(_("New Character"), true, parent, "charcreate.xml"), mCharSelectDialog(parent), mRace(0), @@ -152,8 +153,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mAttributesLeft = new Label( strprintf(_("Please distribute %d points"), 99)); - int w = 480; - int h = 350; + const int w = 480; + const int h = 350; setContentSize(w, h); mPlayerBox->setDimension(gcn::Rectangle(350, 40, 110, 90)); mActionButton->setPosition(375, 140); @@ -163,10 +164,10 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mNameField->setDimension( gcn::Rectangle(60, 10, 300, mNameField->getHeight())); - int leftX = 120; - int rightX = 300; - int labelX = 5; - int nameX = 145; + const int leftX = 120; + const int rightX = 300; + const int labelX = 5; + const int nameX = 145; mPrevHairColorButton->setPosition(leftX, 40); mNextHairColorButton->setPosition(rightX, 40); mHairColorLabel->setPosition(labelX, 45); @@ -270,11 +271,13 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) mAttributeSlider[i]->getValue())); } - int characterSlot = mSlot; #ifdef MANASERV_SUPPORT + int characterSlot = mSlot; // On Manaserv, the slots start at 1, so we offset them. if (Net::getNetworkType() == ServerInfo::MANASERV) ++characterSlot; +#else + const int characterSlot = mSlot; #endif Net::getCharHandler()->newCharacter(getName(), characterSlot, @@ -367,7 +370,7 @@ void CharCreateDialog::updateSliders() } // Update distributed points - int pointsLeft = mMaxPoints - getDistributedPoints(); + const int pointsLeft = mMaxPoints - getDistributedPoints(); if (pointsLeft == 0) { mAttributesLeft->setCaption(_("Character stats OK")); @@ -406,7 +409,8 @@ int CharCreateDialog::getDistributedPoints() const } void CharCreateDialog::setAttributes(const StringVect &labels, - int available, int min, int max) + const int available, + const int min, const int max) { mMaxPoints = available; @@ -427,8 +431,8 @@ void CharCreateDialog::setAttributes(const StringVect &labels, mAttributeSlider.resize(labels.size()); mAttributeValue.resize(labels.size()); - int w = 480; - int h = 350; + const int w = 480; + const int h = 350; for (unsigned i = 0, sz = static_cast(labels.size()); i < sz; i++) @@ -462,7 +466,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels, h - 5 - mCancelButton->getHeight()); } -void CharCreateDialog::setFixedGender(bool fixed, Gender gender) +void CharCreateDialog::setFixedGender(const bool fixed, const Gender gender) { if (gender == GENDER_FEMALE) { @@ -564,7 +568,7 @@ void CharCreateDialog::updatePlayer() void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent) { - int actionId = static_cast(&keyEvent)->getActionId(); + const int actionId = static_cast(&keyEvent)->getActionId(); switch (actionId) { case Input::KEY_GUI_CANCEL: diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index c0c1f113a..048363452 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -54,7 +54,7 @@ class CharCreateDialog : public Window, /** * Constructor. */ - CharCreateDialog(CharSelectDialog *parent, int slot); + CharCreateDialog(CharSelectDialog *const parent, const int slot); /** * Destructor. @@ -69,10 +69,11 @@ class CharCreateDialog : public Window, void unlock(); void setAttributes(const StringVect &labels, - int available, - int min, int max); + const int available, + const int min, const int max); - void setFixedGender(bool fixed, Gender gender = GENDER_FEMALE); + void setFixedGender(const bool fixed, + const Gender gender = GENDER_FEMALE); void logic(); diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 146e4f290..a22ff6a28 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -94,21 +94,21 @@ class CharDeleteConfirm : public ConfirmDialog class CharacterDisplay : public Container { public: - CharacterDisplay(CharSelectDialog *charSelectDialog); + CharacterDisplay(CharSelectDialog *const charSelectDialog); - void setCharacter(Net::Character *character); + void setCharacter(Net::Character *const character); Net::Character *getCharacter() const { return mCharacter; } void requestFocus(); - void setActive(bool active); + void setActive(const bool active); - bool isSelectFocused() + bool isSelectFocused() const { return mButton->isFocused(); } - bool isDeleteFocused() + bool isDeleteFocused() const { return mDelete->isFocused(); } void focusSelect() @@ -130,7 +130,7 @@ class CharacterDisplay : public Container Button *mDelete; }; -CharSelectDialog::CharSelectDialog(LoginData *data): +CharSelectDialog::CharSelectDialog(LoginData *const data): Window(_("Account and Character Management"), false, nullptr, "char.xml"), mLocked(false), mUnregisterButton(nullptr), @@ -149,7 +149,8 @@ CharSelectDialog::CharSelectDialog(LoginData *data): mChangePasswordButton = new Button(_("Change Password"), "change_password", this); - int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); + const int optionalActions = Net::getLoginHandler() + ->supportedOptionalActions(); ContainerPlacer placer; placer = getPlacer(0, 0); @@ -203,7 +204,7 @@ CharSelectDialog::~CharSelectDialog() void CharSelectDialog::action(const gcn::ActionEvent &event) { // Check if a button of a character was pressed - const gcn::Widget *sourceParent = event.getSource()->getParent(); + const gcn::Widget *const sourceParent = event.getSource()->getParent(); int selected = -1; for (unsigned int i = 0, sz = static_cast( mCharacterEntries.size()); i < sz; ++i) @@ -227,8 +228,8 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) !mCharacterEntries[selected]->getCharacter()) { // Start new character dialog - CharCreateDialog *charCreateDialog = - new CharCreateDialog(this, selected); + CharCreateDialog *const charCreateDialog = + new CharCreateDialog(this, selected); mCharHandler->setCharCreateDialog(charCreateDialog); } else if (eventId == "delete" @@ -271,7 +272,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) { - int actionId = static_cast(&keyEvent)->getActionId(); + const int actionId = static_cast(&keyEvent)->getActionId(); switch (actionId) { case Input::KEY_GUI_CANCEL: @@ -400,11 +401,11 @@ bool CharSelectDialog::getFocusedContainer(int &container, int &idx) return false; } -void CharSelectDialog::setFocusedContainer(int i, int button) +void CharSelectDialog::setFocusedContainer(const int i, const int button) { if (i >= 0 && i < static_cast(mLoginData->characterSlots)) { - CharacterDisplay *container = mCharacterEntries[i]; + CharacterDisplay *const container = mCharacterEntries[i]; if (button) container->focusDelete(); else @@ -415,7 +416,7 @@ void CharSelectDialog::setFocusedContainer(int i, int button) /** * Communicate character deletion to the server. */ -void CharSelectDialog::attemptCharacterDelete(int index) +void CharSelectDialog::attemptCharacterDelete(const int index) { if (mLocked) return; @@ -424,7 +425,7 @@ void CharSelectDialog::attemptCharacterDelete(int index) lock(); } -void CharSelectDialog::askPasswordForDeletion(int index) +void CharSelectDialog::askPasswordForDeletion(const int index) { mDeleteIndex = index; mDeleteDialog = new TextDialog( @@ -437,7 +438,7 @@ void CharSelectDialog::askPasswordForDeletion(int index) /** * Communicate character selection to the server. */ -void CharSelectDialog::attemptCharacterSelect(int index) +void CharSelectDialog::attemptCharacterSelect(const int index) { if (mLocked || !mCharacterEntries[index]) return; @@ -467,13 +468,15 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters) if (!*i) continue; - Net::Character *character = *i; + Net::Character *const character = *i; // Slots Number start at 1 for Manaserv, so we offset them by one. - int characterSlot = character->slot; #ifdef MANASERV_SUPPORT + int characterSlot = character->slot; if (Net::getNetworkType() == ServerInfo::MANASERV && characterSlot > 0) --characterSlot; +#else + const int characterSlot = character->slot; #endif if (characterSlot >= static_cast(mCharacterEntries.size())) @@ -497,7 +500,7 @@ void CharSelectDialog::unlock() setLocked(false); } -void CharSelectDialog::setLocked(bool locked) +void CharSelectDialog::setLocked(const bool locked) { mLocked = locked; @@ -518,7 +521,7 @@ void CharSelectDialog::setLocked(bool locked) } bool CharSelectDialog::selectByName(const std::string &name, - SelectAction selAction) + const SelectAction selAction) { if (mLocked) return false; @@ -527,7 +530,8 @@ bool CharSelectDialog::selectByName(const std::string &name, { if (mCharacterEntries[i]) { - Net::Character *character = mCharacterEntries[i]->getCharacter(); + const Net::Character *const character + = mCharacterEntries[i]->getCharacter(); if (character) { if (character->dummy && character->dummy->getName() == name) @@ -546,7 +550,7 @@ bool CharSelectDialog::selectByName(const std::string &name, } -CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): +CharacterDisplay::CharacterDisplay(CharSelectDialog *const charSelectDialog) : mCharacter(nullptr), mPlayerBox(new PlayerBox(nullptr)), mName(new Label("wwwwwwwwwwwwwwwwwwwwwwww")), @@ -584,7 +588,7 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): setHeight(200); } -void CharacterDisplay::setCharacter(Net::Character *character) +void CharacterDisplay::setCharacter(Net::Character *const character) { if (mCharacter == character) return; @@ -599,7 +603,7 @@ void CharacterDisplay::requestFocus() mButton->requestFocus(); } -void CharacterDisplay::setActive(bool active) +void CharacterDisplay::setActive(const bool active) { mButton->setEnabled(active); mDelete->setEnabled(active); @@ -609,7 +613,7 @@ void CharacterDisplay::update() { if (mCharacter) { - const LocalPlayer *character = mCharacter->dummy; + const LocalPlayer *const character = mCharacter->dummy; mButton->setCaption(_("Choose")); mButton->setActionEventId("use"); mName->setCaption(strprintf("%s", character->getName().c_str())); diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index fb71b4bf4..0522566f1 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -66,7 +66,7 @@ class CharSelectDialog : public Window, /** * Constructor. */ - CharSelectDialog(LoginData *data); + CharSelectDialog(LoginData *const data); ~CharSelectDialog(); @@ -89,23 +89,24 @@ class CharSelectDialog : public Window, * character). */ bool selectByName(const std::string &name, - SelectAction action = Focus); + const SelectAction action = Focus); - void askPasswordForDeletion(int index); + void askPasswordForDeletion(const int index); private: - void attemptCharacterDelete(int index); - void attemptCharacterSelect(int index); + void attemptCharacterDelete(const int index); + + void attemptCharacterSelect(const int index); void setCharacters(const Net::Characters &characters); void lock(); void unlock(); - void setLocked(bool locked); + void setLocked(const bool locked); bool getFocusedContainer(int &container, int &idx); - void setFocusedContainer(int i, int button); + void setFocusedContainer(const int i, const int button); bool mLocked; diff --git a/src/guichan/actionevent.cpp b/src/guichan/actionevent.cpp index 7348587d7..a2e22abee 100644 --- a/src/guichan/actionevent.cpp +++ b/src/guichan/actionevent.cpp @@ -52,7 +52,7 @@ namespace gcn { - ActionEvent::ActionEvent(Widget* source, const std::string& id) + ActionEvent::ActionEvent(Widget *const source, const std::string &id) :Event(source), mId(id) { diff --git a/src/guichan/basiccontainer.cpp b/src/guichan/basiccontainer.cpp index c74748622..232baedb9 100644 --- a/src/guichan/basiccontainer.cpp +++ b/src/guichan/basiccontainer.cpp @@ -171,7 +171,7 @@ namespace gcn Widget *BasicContainer::getWidgetAt(int x, int y) { - Rectangle r = getChildrenArea(); + const Rectangle r = getChildrenArea(); if (!r.isPointInRect(x, y)) return nullptr; @@ -298,7 +298,7 @@ namespace gcn void BasicContainer::showWidgetPart(Widget* widget, Rectangle area) { - Rectangle widgetArea = getChildrenArea(); + const Rectangle widgetArea = getChildrenArea(); area.x += widget->getX(); area.y += widget->getY(); @@ -344,12 +344,12 @@ namespace gcn if ((*iter)->getId() == id) return (*iter); - BasicContainer *basicContainer - = dynamic_cast(*iter); + BasicContainer *const basicContainer + = dynamic_cast(*iter); if (basicContainer) { - Widget *widget = basicContainer->findWidgetById(id); + Widget *const widget = basicContainer->findWidgetById(id); if (widget) return widget; diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp index 9be06c582..71f1831ed 100644 --- a/src/guichan/focushandler.cpp +++ b/src/guichan/focushandler.cpp @@ -87,7 +87,7 @@ namespace gcn if (toBeFocusedIndex < 0) throw GCN_EXCEPTION("Trying to focus a none existing widget."); - Widget *oldFocused = mFocusedWidget; + Widget *const oldFocused = mFocusedWidget; if (oldFocused != widget) { @@ -164,7 +164,7 @@ namespace gcn if (mWidgets[i] == mFocusedWidget) focusedWidget = i; } - int focused = focusedWidget; + const int focused = focusedWidget; // i is a counter that ensures that the following loop // won't get stuck in an infinite loop @@ -220,7 +220,7 @@ namespace gcn if (mWidgets[i] == mFocusedWidget) focusedWidget = i; } - int focused = focusedWidget; + const int focused = focusedWidget; // i is a counter that ensures that the following loop // won't get stuck in an infinite loop @@ -319,7 +319,7 @@ namespace gcn { if (mFocusedWidget) { - Widget* focused = mFocusedWidget; + Widget *const focused = mFocusedWidget; mFocusedWidget = nullptr; Event focusEvent(focused); @@ -349,7 +349,7 @@ namespace gcn if (mWidgets[i] == mFocusedWidget) focusedWidget = i; } - int focused = focusedWidget; + const int focused = focusedWidget; bool done = false; // i is a counter that ensures that the following loop @@ -373,7 +373,7 @@ namespace gcn if (focusedWidget == focused) return; - const Widget *widget = mWidgets.at(focusedWidget); + const Widget *const widget = mWidgets.at(focusedWidget); if (widget->isFocusable() && widget->isTabInEnabled() && (!mModalFocusedWidget || widget->isModalFocused())) { @@ -418,7 +418,7 @@ namespace gcn if (mWidgets[i] == mFocusedWidget) focusedWidget = i; } - int focused = focusedWidget; + const int focused = focusedWidget; bool done = false; // i is a counter that ensures that the following loop @@ -442,7 +442,7 @@ namespace gcn if (focusedWidget == focused) return; - const Widget *widget = mWidgets.at(focusedWidget); + const Widget *const widget = mWidgets.at(focusedWidget); if (widget->isFocusable() && widget->isTabInEnabled() && (!mModalFocusedWidget || widget->isModalFocused())) { @@ -467,7 +467,7 @@ namespace gcn void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) { - Widget* sourceWidget = focusEvent.getSource(); + Widget *const sourceWidget = focusEvent.getSource(); std::list focusListeners = sourceWidget->_getFocusListeners(); @@ -484,7 +484,7 @@ namespace gcn void FocusHandler::distributeFocusGainedEvent(const Event& focusEvent) { - Widget* sourceWidget = focusEvent.getSource(); + Widget *const sourceWidget = focusEvent.getSource(); std::list focusListeners = sourceWidget->_getFocusListeners(); diff --git a/src/guichan/font.cpp b/src/guichan/font.cpp index bb8006b95..57d51bfff 100644 --- a/src/guichan/font.cpp +++ b/src/guichan/font.cpp @@ -54,7 +54,7 @@ namespace gcn { - int Font::getStringIndexAt(const std::string& text, int x) const + int Font::getStringIndexAt(const std::string& text, const int x) const { for (unsigned int i = 0, sz = static_cast(text.size()); i < sz; ++i) diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp index 1c99d899e..52e183591 100644 --- a/src/guichan/graphics.cpp +++ b/src/guichan/graphics.cpp @@ -118,7 +118,7 @@ namespace gcn carea.height = 0; } - bool result = carea.isIntersecting(top); + const bool result = carea.isIntersecting(top); mClipStack.push(carea); diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp index 005b3505b..fda5cc1e7 100644 --- a/src/guichan/gui.cpp +++ b/src/guichan/gui.cpp @@ -162,8 +162,8 @@ namespace gcn void Gui::handleMouseInput() { while (!mInput->isMouseQueueEmpty()) - { - MouseInput mouseInput = mInput->dequeueMouseInput(); + { + const MouseInput mouseInput = mInput->dequeueMouseInput(); // Save the current mouse state. It will be needed if modal focus // changes or modal mouse input focus changes. @@ -209,7 +209,7 @@ namespace gcn // "widget with mouse" queue. while (!mWidgetWithMouseQueue.empty()) { - Widget* widget = mWidgetWithMouseQueue.front(); + Widget *const widget = mWidgetWithMouseQueue.front(); if (Widget::widgetExists(widget)) { @@ -239,7 +239,7 @@ namespace gcn iter != mWidgetWithMouseQueue.end(); ++ iter) { - Widget* widget = *iter; + Widget *const widget = *iter; // If a widget in the "widget with mouse queue" doesn't // exists anymore it should be removed from the queue. @@ -343,7 +343,7 @@ namespace gcn mWidgetWithMouseQueue.push_front(widget); } - Widget* swap = widget; + Widget *const swap = widget; widget = parent; parent = swap->getParent(); } @@ -358,7 +358,7 @@ namespace gcn } else { - Widget* sourceWidget = getMouseEventSource( + Widget *const sourceWidget = getMouseEventSource( mouseInput.getX(), mouseInput.getY()); distributeMouseEvent(sourceWidget, @@ -499,7 +499,7 @@ namespace gcn while (child) { - Widget* swap = child; + Widget *const swap = child; int parentX, parentY; parent->getAbsolutePosition(parentX, parentY); child = parent->getWidgetAt(x - parentX, y - parentY); @@ -511,7 +511,7 @@ namespace gcn Widget* Gui::getMouseEventSource(int x, int y) { - Widget* widget = getWidgetAt(x, y); + Widget *const widget = getWidgetAt(x, y); //+++ possible nullpointer if (mFocusHandler->getModalMouseInputFocused() @@ -637,7 +637,7 @@ namespace gcn break; } - Widget* swap = widget; + Widget *const swap = widget; widget = parent; parent = swap->getParent(); @@ -710,7 +710,7 @@ namespace gcn } } - Widget* swap = widget; + const Widget *const swap = widget; widget = parent; parent = swap->getParent(); @@ -793,7 +793,7 @@ namespace gcn // Distribute an event to all widgets in the "widget with mouse" queue. while (!mWidgetWithMouseQueue.empty()) { - Widget* widget = mWidgetWithMouseQueue.front(); + Widget *const widget = mWidgetWithMouseQueue.front(); if (Widget::widgetExists(widget)) { @@ -855,7 +855,7 @@ namespace gcn mWidgetWithMouseQueue.push_front(widget); } - Widget* swap = widget; + const Widget *const swap = widget; widget = parent; parent = swap->getParent(); } diff --git a/src/guichan/include/guichan/actionevent.hpp b/src/guichan/include/guichan/actionevent.hpp index a6c54f516..b8927931c 100644 --- a/src/guichan/include/guichan/actionevent.hpp +++ b/src/guichan/include/guichan/actionevent.hpp @@ -86,7 +86,7 @@ namespace gcn * @param source The source widget of the event. * @param id An identifier of the event. */ - ActionEvent(Widget* source, const std::string& id); + ActionEvent(Widget *const source, const std::string &id); /** * Destructor. diff --git a/src/guichan/include/guichan/font.hpp b/src/guichan/include/guichan/font.hpp index d39630352..cc177928e 100644 --- a/src/guichan/include/guichan/font.hpp +++ b/src/guichan/include/guichan/font.hpp @@ -64,7 +64,8 @@ namespace gcn /** * Destructor. */ - virtual ~Font(){ } + virtual ~Font() + { } /** * Gets the width of a string. The width of a string is not necesserily @@ -91,7 +92,8 @@ namespace gcn * * @return A string index in a string providing an x coordinate. */ - virtual int getStringIndexAt(const std::string& text, int x) const; + virtual int getStringIndexAt(const std::string& text, + const int x) const; /** * Draws a string. diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp index 0be0bfe59..c3afddb74 100644 --- a/src/guichan/sdl/sdlgraphics.cpp +++ b/src/guichan/sdl/sdlgraphics.cpp @@ -94,7 +94,7 @@ namespace gcn bool SDLGraphics::pushClipArea(Rectangle area) { SDL_Rect rect; - bool result = Graphics::pushClipArea(area); + const bool result = Graphics::pushClipArea(area); const ClipRectangle& carea = mClipStack.top(); rect.x = static_cast(carea.x); @@ -205,14 +205,14 @@ namespace gcn x2 = top.x + top.width -1; } - int bpp = mTarget->format->BytesPerPixel; + const int bpp = mTarget->format->BytesPerPixel; SDL_LockSurface(mTarget); uint8_t *p = static_cast(mTarget->pixels) + y * mTarget->pitch + x1 * bpp; - uint32_t pixel = SDL_MapRGB(mTarget->format, + const uint32_t pixel = SDL_MapRGB(mTarget->format, static_cast(mColor.r), static_cast(mColor.g), static_cast(mColor.b)); @@ -319,14 +319,14 @@ namespace gcn y2 = top.y + top.height - 1; } - int bpp = mTarget->format->BytesPerPixel; + const int bpp = mTarget->format->BytesPerPixel; SDL_LockSurface(mTarget); uint8_t *p = static_cast(mTarget->pixels) + y1 * mTarget->pitch + x * bpp; - uint32_t pixel = SDL_MapRGB(mTarget->format, + const uint32_t pixel = SDL_MapRGB(mTarget->format, static_cast(mColor.r), static_cast(mColor.g), static_cast(mColor.b)); @@ -399,10 +399,10 @@ namespace gcn void SDLGraphics::drawRectangle(const Rectangle& rectangle) { - int x1 = rectangle.x; - int x2 = rectangle.x + rectangle.width - 1; - int y1 = rectangle.y; - int y2 = rectangle.y + rectangle.height - 1; + const int x1 = rectangle.x; + const int x2 = rectangle.x + rectangle.width - 1; + const int y1 = rectangle.y; + const int y2 = rectangle.y + rectangle.height - 1; drawHLine(x1, y1, x2); drawHLine(x1, y2, x2); @@ -439,8 +439,8 @@ namespace gcn // Draw a line with Bresenham - int dx = ABS(x2 - x1); - int dy = ABS(y2 - y1); + const int dx = ABS(x2 - x1); + const int dy = ABS(y2 - y1); if (dx > dy) { diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp index efeb80486..8b68b8510 100644 --- a/src/guichan/widget.cpp +++ b/src/guichan/widget.cpp @@ -110,14 +110,13 @@ namespace gcn void Widget::drawFrame(Graphics* graphics) { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - int width = getWidth() + getFrameSize() * 2 - 1; - int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor = faceColor + 0x303030; + const Color faceColor = getBaseColor(); + Color highlightColor = faceColor + 0x303030; + Color shadowColor = faceColor - 0x303030; + const int alpha = getBaseColor().a; + const int width = getWidth() + getFrameSize() * 2 - 1; + const int height = getHeight() + getFrameSize() * 2 - 1; highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; shadowColor.a = alpha; for (unsigned int i = 0; i < getFrameSize(); ++i) @@ -204,7 +203,7 @@ namespace gcn void Widget::setDimension(const Rectangle& dimension) { - Rectangle oldDimension = mDimension; + const Rectangle oldDimension = mDimension; mDimension = dimension; if (mDimension.width != oldDimension.width diff --git a/src/guichan/widgets/checkbox.cpp b/src/guichan/widgets/checkbox.cpp index 413f8e6af..fe0bfbee4 100644 --- a/src/guichan/widgets/checkbox.cpp +++ b/src/guichan/widgets/checkbox.cpp @@ -118,7 +118,7 @@ namespace gcn void CheckBox::adjustSize() { - int height = getFont()->getHeight(); + const int height = getFont()->getHeight(); setHeight(height); setWidth(getFont()->getWidth(mCaption) + height + height / 2); diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp index 9f2180a72..0cd979adc 100644 --- a/src/guichan/widgets/dropdown.cpp +++ b/src/guichan/widgets/dropdown.cpp @@ -230,10 +230,10 @@ namespace gcn if (!mListBox) throw GCN_EXCEPTION("List box has been deleted."); - int listBoxHeight = mListBox->getHeight(); + const int listBoxHeight = mListBox->getHeight(); // We add 2 for the border - int h2 = getFont()->getHeight() + 2; + const int h2 = getFont()->getHeight() + 2; setHeight(h2); @@ -242,7 +242,7 @@ namespace gcn if (mDroppedDown && getParent()) { - int h = getParent()->getChildrenArea().height - getY(); + const int h = getParent()->getChildrenArea().height - getY(); if (listBoxHeight > h - h2 - 2) { diff --git a/src/guichan/widgets/label.cpp b/src/guichan/widgets/label.cpp index 3e0eecb3c..815bba741 100644 --- a/src/guichan/widgets/label.cpp +++ b/src/guichan/widgets/label.cpp @@ -91,7 +91,7 @@ namespace gcn void Label::draw(Graphics* graphics) { int textX; - int textY = getHeight() / 2 - getFont()->getHeight() / 2; + const int textY = getHeight() / 2 - getFont()->getHeight() / 2; switch (getAlignment()) { diff --git a/src/guichan/widgets/radiobutton.cpp b/src/guichan/widgets/radiobutton.cpp index 26bd7e44c..7f8d846d9 100644 --- a/src/guichan/widgets/radiobutton.cpp +++ b/src/guichan/widgets/radiobutton.cpp @@ -177,7 +177,7 @@ namespace gcn void RadioButton::adjustSize() { - int height = getFont()->getHeight(); + const int height = getFont()->getHeight(); setHeight(height); setWidth(getFont()->getWidth(getCaption()) + height + height / 2); diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp index 9668f9778..1251bc665 100644 --- a/src/guichan/widgets/scrollarea.cpp +++ b/src/guichan/widgets/scrollarea.cpp @@ -195,7 +195,7 @@ namespace gcn void ScrollArea::setVerticalScrollAmount(int vScroll) { - int max = getVerticalMaxScroll(); + const int max = getVerticalMaxScroll(); mVScroll = vScroll; @@ -213,7 +213,7 @@ namespace gcn void ScrollArea::setHorizontalScrollAmount(int hScroll) { - int max = getHorizontalMaxScroll(); + const int max = getHorizontalMaxScroll(); mHScroll = hScroll; @@ -241,7 +241,7 @@ namespace gcn if (!getContent()) return 0; - int value = getContent()->getWidth() - getChildrenArea().width + + const int value = getContent()->getWidth() - getChildrenArea().width + 2 * getContent()->getFrameSize(); if (value < 0) @@ -283,8 +283,8 @@ namespace gcn void ScrollArea::mousePressed(MouseEvent& mouseEvent) { - int x = mouseEvent.getX(); - int y = mouseEvent.getY(); + const int x = mouseEvent.getX(); + const int y = mouseEvent.getY(); if (getUpButtonDimension().isPointInRect(x, y)) { @@ -368,11 +368,11 @@ namespace gcn { if (mIsVerticalMarkerDragged) { - Rectangle barDim = getVerticalBarDimension(); + const Rectangle barDim = getVerticalBarDimension(); - int pos = mouseEvent.getY() - barDim.y + const int pos = mouseEvent.getY() - barDim.y - mVerticalMarkerDragOffset; - int length = getVerticalMarkerDimension().height; + const int length = getVerticalMarkerDimension().height; if ((barDim.height - length) > 0) { @@ -387,11 +387,11 @@ namespace gcn if (mIsHorizontalMarkerDragged) { - Rectangle barDim = getHorizontalBarDimension(); + const Rectangle barDim = getHorizontalBarDimension(); - int pos = mouseEvent.getX() - barDim.x + const int pos = mouseEvent.getX() - barDim.x - mHorizontalMarkerDragOffset; - int length = getHorizontalMarkerDimension().width; + const int length = getHorizontalMarkerDimension().width; if ((barDim.width - length) > 0) { @@ -464,13 +464,12 @@ namespace gcn void ScrollArea::checkPolicies() { - int w = getWidth(); - int h = getHeight(); + const int w = getWidth(); + const int h = getHeight(); mHBarVisible = false; mVBarVisible = false; - if (!getContent()) { mHBarVisible = (mHPolicy == SHOW_ALWAYS); @@ -616,7 +615,7 @@ namespace gcn Rectangle ScrollArea::getChildrenArea() { - Rectangle area = Rectangle(0, 0, + const Rectangle area = Rectangle(0, 0, mVBarVisible ? (getWidth() - mScrollbarWidth) : getWidth(), mHBarVisible ? (getHeight() - mScrollbarWidth) : getHeight()); diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp index 189ee6e7b..ed14f525a 100644 --- a/src/guichan/widgets/slider.cpp +++ b/src/guichan/widgets/slider.cpp @@ -209,7 +209,7 @@ namespace gcn else w = getHeight(); - double pos = v / (static_cast(w) - getMarkerLength()); + const double pos = v / (static_cast(w) - getMarkerLength()); return (1.0 - pos) * getScaleStart() + pos * getScaleEnd(); } @@ -221,7 +221,7 @@ namespace gcn else v = getHeight(); - int w = static_cast((v - getMarkerLength()) + const int w = static_cast((v - getMarkerLength()) * (value - getScaleStart()) / (getScaleEnd() - getScaleStart())); diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp index 6f4c4a2b9..7bd77e7cd 100644 --- a/src/guichan/widgets/tabbedarea.cpp +++ b/src/guichan/widgets/tabbedarea.cpp @@ -220,7 +220,7 @@ namespace gcn int x = 0; for (i = 0; i < sz; i++) { - Tab* tab = mTabs[i].first; + Tab *const tab = mTabs[i].first; tab->setPosition(x, maxTabHeight - tab->getHeight()); x += tab->getWidth(); } @@ -256,7 +256,7 @@ namespace gcn void TabbedArea::death(const Event& event) { - Tab* tab = dynamic_cast(event.getSource()); + Tab *const tab = dynamic_cast(event.getSource()); if (tab) removeTab(tab); @@ -266,8 +266,8 @@ namespace gcn void TabbedArea::action(const ActionEvent& actionEvent) { - Widget* source = actionEvent.getSource(); - Tab* tab = dynamic_cast(source); + Widget *const source = actionEvent.getSource(); + Tab *const tab = dynamic_cast(source); if (!tab) { diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp index 97256eb44..0640b6a2c 100644 --- a/src/guichan/widgets/textbox.cpp +++ b/src/guichan/widgets/textbox.cpp @@ -172,7 +172,7 @@ namespace gcn int width = 0; for (size_t i = 0, sz = mTextRows.size(); i < sz; ++i) { - int w = getFont()->getWidth(mTextRows[i]); + const int w = getFont()->getWidth(mTextRows[i]); if (width < w) width = w; } diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp index b74d2333f..2fffdc5f5 100644 --- a/src/guichan/widgets/textfield.cpp +++ b/src/guichan/widgets/textfield.cpp @@ -132,7 +132,8 @@ namespace gcn { if (isFocused()) { - int caretX = getFont()->getWidth(mText.substr(0, mCaretPosition)); + const int caretX = getFont()->getWidth( + mText.substr(0, mCaretPosition)); if (caretX - mXScroll >= getWidth() - 4) { diff --git a/src/net/buysellhandler.h b/src/net/buysellhandler.h index 3fbcbe733..dc41f63dc 100644 --- a/src/net/buysellhandler.h +++ b/src/net/buysellhandler.h @@ -42,11 +42,13 @@ class BuySellHandler virtual void requestBuyList(std::string nick) = 0; - virtual void sendBuyRequest(std::string nick, ShopItem* item, - int amount) = 0; + virtual void sendBuyRequest(const std::string &nick, + const ShopItem *const item, + const int amount) = 0; - virtual void sendSellRequest(std::string nick, ShopItem* item, - int amount) = 0; + virtual void sendSellRequest(const std::string &nick, + const ShopItem *const item, + const int amount) = 0; }; } // namespace Net diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index d9080b969..8566bcab7 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -90,8 +90,9 @@ void BuySellHandler::requestBuyList(std::string nick) } } -void BuySellHandler::sendBuyRequest(std::string nick, ShopItem* item, - int amount) +void BuySellHandler::sendBuyRequest(const std::string &nick, + const ShopItem *const item, + const int amount) { if (!chatWindow || nick.empty() || !item || amount < 1 || amount > item->getQuantity()) @@ -107,8 +108,9 @@ void BuySellHandler::sendBuyRequest(std::string nick, ShopItem* item, chatWindow->addWhisper(nick, data, BY_PLAYER); } -void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item, - int amount) +void BuySellHandler::sendSellRequest(const std::string &nick, + const ShopItem *const item, + const int amount) { if (!chatWindow || nick.empty() || !item || amount < 1 || amount > item->getQuantity()) diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h index 14d39ea02..26f0d2716 100644 --- a/src/net/ea/buysellhandler.h +++ b/src/net/ea/buysellhandler.h @@ -43,11 +43,13 @@ class BuySellHandler : public Net::BuySellHandler virtual void requestBuyList(std::string nick); - virtual void sendBuyRequest(std::string nick, ShopItem* item, - int amount); + virtual void sendBuyRequest(const std::string &nick, + const ShopItem *const item, + const int amount); - virtual void sendSellRequest(std::string nick, ShopItem* item, - int amount); + virtual void sendSellRequest(const std::string &nick, + const ShopItem *const item, + const int amount); virtual void processNpcBuySellChoice(Net::MessageIn &msg); -- cgit v1.2.3-70-g09d2