From 520a495c466793c29f3e721634dfe6cc616b8ede Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 1 May 2014 23:56:03 +0300 Subject: Add missing const. --- src/being/localplayer.cpp | 3 ++- src/being/localplayer.h | 3 ++- src/client.cpp | 9 ++++----- src/commands.cpp | 2 +- src/dragdrop.h | 2 +- src/gui/focushandler.cpp | 7 +++---- src/gui/focushandler.h | 4 ++-- src/gui/gui.cpp | 4 ++-- src/gui/gui.h | 2 +- src/gui/popups/popupmenu.cpp | 12 ++++++------ src/gui/popups/popupmenu.h | 10 +++++----- src/gui/widgets/scrollarea.cpp | 4 ++-- src/gui/widgets/scrollarea.h | 4 ++-- src/gui/windows/changeemaildialog.cpp | 2 +- src/gui/windows/changepassworddialog.cpp | 2 +- src/gui/windows/chatwindow.cpp | 6 +++--- src/gui/windows/chatwindow.h | 6 +++--- src/gui/windows/itemamountwindow.cpp | 6 ++++-- src/gui/windows/itemamountwindow.h | 14 +++++++++----- src/gui/windows/logindialog.cpp | 2 +- src/gui/windows/statuswindow.cpp | 2 +- src/gui/windows/unregisterdialog.cpp | 2 +- src/gui/windows/whoisonline.cpp | 2 +- src/gui/windows/whoisonline.h | 2 +- src/maplayer.cpp | 6 ++++-- src/maplayer.h | 4 ++-- src/net/download.cpp | 4 +--- src/net/download.h | 2 +- src/net/ea/loginhandler.cpp | 2 +- src/net/ea/loginhandler.h | 2 +- src/net/eathena/partyhandler.cpp | 4 ++-- src/net/eathena/partyhandler.h | 4 ++-- src/net/loginhandler.h | 3 ++- src/net/partyhandler.h | 4 ++-- src/net/tmwa/partyhandler.cpp | 4 ++-- src/net/tmwa/partyhandler.h | 4 ++-- src/render/mobileopenglgraphics.cpp | 2 -- src/resources/atlasmanager.cpp | 9 +++++---- src/resources/atlasmanager.h | 5 +++-- src/resources/mapreader.cpp | 2 +- src/resources/resourcemanager.cpp | 4 ++-- src/resources/resourcemanager.h | 2 +- src/spellmanager.cpp | 2 +- src/test/testlauncher.cpp | 3 +-- src/utils/langs.cpp | 6 +++--- src/utils/stringutils.cpp | 2 +- src/utils/stringutils.h | 2 +- 47 files changed, 100 insertions(+), 94 deletions(-) (limited to 'src') diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 3813f5121..feb6c590a 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -3370,7 +3370,8 @@ void LocalPlayer::imitateDirection(const Being *const being, } } -void LocalPlayer::imitateOutfit(Being *const player, const int sprite) const +void LocalPlayer::imitateOutfit(const Being *const player, + const int sprite) const { if (!player) return; diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 5e8e0e8fe..a0ff28dc2 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -349,7 +349,8 @@ class LocalPlayer final : public Being, void imitateDirection(const Being *const being, const unsigned char dir); - void imitateOutfit(Being *const player, const int sprite = -1) const; + void imitateOutfit(const Being *const player, + const int sprite = -1) const; void followMoveTo(const Being *const being, const int x, const int y); diff --git a/src/client.cpp b/src/client.cpp index 83147d34c..78df4e161 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -440,8 +440,7 @@ void Client::gameInit() if (mCurrentServer.hostname.empty()) { - mCurrentServer.hostname = - branding.getValue("defaultServer", "").c_str(); + mCurrentServer.hostname = branding.getValue("defaultServer", ""); mOptions.serverName = mCurrentServer.hostname; } @@ -2996,12 +2995,12 @@ void Client::setIcon() // Attempt to load icon from .ico file HICON icon = (HICON) LoadImage(nullptr, iconFile.c_str(), IMAGE_ICON, 64, 64, LR_LOADFROMFILE); - if (!icon) - logger->log("icon load error"); // If it's failing, we load the default resource file. if (!icon) + { + logger->log("icon load error"); icon = LoadIcon(GetModuleHandle(nullptr), "A"); - + } if (icon) SetClassLong(pInfo.window, GCL_HICON, reinterpret_cast(icon)); #else diff --git a/src/commands.cpp b/src/commands.cpp index ef1e2faac..aeb1f3f53 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -98,7 +98,7 @@ extern char **environ; namespace Commands { -static void outString(ChatTab *const tab, +static void outString(const ChatTab *const tab, const std::string &str, const std::string &def) { diff --git a/src/dragdrop.h b/src/dragdrop.h index 157b1aec8..6f18479a4 100644 --- a/src/dragdrop.h +++ b/src/dragdrop.h @@ -195,7 +195,7 @@ class DragDrop final bool isEmpty() const { return mSource == DRAGDROP_SOURCE_EMPTY; } - void select(Item *const item) + void select(const Item *const item) { if (item) { diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index ced7c5f6e..4c832c566 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -109,8 +109,7 @@ void FocusHandler::releaseModalFocus(Widget *const widget) if (mModalFocusedWidget == widget) { - if (mModalFocusedWidget == widget) - mModalFocusedWidget = nullptr; + mModalFocusedWidget = nullptr; /* Check if there were any previously modal widgets that'd still like * to regain their modal focus. @@ -353,7 +352,7 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) } } -void FocusHandler::requestFocus(Widget *const widget) +void FocusHandler::requestFocus(const Widget *const widget) { if (!widget || widget == mFocusedWidget) return; @@ -400,7 +399,7 @@ void FocusHandler::requestModalMouseInputFocus(Widget *const widget) mModalMouseInputFocusedWidget = widget; } -void FocusHandler::releaseModalMouseInputFocus(Widget *const widget) +void FocusHandler::releaseModalMouseInputFocus(const Widget *const widget) { if (mModalMouseInputFocusedWidget == widget) mModalMouseInputFocusedWidget = nullptr; diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index 58b317024..99ba45094 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -97,7 +97,7 @@ class FocusHandler final * @param widget The widget to request focus for. * @see isFocused, Widget::requestFocus */ - void requestFocus(Widget *const widget); + void requestFocus(const Widget *const widget); /** * Requests modal focus for a widget. Focus will only be granted @@ -144,7 +144,7 @@ class FocusHandler final * @param widget the widget to release modal mouse input focus for. * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus */ - void releaseModalMouseInputFocus(Widget *const widget); + void releaseModalMouseInputFocus(const Widget *const widget); /** * Checks if a widget is focused. diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 7be573995..dda1cc64a 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -1102,7 +1102,7 @@ void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent) } } -void Gui::removeDragged(Widget *widget) +void Gui::removeDragged(const Widget *const widget) { if (!mFocusHandler) return; @@ -1246,7 +1246,7 @@ Widget* Gui::getKeyEventSource() const void Gui::distributeKeyEvent(KeyEvent &event) const { Widget* parent = event.getSource(); - Widget* widget = event.getSource(); + Widget* widget = parent; if (mFocusHandler->getModalFocused() && !widget->isModalFocused()) return; diff --git a/src/gui/gui.h b/src/gui/gui.h index b4f9991f0..43594ad9f 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -213,7 +213,7 @@ class Gui final void distributeGlobalFocusGainedEvent(const Event &focusEvent); - void removeDragged(Widget *widget); + void removeDragged(const Widget *const widget); int getLastMouseX() const { return mLastMouseX; } diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index c8416f66d..9e6968464 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -311,7 +311,7 @@ void PopupMenu::showPopup(const int x, const int y, const Being *const being) } void PopupMenu::showPopup(const int x, const int y, - std::vector &beings) + const std::vector &beings) { mX = x; mY = y; @@ -1543,7 +1543,7 @@ void PopupMenu::handleLink(const std::string &link, std::list mobs = actorManager->getAttackMobs(); std::list::iterator it = mobs.begin(); - std::list::iterator it2 = mobs.begin(); + std::list::iterator it2 = it; while (it != mobs.end()) { if (*it == mNick) @@ -1574,7 +1574,7 @@ void PopupMenu::handleLink(const std::string &link, std::list mobs = actorManager->getPriorityAttackMobs(); std::list::iterator it = mobs.begin(); - std::list::iterator it2 = mobs.begin(); + std::list::iterator it2 = it; while (it != mobs.end()) { if (*it == mNick) @@ -1605,7 +1605,7 @@ void PopupMenu::handleLink(const std::string &link, std::list mobs = actorManager->getAttackMobs(); std::list::iterator it = mobs.begin(); - std::list::iterator it2 = mobs.begin(); + std::list::iterator it2 = it; while (it != mobs.end()) { if (*it == mNick) @@ -1640,7 +1640,7 @@ void PopupMenu::handleLink(const std::string &link, std::list mobs = actorManager->getPriorityAttackMobs(); std::list::iterator it = mobs.begin(); - std::list::iterator it2 = mobs.begin(); + std::list::iterator it2 = it; while (it != mobs.end()) { if (*it == mNick) @@ -2906,7 +2906,7 @@ RenameListener::RenameListener() : { } -void RenameListener::setMapItem(MapItem *const mapItem) +void RenameListener::setMapItem(const MapItem *const mapItem) { if (mapItem) { diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 8bdbd3b1b..94db12343 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -55,7 +55,7 @@ class RenameListener final : public ActionListener void action(const ActionEvent &event) override final; - void setMapItem(MapItem *const mapItem); + void setMapItem(const MapItem *const mapItem); void setDialog(TextDialog *dialog) { mDialog = dialog; } @@ -75,13 +75,13 @@ class PlayerListener : public ActionListener void action(const ActionEvent &event) override final; - void setNick(std::string name) + void setNick(const std::string &name) { mNick = name; } - void setDialog(TextDialog *dialog) + void setDialog(TextDialog *const dialog) { mDialog = dialog; } - void setType(int type) + void setType(const int type) { mType = type; } private: @@ -114,7 +114,7 @@ class PopupMenu final : public Popup, public LinkHandler * Shows the beings related popup menu at the specified mouse coords. */ void showPopup(const int x, const int y, - std::vector &beings); + const std::vector &beings); void showPlayerPopup(const int x, const int y, const std::string &nick); diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index b748e30a1..8761e3f7d 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -532,7 +532,7 @@ void ScrollArea::drawVBar(Graphics *const graphics) const } } -void ScrollArea::calcVBar(Graphics *const graphics) +void ScrollArea::calcVBar(const Graphics *const graphics) { const Rect &dim = getVerticalBarDimension(); @@ -587,7 +587,7 @@ void ScrollArea::drawHBar(Graphics *const graphics) const } } -void ScrollArea::calcHBar(Graphics *const graphics) +void ScrollArea::calcHBar(const Graphics *const graphics) { const Rect &dim = getHorizontalBarDimension(); diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 0d540c399..01ec4e13c 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -451,8 +451,8 @@ class ScrollArea final : public BasicContainer, void drawVMarker(Graphics *const graphics); void drawHMarker(Graphics *const graphics); - void calcVBar(Graphics *const graphics); - void calcHBar(Graphics *const graphics); + void calcVBar(const Graphics *const graphics); + void calcHBar(const Graphics *const graphics); void calcVMarker(Graphics *const graphics); void calcHMarker(Graphics *const graphics); diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp index 0f4086a0b..420dc3b76 100644 --- a/src/gui/windows/changeemaildialog.cpp +++ b/src/gui/windows/changeemaildialog.cpp @@ -118,7 +118,7 @@ void ChangeEmailDialog::action(const ActionEvent &event) } else if (eventId == "change_email") { - const std::string username = mLoginData->username.c_str(); + const std::string username = mLoginData->username; const std::string &newFirstEmail = mFirstEmailField->getText(); const std::string &newSecondEmail = mSecondEmailField->getText(); logger->log("ChangeEmailDialog::Email change, Username is %s", diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp index eb7380f20..383b6a63e 100644 --- a/src/gui/windows/changepassworddialog.cpp +++ b/src/gui/windows/changepassworddialog.cpp @@ -97,7 +97,7 @@ void ChangePasswordDialog::action(const ActionEvent &event) } else if (eventId == "change_password") { - const std::string username = mLoginData->username.c_str(); + const std::string username = mLoginData->username; const std::string &oldPassword = mOldPassField->getText(); const std::string &newFirstPass = mFirstPassField->getText(); const std::string &newSecondPass = mSecondPassField->getText(); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 1b1973f63..ad646ce82 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1334,7 +1334,7 @@ void ChatWindow::autoComplete() } } -std::string ChatWindow::autoComplete(StringVect &names, +std::string ChatWindow::autoComplete(const StringVect &names, std::string partName) { StringVectCIter i = names.begin(); @@ -1365,7 +1365,7 @@ std::string ChatWindow::autoComplete(StringVect &names, } std::string ChatWindow::autoComplete(const std::string &partName, - History *const words) const + const History *const words) const { if (!words) return ""; @@ -1605,7 +1605,7 @@ void ChatWindow::initTradeFilter() } } -void ChatWindow::updateOnline(std::set &onlinePlayers) const +void ChatWindow::updateOnline(const std::set &onlinePlayers) const { const Party *party = nullptr; const Guild *guild = nullptr; diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 3999d6b8a..114c6008c 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -240,7 +240,7 @@ class ChatWindow final : public Window, const bool ignoreRecord = false, const bool tryRemoveColors = true); - void updateOnline(std::set &onlinePlayers) const; + void updateOnline(const std::set &onlinePlayers) const; void loadState(); @@ -331,9 +331,9 @@ class ChatWindow final : public Window, std::string autoCompleteHistory(const std::string &partName) const; std::string autoComplete(const std::string &partName, - History *const words) const; + const History *const words) const; - static std::string autoComplete(StringVect &names, + static std::string autoComplete(const StringVect &names, std::string partName); /** Used for showing item popup on clicking links **/ diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 9c2e039f9..92ceeae76 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -53,8 +53,10 @@ #include "debug.h" -void ItemAmountWindow::finish(Item *const item, const int amount, - const int price, const Usage usage) +void ItemAmountWindow::finish(const Item *const item, + const int amount, + const int price, + const Usage usage) { switch (usage) { diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h index d2dca064e..ec36265af 100644 --- a/src/gui/windows/itemamountwindow.h +++ b/src/gui/windows/itemamountwindow.h @@ -93,11 +93,15 @@ class ItemAmountWindow final : public Window, ~ItemAmountWindow(); private: - static void finish(Item *const item, const int amount, - const int price, const Usage usage); - - ItemAmountWindow(const Usage usage, Window *const parent, - Item *const item, const int maxRange = 0); + static void finish(const Item *const item, + const int amount, + const int price, + const Usage usage); + + 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/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index b2242d3f6..d1202dea7 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -302,7 +302,7 @@ void LoginDialog::prepareUpdate() if (checkPath(mUpdateHostText->getText())) { mLoginData->updateHost = mUpdateHostText->getText(); - *mUpdateHost = mUpdateHostText->getText(); + *mUpdateHost = mLoginData->updateHost; } else { diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index a45c206f5..e76658b05 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -646,7 +646,7 @@ void StatusWindow::updateMoneyBar(ProgressBar *const bar) return; const int money = PlayerInfo::getAttribute(PlayerInfo::MONEY); - bar->setText(Units::formatCurrency(money).c_str()); + bar->setText(Units::formatCurrency(money)); if (money > 0) { const float progress = static_cast(money) diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp index 3d8627add..e35c27aa2 100644 --- a/src/gui/windows/unregisterdialog.cpp +++ b/src/gui/windows/unregisterdialog.cpp @@ -110,7 +110,7 @@ void UnRegisterDialog::action(const ActionEvent &event) } else if (eventId == "unregister") { - const std::string username = mLoginData->username.c_str(); + const std::string username = mLoginData->username; const std::string &password = mPasswordField->getText(); logger->log("UnregisterDialog::unregistered, Username is %s", username.c_str()); diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 34ae7aa49..0bf05a129 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -292,7 +292,7 @@ void WhoIsOnline::handlerPlayerRelation(const std::string &nick, } } -void WhoIsOnline::loadList(std::vector &list) +void WhoIsOnline::loadList(const std::vector &list) { mBrowserBox->clearRows(); const size_t numOnline = list.size(); diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index 915150409..448321866 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -125,7 +125,7 @@ public: */ void loadWebList(); - void loadList(std::vector &list); + void loadList(const std::vector &list); void handleLink(const std::string& link, MouseEvent *event) override final; diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 7db90b956..bfecd90d8 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -178,7 +178,8 @@ void MapLayer::drawSDL(Graphics *const graphics) } #ifdef USE_OPENGL -void MapLayer::updateSDL(Graphics *const graphics, int startX, int startY, +void MapLayer::updateSDL(const Graphics *const graphics, + int startX, int startY, int endX, int endY, const int scrollX, const int scrollY, const int debugFlags) @@ -242,7 +243,8 @@ void MapLayer::updateSDL(Graphics *const graphics, int startX, int startY, BLOCK_END("MapLayer::updateSDL") } -void MapLayer::updateOGL(Graphics *const graphics, int startX, int startY, +void MapLayer::updateOGL(const Graphics *const graphics, + int startX, int startY, int endX, int endY, const int scrollX, const int scrollY, const int debugFlags) diff --git a/src/maplayer.h b/src/maplayer.h index ad2378010..19b8f2503 100644 --- a/src/maplayer.h +++ b/src/maplayer.h @@ -141,14 +141,14 @@ class MapLayer final: public ConfigListener #ifdef USE_OPENGL void drawOGL(Graphics *const graphics); - void updateOGL(Graphics *const graphics, + void updateOGL(const Graphics *const graphics, int startX, int startY, int endX, int endY, const int scrollX, const int scrollY, const int mDebugFlags); #endif - void updateSDL(Graphics *const graphics, + void updateSDL(const Graphics *const graphics, int startX, int startY, int endX, int endY, const int scrollX, const int scrollY, diff --git a/src/net/download.cpp b/src/net/download.cpp index cf5a1d0b3..86a6a88e8 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -138,8 +138,6 @@ unsigned long Download::fadler32(FILE *const file) // Calculate Adler-32 checksum char *const buffer = new char[fileSize]; - if (!buffer) - return 0; const uInt read = static_cast(fread(buffer, 1, fileSize, file)); unsigned long adler = adler32(0L, Z_NULL, 0); adler = adler32(static_cast(adler), @@ -148,7 +146,7 @@ unsigned long Download::fadler32(FILE *const file) return adler; } -unsigned long Download::adlerBuffer(char *const buffer, int size) +unsigned long Download::adlerBuffer(const char *const buffer, int size) { unsigned long adler = adler32(0L, Z_NULL, 0); return adler32(static_cast(adler), diff --git a/src/net/download.h b/src/net/download.h index 3628a8f3a..d9a88f8a5 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -106,7 +106,7 @@ class Download final static void addHeaders(CURL *const curl); - static unsigned long adlerBuffer(char *const buffer, int size); + static unsigned long adlerBuffer(const char *const buffer, int size); static std::string getUploadResponse() { return mUploadResponse; } diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 174263dcd..af86aaf93 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -93,7 +93,7 @@ void LoginHandler::chooseServer(const unsigned int server) const client->setState(STATE_UPDATE); } -void LoginHandler::registerAccount(LoginData *const loginData1) const +void LoginHandler::registerAccount(const LoginData *const loginData1) const { if (!loginData1) return; diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index a6e7160cb..8619d4c34 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -63,7 +63,7 @@ class LoginHandler : public Net::LoginHandler virtual void chooseServer(const unsigned int server) const override; - virtual void registerAccount(LoginData *const loginData) + virtual void registerAccount(const LoginData *const loginData) const override final; virtual const Worlds &getWorlds() const override final A_WARN_UNUSED; diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index dc65fb3ad..6d39fe85b 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -110,7 +110,7 @@ void PartyHandler::create(const std::string &name) const outMsg.writeString(name.substr(0, 23), 24); } -void PartyHandler::invite(Being *const being) const +void PartyHandler::invite(const Being *const being) const { if (being) { @@ -149,7 +149,7 @@ void PartyHandler::leave() const MessageOut outMsg(CMSG_PARTY_LEAVE); } -void PartyHandler::kick(Being *const being) const +void PartyHandler::kick(const Being *const being) const { if (being) { diff --git a/src/net/eathena/partyhandler.h b/src/net/eathena/partyhandler.h index d24c46683..0c69f5da9 100644 --- a/src/net/eathena/partyhandler.h +++ b/src/net/eathena/partyhandler.h @@ -44,7 +44,7 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler void create(const std::string &name) const override final; - void invite(Being *const being) const override final; + void invite(const Being *const being) const override final; void invite(const std::string &name) const override final; @@ -53,7 +53,7 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler void leave() const override final; - void kick(Being *const being) const override final; + void kick(const Being *const being) const override final; void kick(const std::string &name) const override final; diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 6e832aeda..caad082ae 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -90,7 +90,8 @@ class LoginHandler virtual void chooseServer(unsigned int server) const = 0; - virtual void registerAccount(LoginData *const loginData) const = 0; + virtual void registerAccount(const LoginData *const loginData) + const = 0; virtual void unregisterAccount(const std::string &username, const std::string &password) const = 0; diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h index f92c148c4..4a4e8ec82 100644 --- a/src/net/partyhandler.h +++ b/src/net/partyhandler.h @@ -52,7 +52,7 @@ class PartyHandler virtual void join(const int partyId) const = 0; - virtual void invite(Being *const player) const = 0; + virtual void invite(const Being *const player) const = 0; virtual void invite(const std::string &name) const = 0; @@ -61,7 +61,7 @@ class PartyHandler virtual void leave() const = 0; - virtual void kick(Being *const player) const = 0; + virtual void kick(const Being *const player) const = 0; virtual void kick(const std::string &name) const = 0; diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index ba18a9efa..a7088e33b 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -112,7 +112,7 @@ void PartyHandler::create(const std::string &name) const outMsg.writeString(name.substr(0, 23), 24); } -void PartyHandler::invite(Being *const being) const +void PartyHandler::invite(const Being *const being) const { if (being) { @@ -151,7 +151,7 @@ void PartyHandler::leave() const MessageOut outMsg(CMSG_PARTY_LEAVE); } -void PartyHandler::kick(Being *const being) const +void PartyHandler::kick(const Being *const being) const { if (being) { diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h index 1de9c63b7..6a52c3321 100644 --- a/src/net/tmwa/partyhandler.h +++ b/src/net/tmwa/partyhandler.h @@ -44,7 +44,7 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler void create(const std::string &name) const override final; - void invite(Being *const being) const override final; + void invite(const Being *const being) const override final; void invite(const std::string &name) const override final; @@ -53,7 +53,7 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler void leave() const override final; - void kick(Being *const being) const override final; + void kick(const Being *const being) const override final; void kick(const std::string &name) const override final; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 65b6b291a..9a420740b 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -926,8 +926,6 @@ SDL_Surface* MobileOpenGLGraphics::getScreenshot() const unsigned int lineSize = 3 * w; GLubyte *const buf = new GLubyte[lineSize]; - if (!buf) - return nullptr; // Grap the pixel buffer and write it to the SDL surface glGetIntegerv(GL_PACK_ALIGNMENT, &pack); diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index c3ba82fdd..1dad94a09 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -133,13 +133,14 @@ void AtlasManager::loadImages(const StringVect &files, void AtlasManager::simpleSort(const std::string &restrict name, std::vector &restrict atlases, - std::vector &restrict images, int size) + const std::vector &restrict images, + int size) { int x = 0; int y = 0; int tempHeight = 0; TextureAtlas *atlas = new TextureAtlas(); - std::vector::iterator it = images.begin(); + std::vector::const_iterator it = images.begin(); const std::vector::const_iterator it_end = images.end(); for (it = images.begin(); it != it_end; ++ it) { @@ -297,10 +298,10 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas) } } -void AtlasManager::injectToResources(AtlasResource *const resource) +void AtlasManager::injectToResources(const AtlasResource *const resource) { ResourceManager *const resman = ResourceManager::getInstance(); - FOR_EACH (std::vector::iterator, it, resource->atlases) + FOR_EACH (std::vector::const_iterator, it, resource->atlases) { // add each atlas image to resources TextureAtlas *const atlas = *it; diff --git a/src/resources/atlasmanager.h b/src/resources/atlasmanager.h index 309bf11cb..58f43d251 100644 --- a/src/resources/atlasmanager.h +++ b/src/resources/atlasmanager.h @@ -104,7 +104,7 @@ class AtlasManager final const StringVect &files) A_WARN_UNUSED; - static void injectToResources(AtlasResource *const resource); + static void injectToResources(const AtlasResource *const resource); static void moveToDeleted(AtlasResource *const resource); @@ -114,7 +114,8 @@ class AtlasManager final static void simpleSort(const std::string &restrict name, std::vector &restrict atlases, - std::vector &restrict images, int size); + const std::vector &restrict images, + int size); static SDL_Surface *createSDLAtlas(TextureAtlas *const atlas) A_WARN_UNUSED; diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index ec219886e..e4c3e6f73 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -277,7 +277,7 @@ void MapReader::unloadTempLayers() mKnownDocs.clear(); } -static void loadReplaceLayer(LayerInfoIterator &it, Map *const map) +static void loadReplaceLayer(const LayerInfoIterator &it, Map *const map) { MapReader::readLayer((*it).second, map); } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index a65fc508c..876d7b751 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -1099,7 +1099,7 @@ void ResourceManager::clearScheduled() struct RescaledLoader { ResourceManager *manager; - Image *image; + const Image *image; int width; int height; static Resource *load(const void *const v) @@ -1118,7 +1118,7 @@ struct RescaledLoader } }; -Image *ResourceManager::getRescaled(Image *const image, +Image *ResourceManager::getRescaled(const Image *const image, const int width, const int height) { if (!image) diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 2398cf212..954ee3551 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -278,7 +278,7 @@ class ResourceManager final const std::string &restrict name, const std::string &restrict text); - Image *getRescaled(Image *const image, + Image *getRescaled(const Image *const image, const int width, const int height) A_WARN_UNUSED; /** diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index cd4f0f2fd..0db577a48 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -193,7 +193,7 @@ std::string SpellManager::parseCommand(std::string command, if (target) { name = target->getName(); - name2 = target->getName(); + name2 = name; id = toString(target->getId()); } else diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 09c7ef2ed..26ad10174 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -261,8 +261,7 @@ int TestLauncher::testDye() rw = MPHYSFSRWOPS_openRead( "graphics/sprites/arrow_up.png"); d = new Dye("S:#0000ff,00ff00,5c5cff,ff0000"); - image = d ? surfaceImageHelper->load(rw, *d) - : surfaceImageHelper->load(rw); + image = surfaceImageHelper->load(rw, *d); if (image) { surface = surfaceImageHelper->create32BitSurface( diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp index af05649a9..6a2215d30 100644 --- a/src/utils/langs.cpp +++ b/src/utils/langs.cpp @@ -35,7 +35,7 @@ static const char *getLangName() LangVect getLang() { LangVect langs; - std::string lang = config.getStringValue("lang").c_str(); + std::string lang = config.getStringValue("lang"); if (lang.empty()) { const char *const lng = getLangName(); @@ -60,7 +60,7 @@ LangVect getLang() std::string getLangSimple() { - const std::string lang = config.getStringValue("lang").c_str(); + const std::string lang = config.getStringValue("lang"); if (lang.empty()) { const char *const lng = getLangName(); @@ -77,7 +77,7 @@ std::string getLangSimple() std::string getLangShort() { - std::string lang = config.getStringValue("lang").c_str(); + std::string lang = config.getStringValue("lang"); if (lang.empty()) { const char *const lng = getLangName(); diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index e7b850510..cacb3befd 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -189,7 +189,7 @@ size_t findI(std::string str, std::string subStr) return str.find(subStr); } -size_t findI(std::string text, StringVect &list) +size_t findI(std::string text, const StringVect &list) { toLower(text); FOR_EACH (StringVectCIter, i, list) diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index cd04006ef..4f84dab76 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -138,7 +138,7 @@ bool isWordSeparator(const signed char chr) A_WARN_UNUSED; size_t findI(std::string str, std::string subStr) A_WARN_UNUSED; -size_t findI(std::string text, StringVect &list) A_WARN_UNUSED; +size_t findI(std::string text, const StringVect &list) A_WARN_UNUSED; const std::string encodeStr(unsigned int value, const unsigned int size = 0) A_WARN_UNUSED; -- cgit v1.2.3-70-g09d2