summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-21 00:45:24 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-21 00:45:24 +0300
commitcfa5391c1be51ef49380e398a72c813255d6316e (patch)
tree32e9f77ae80e72a6388923dddb90721e661394e5 /src
parent31acb66791e27b6cfa846302156ad2e7a88f5f04 (diff)
downloadmanaplus-cfa5391c1be51ef49380e398a72c813255d6316e.tar.gz
manaplus-cfa5391c1be51ef49380e398a72c813255d6316e.tar.bz2
manaplus-cfa5391c1be51ef49380e398a72c813255d6316e.tar.xz
manaplus-cfa5391c1be51ef49380e398a72c813255d6316e.zip
first part of checks and style fixes.
Diffstat (limited to 'src')
-rw-r--r--src/actorspritemanager.cpp2
-rw-r--r--src/actorspritemanager.h2
-rw-r--r--src/flooritem.cpp2
-rw-r--r--src/flooritem.h2
-rw-r--r--src/gui/botcheckerwindow.cpp64
-rw-r--r--src/gui/botcheckerwindow.h2
-rw-r--r--src/gui/changeemaildialog.cpp32
-rw-r--r--src/gui/changeemaildialog.h2
-rw-r--r--src/gui/npcpostdialog.cpp7
-rw-r--r--src/gui/popupmenu.cpp217
-rw-r--r--src/gui/popupmenu.h44
-rw-r--r--src/gui/setup_input.cpp3
-rw-r--r--src/gui/setup_players.cpp4
-rw-r--r--src/gui/tradewindow.cpp82
-rw-r--r--src/gui/tradewindow.h30
-rw-r--r--src/gui/userpalette.cpp18
-rw-r--r--src/gui/userpalette.h11
-rw-r--r--src/gui/widgets/shoplistbox.cpp3
-rw-r--r--src/net/eathena/playerhandler.cpp2
-rw-r--r--src/net/eathena/playerhandler.h2
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwa/playerhandler.cpp2
-rw-r--r--src/net/tmwa/playerhandler.h2
-rw-r--r--src/resources/resourcemanager.cpp2
24 files changed, 282 insertions, 257 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index d7e542323..617bb17dd 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -1662,7 +1662,7 @@ void ActorSpriteManager::storeAttackList()
serverConfig.setValue("ignorePickupItems", packList(mIgnorePickupItems));
}
-bool ActorSpriteManager::checkForPickup(FloorItem *item)
+bool ActorSpriteManager::checkForPickup(const FloorItem *item)
{
if (mPickupItemsSet.find("") != mPickupItemsSet.end())
{
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index 86bc7d9cd..3c3d61c0e 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -282,7 +282,7 @@ class ActorSpriteManager: public ConfigListener
int getIndexByName(std::string name, std::map<std::string, int> &map);
- bool checkForPickup(FloorItem *item);
+ bool checkForPickup(const FloorItem *item);
protected:
bool validateBeing(Being *aroundBeing, Being* being,
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index 69284c998..557205c17 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -82,7 +82,7 @@ const ItemInfo &FloorItem::getInfo() const
return ItemDB::get(mItemId);
}
-std::string FloorItem::getName()
+std::string FloorItem::getName() const
{
const ItemInfo &info = ItemDB::get(mItemId);
if (serverVersion > 0)
diff --git a/src/flooritem.h b/src/flooritem.h
index 817fa0317..1d1947379 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -66,7 +66,7 @@ class FloorItem : public ActorSprite
*/
const ItemInfo &getInfo() const;
- std::string getName();
+ std::string getName() const;
virtual int getTileX() const
{ return mX; }
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index 7ef349916..7a4aa99e6 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -40,23 +40,21 @@
#include "actorspritemanager.h"
#include "configuration.h"
#include "localplayer.h"
-#include "main.h"
#include "utils/gettext.h"
-#include "utils/stringutils.h"
#include "debug.h"
-#define COLUMNS_NR 5 // name plus listbox
-#define NAME_COLUMN 0
-#define TIME_COLUMN 1
+const int COLUMNS_NR = 5; // name plus listbox
+const int NAME_COLUMN = 0;
+const int TIME_COLUMN = 1;
-#define ROW_HEIGHT 12
+const int ROW_HEIGHT = 12;
// The following column widths really shouldn't be hardcoded but should
// scale with the size of the widget... excep
// that, right now, the widget doesn't exactly scale either.
-#define NAME_COLUMN_WIDTH 185
-#define TIME_COLUMN_WIDTH 70
+const int NAME_COLUMN_WIDTH = 185;
+const int TIME_COLUMN_WIDTH = 70;
#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column)
@@ -64,6 +62,7 @@ class UsersTableModel : public TableModel
{
public:
UsersTableModel() :
+ TableModel(),
mPlayers(0)
{
playersUpdated();
@@ -89,7 +88,7 @@ public:
return ROW_HEIGHT;
}
- virtual int getColumnWidth(int index) const
+ virtual int getColumnWidth(const int index) const
{
if (index == NAME_COLUMN)
return NAME_COLUMN_WIDTH;
@@ -97,7 +96,7 @@ public:
return TIME_COLUMN_WIDTH;
}
- virtual void playersUpdated()
+ void playersUpdated()
{
signalBeforeUpdate();
@@ -110,7 +109,7 @@ public:
for (ActorSprites::const_iterator i = beings.begin(),
i_end = beings.end(); i != i_end; ++i)
{
- Being *being = dynamic_cast<Being*>(*i);
+ Being *const being = dynamic_cast<Being*>(*i);
if (being && being->getType() == Being::PLAYER
&& being != player_node && being->getName() != "")
@@ -120,14 +119,14 @@ public:
}
}
- unsigned int curTime = cur_time;
+ const unsigned int curTime = cur_time;
// set up widgets
for (unsigned int r = 0; r < mPlayers.size(); ++r)
{
if (!mPlayers.at(r))
continue;
- const Being *player = mPlayers.at(r);
+ const Being *const player = mPlayers.at(r);
std::string name = player->getName();
gcn::Widget *widget = new Label(name);
@@ -177,16 +176,16 @@ public:
if (curTime - player->getTestTime() > 2 * 60)
{
- int attack = curTime - (player->getAttackTime()
+ const int attack = curTime - (player->getAttackTime()
? player->getAttackTime()
: player->getTestTime());
- int talk = curTime - (player->getTalkTime()
+ const int talk = curTime - (player->getTalkTime()
? player->getTalkTime()
: player->getTestTime()) - attack;
- int move = curTime - (player->getMoveTime()
+ const int move = curTime - (player->getMoveTime()
? player->getMoveTime()
: player->getTestTime()) - attack;
- int other = curTime - (player->getOtherTime()
+ const int other = curTime - (player->getOtherTime()
? player->getMoveTime()
: player->getOtherTime()) - attack;
@@ -241,12 +240,12 @@ public:
}
- virtual gcn::Widget *getElementAt(int row, int column) const
+ virtual gcn::Widget *getElementAt(const int row, const int column) const
{
return mWidgets[WIDGET_AT(row, column)];
}
- virtual void freeWidgets()
+ void freeWidgets()
{
for (std::vector<gcn::Widget *>::const_iterator it = mWidgets.begin();
it != mWidgets.end(); ++it)
@@ -265,24 +264,29 @@ protected:
BotCheckerWindow::BotCheckerWindow():
Window(_("Bot Checker"), false, nullptr, "botchecker.xml"),
+ ActionListener(),
+ mTableModel(new UsersTableModel()),
+ mTable(new GuiTable(mTableModel)),
+ playersScrollArea(new ScrollArea(mTable, true,
+ "bochecker_background.xml")),
+ mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
+ mPlayerTitleTable(new GuiTable(mPlayerTableTitleModel)),
+ mIncButton(new Button(_("Reset"), "reset", this)),
+ mLastUpdateTime(0),
+ mNeedUpdate(false),
mEnabled(false)
{
- int w = 500;
- int h = 250;
+ const int w = 500;
+ const int h = 250;
setSaveVisible(true);
- mLastUpdateTime = 0;
- mNeedUpdate = false;
- mTableModel = new UsersTableModel();
- mTable = new GuiTable(mTableModel);
mTable->setOpaque(false);
mTable->setLinewiseSelection(true);
mTable->setWrappingEnabled(true);
mTable->setActionEventId("skill");
mTable->addActionListener(this);
- mPlayerTableTitleModel = new StaticTableModel(1, COLUMNS_NR);
mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH);
for (int f = 0; f < 4; f++)
@@ -291,7 +295,6 @@ BotCheckerWindow::BotCheckerWindow():
TIME_COLUMN_WIDTH);
}
- mPlayerTitleTable = new GuiTable(mPlayerTableTitleModel);
mPlayerTitleTable->setHeight(1);
mPlayerTableTitleModel->set(0, 0, new Label(_("Name")));
@@ -307,10 +310,7 @@ BotCheckerWindow::BotCheckerWindow():
setStickyButtonLock(true);
setDefaultSize(w, h, ImageRect::CENTER);
- playersScrollArea = new ScrollArea(mTable,
- true, "bochecker_background.xml");
- mIncButton = new Button(_("Reset"), "reset", this);
playersScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mPlayerTitleTable->setPosition(getPadding(), getPadding());
@@ -348,7 +348,7 @@ void BotCheckerWindow::slowLogic()
{
if (mEnabled && mTableModel)
{
- unsigned int nowTime = cur_time;
+ const unsigned int nowTime = cur_time;
if (nowTime - mLastUpdateTime > 5 && mNeedUpdate)
{
mTableModel->playersUpdated();
@@ -392,7 +392,7 @@ void BotCheckerWindow::reset()
for (ActorSprites::const_iterator i = beings.begin(),
i_end = beings.end(); i != i_end; ++i)
{
- Being *being = dynamic_cast<Being*>(*i);
+ Being *const being = dynamic_cast<Being*>(*i);
if (being && being->getType() == Being::PLAYER
&& being != player_node && being->getName() != "")
diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h
index f2a284733..705ddd73c 100644
--- a/src/gui/botcheckerwindow.h
+++ b/src/gui/botcheckerwindow.h
@@ -76,9 +76,9 @@ class BotCheckerWindow : public Window, public gcn::ActionListener,
void optionChanged(const std::string &name);
private:
+ UsersTableModel *mTableModel;
GuiTable *mTable;
ScrollArea *playersScrollArea;
- UsersTableModel *mTableModel;
StaticTableModel *mPlayerTableTitleModel;
GuiTable *mPlayerTitleTable;
gcn::Button *mIncButton;
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index 47fc27a92..3f208cc8f 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -37,26 +37,27 @@
#include "net/net.h"
#include "utils/gettext.h"
-#include "utils/stringutils.h"
#include <string>
#include <sstream>
#include "debug.h"
-ChangeEmailDialog::ChangeEmailDialog(LoginData *data):
+ChangeEmailDialog::ChangeEmailDialog(LoginData *const data):
Window(_("Change Email Address"), true, nullptr, "changeemail.xml"),
+ ActionListener(),
+ mFirstEmailField(new TextField),
+ mSecondEmailField(new TextField),
+ mChangeEmailButton(new Button(_("Change Email Address"),
+ "change_email", this)),
+ mCancelButton(new Button(_("Cancel"), "cancel", this)),
mWrongDataNoticeListener(new WrongDataNoticeListener),
mLoginData(data)
{
- gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"),
- mLoginData->username.c_str()));
- gcn::Label *newEmailLabel = new Label(_("Type new email address twice:"));
- mFirstEmailField = new TextField;
- mSecondEmailField = new TextField;
- mChangeEmailButton = new Button(_("Change Email Address"),
- "change_email", this);
- mCancelButton = new Button(_("Cancel"), "cancel", this);
+ gcn::Label *const accountLabel = new Label(strprintf(_("Account: %s"),
+ mLoginData->username.c_str()));
+ gcn::Label *const newEmailLabel = new Label(
+ _("Type new email address twice:"));
const int width = 200;
const int height = 130;
@@ -123,8 +124,10 @@ void ChangeEmailDialog::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();
if (newFirstEmail.length() < min)
{
@@ -154,10 +157,9 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
else if (error == 2)
mWrongDataNoticeListener->setTarget(this->mSecondEmailField);
- OkDialog *dlg = new OkDialog(_("Error"),
+ OkDialog *const dlg = new OkDialog(_("Error"),
errorMsg.str(), DIALOG_ERROR);
- if (dlg)
- dlg->addActionListener(mWrongDataNoticeListener);
+ dlg->addActionListener(mWrongDataNoticeListener);
}
else
{
diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h
index cbf8f782f..6077a3d93 100644
--- a/src/gui/changeemaildialog.h
+++ b/src/gui/changeemaildialog.h
@@ -50,7 +50,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener
*
* @see Window::Window
*/
- ChangeEmailDialog(LoginData *data);
+ ChangeEmailDialog(LoginData *const data);
/**
* Destructor.
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index a6b12f833..f1c2cacea 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -40,14 +40,16 @@ NpcPostDialog::DialogList NpcPostDialog::instances;
NpcPostDialog::NpcPostDialog(int npcId):
Window(_("NPC"), false, nullptr, "npcpost.xml"),
- mNpcId(npcId)
+ ActionListener(),
+ mNpcId(npcId),
+ mText(new TextBox),
+ mSender(new TextField)
{
setContentSize(400, 180);
// create text field for receiver
gcn::Label *senderText = new Label(_("To:"));
senderText->setPosition(5, 5);
- mSender = new TextField;
mSender->setPosition(senderText->getWidth() + 5, 5);
mSender->setWidth(65);
@@ -60,7 +62,6 @@ NpcPostDialog::NpcPostDialog(int npcId):
- (cancelButton->getWidth() + 2), sendButton->getY());
// create textfield for letter
- mText = new TextBox;
mText->setHeight(400 - (mSender->getHeight() + sendButton->getHeight()));
mText->setEditable(true);
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 2df651ab1..992ba8e14 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -22,19 +22,14 @@
#include "gui/popupmenu.h"
-#include "actorsprite.h"
#include "actorspritemanager.h"
-#include "being.h"
#include "dropshortcut.h"
#include "guild.h"
#include "guildmanager.h"
-#include "flooritem.h"
#include "graphics.h"
#include "item.h"
#include "itemshortcut.h"
#include "localplayer.h"
-#include "logger.h"
-#include "map.h"
#include "maplayer.h"
#include "party.h"
#include "playerinfo.h"
@@ -58,7 +53,6 @@
#include "gui/windowmenu.h"
#include "gui/widgets/browserbox.h"
-#include "gui/widgets/button.h"
#include "gui/widgets/chattab.h"
#include "gui/widgets/progressbar.h"
#include "gui/widgets/whispertab.h"
@@ -67,18 +61,14 @@
#include "net/beinghandler.h"
#include "net/buysellhandler.h"
#include "net/guildhandler.h"
-#include "net/inventoryhandler.h"
-#include "net/net.h"
#include "net/npchandler.h"
#include "net/partyhandler.h"
#include "gui/shortcutwindow.h"
#include "net/tradehandler.h"
-#include "resources/itemdb.h"
#include "resources/iteminfo.h"
#include "utils/gettext.h"
-#include "utils/stringutils.h"
#include "debug.h"
@@ -95,10 +85,11 @@ PopupMenu::PopupMenu():
mMapItem(nullptr),
mTab(nullptr),
mSpell(nullptr),
+ mWindow(nullptr),
mDialog(nullptr),
mButton(nullptr),
mNick(""),
- mType(Being::UNKNOWN),
+ mType(static_cast<int>(Being::UNKNOWN)),
mX(0),
mY(0)
{
@@ -110,19 +101,19 @@ PopupMenu::PopupMenu():
mRenameListener.setDialog(nullptr);
mPlayerListener.setNick("");
mPlayerListener.setDialog(nullptr);
- mPlayerListener.setType(Being::UNKNOWN);
+ mPlayerListener.setType(static_cast<int>(Being::UNKNOWN));
add(mBrowserBox);
}
-void PopupMenu::showPopup(int x, int y, Being *being)
+void PopupMenu::showPopup(const int x, const int y, const Being *const being)
{
if (!being || !player_node || !actorSpriteManager)
return;
mBeingId = being->getId();
mNick = being->getName();
- mType = being->getType();
+ mType = static_cast<int>(being->getType());
mBrowserBox->clearRows();
mX = x;
mY = y;
@@ -151,8 +142,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
addParty(being->getPartyName());
- Guild *guild1 = being->getGuild();
- Guild *guild2 = player_node->getGuild();
+ const Guild *const guild1 = being->getGuild();
+ const Guild *const guild2 = player_node->getGuild();
if (guild2)
{
if (guild1)
@@ -262,7 +253,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
showPopup(x, y);
}
-void PopupMenu::showPopup(int x, int y, std::vector<ActorSprite*> &beings)
+void PopupMenu::showPopup(const int x, const int y,
+ std::vector<ActorSprite*> &beings)
{
mX = x;
mY = y;
@@ -271,8 +263,8 @@ void PopupMenu::showPopup(int x, int y, std::vector<ActorSprite*> &beings)
for (std::vector<ActorSprite*>::const_iterator it = beings.begin(),
it_end = beings.end(); it != it_end; ++it)
{
- Being *being = dynamic_cast<Being*>(*it);
- ActorSprite *actor = *it;
+ const Being *const being = dynamic_cast<Being*>(*it);
+ const ActorSprite *const actor = *it;
if (being && !being->getName().empty())
{
mBrowserBox->addRow(strprintf("@@player_%u|%s >@@",
@@ -281,7 +273,8 @@ void PopupMenu::showPopup(int x, int y, std::vector<ActorSprite*> &beings)
}
else if (actor->getType() == ActorSprite::FLOOR_ITEM)
{
- FloorItem *floorItem = static_cast<FloorItem*>(actor);
+ const FloorItem *const floorItem
+ = static_cast<const FloorItem*>(actor);
mBrowserBox->addRow(strprintf("@@flooritem_%u|%s >@@",
static_cast<unsigned>(actor->getId()),
floorItem->getName().c_str()));
@@ -292,14 +285,14 @@ void PopupMenu::showPopup(int x, int y, std::vector<ActorSprite*> &beings)
showPopup(x, y);
}
-void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
+void PopupMenu::showPlayerPopup(const int x, const int y, std::string nick)
{
if (nick.empty() || !player_node)
return;
mNick = nick;
mBeingId = 0;
- mType = Being::PLAYER;
+ mType = static_cast<int>(Being::PLAYER);
mX = x;
mY = y;
mBrowserBox->clearRows();
@@ -319,22 +312,23 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
if (player_node->isInParty())
{
- Party *party = player_node->getParty();
+ const Party *const party = player_node->getParty();
if (party)
{
- PartyMember *member = party->getMember(mNick);
+ const PartyMember *const member = party->getMember(mNick);
if (member)
{
mBrowserBox->addRow("kick party", _("Kick from party"));
mBrowserBox->addRow("##3---");
- PartyMember *o = party->getMember(player_node->getName());
+ const PartyMember *const o = party->getMember(
+ player_node->getName());
if (o && member->getMap() == o->getMap())
mBrowserBox->addRow("move", _("Move"));
}
}
}
- Guild *guild2 = player_node->getGuild();
+ const Guild *const guild2 = player_node->getGuild();
if (guild2)
{
if (guild2->getMember(mNick))
@@ -368,7 +362,8 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
showPopup(x, y);
}
-void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
+void PopupMenu::showPopup(const int x, const int y,
+ const FloorItem *const floorItem)
{
if (!floorItem)
return;
@@ -376,7 +371,7 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
mFloorItemId = floorItem->getId();
mX = x;
mY = y;
- mType = Being::FLOOR_ITEM;
+ mType = static_cast<int>(Being::FLOOR_ITEM);
mBrowserBox->clearRows();
std::string name = floorItem->getName();
mNick = name;
@@ -406,7 +401,7 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
showPopup(x, y);
}
-void PopupMenu::showPopup(int x, int y, MapItem *mapItem)
+void PopupMenu::showPopup(const int x, const int y, MapItem *const mapItem)
{
if (!mapItem)
return;
@@ -432,7 +427,8 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem)
showPopup(x, y);
}
-void PopupMenu::showMapPopup(int x, int y, int x2, int y2)
+void PopupMenu::showMapPopup(const int x, const int y,
+ const int x2, const int y2)
{
mX = x2;
mY = y2;
@@ -451,7 +447,7 @@ void PopupMenu::showMapPopup(int x, int y, int x2, int y2)
showPopup(x, y);
}
-void PopupMenu::showOutfitsPopup(int x, int y)
+void PopupMenu::showOutfitsPopup(const int x, const int y)
{
mX = x;
mY = y;
@@ -467,7 +463,8 @@ void PopupMenu::showOutfitsPopup(int x, int y)
showPopup(x, y);
}
-void PopupMenu::showSpellPopup(int x, int y, TextCommand *cmd)
+void PopupMenu::showSpellPopup(const int x, const int y,
+ TextCommand *const cmd)
{
if (!cmd)
return;
@@ -487,7 +484,7 @@ void PopupMenu::showSpellPopup(int x, int y, TextCommand *cmd)
showPopup(x, y);
}
-void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
+void PopupMenu::showChatPopup(const int x, const int y, ChatTab *const tab)
{
if (!tab || !actorSpriteManager || !player_node)
return;
@@ -498,7 +495,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->clearRows();
- if (tab->getType() == ChatTab::TAB_WHISPER)
+ if (tab->getType() == static_cast<int>(ChatTab::TAB_WHISPER))
mBrowserBox->addRow("chat close", _("Close"));
mBrowserBox->addRow("chat clear", _("Clear"));
@@ -518,7 +515,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->addRow("disable away", _("Disable away"));
mBrowserBox->addRow("##3---");
- if (tab->getType() == ChatTab::TAB_PARTY)
+ if (tab->getType() == static_cast<int>(ChatTab::TAB_PARTY))
{
mBrowserBox->addRow("leave party", _("Leave"));
mBrowserBox->addRow("##3---");
@@ -526,19 +523,19 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->addRow("chat clipboard", _("Copy to clipboard"));
mBrowserBox->addRow("##3---");
- if (tab->getType() == ChatTab::TAB_WHISPER)
+ if (tab->getType() == static_cast<int>(ChatTab::TAB_WHISPER))
{
- WhisperTab *wTab = static_cast<WhisperTab*>(tab);
+ const WhisperTab *const wTab = static_cast<WhisperTab*>(tab);
std::string name = wTab->getNick();
- Being* being = actorSpriteManager->findBeingByName(
+ const Being* const being = actorSpriteManager->findBeingByName(
name, Being::PLAYER);
if (being)
{
mBeingId = being->getId();
mNick = being->getName();
- mType = being->getType();
+ mType = static_cast<int>(being->getType());
mBrowserBox->addRow("trade", _("Trade"));
mBrowserBox->addRow("attack", _("Attack"));
@@ -573,8 +570,8 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->addRow("##3---");
}
}
- Guild *guild1 = being->getGuild();
- Guild *guild2 = player_node->getGuild();
+ const Guild *const guild1 = being->getGuild();
+ const Guild *const guild2 = player_node->getGuild();
if (guild2)
{
if (guild1)
@@ -607,17 +604,17 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
else
{
mNick = name;
- mType = Being::PLAYER;
+ mType = static_cast<int>(Being::PLAYER);
addPlayerRelation(name);
mBrowserBox->addRow("##3---");
addFollow();
if (player_node->isInParty())
{
- Party *party = player_node->getParty();
+ const Party *const party = player_node->getParty();
if (party)
{
- PartyMember *m = party->getMember(mNick);
+ const PartyMember *const m = party->getMember(mNick);
if (m)
mBrowserBox->addRow("move", _("Move"));
}
@@ -632,7 +629,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
showPopup(x, y);
}
-void PopupMenu::showChangePos(int x, int y)
+void PopupMenu::showChangePos(const int x, const int y)
{
mBrowserBox->clearRows();
mBrowserBox->addRow(_("Change guild position"));
@@ -642,7 +639,7 @@ void PopupMenu::showChangePos(int x, int y)
mX = x;
mY = y;
- const Guild *guild = player_node->getGuild();
+ const Guild *const guild = player_node->getGuild();
if (guild)
{
PositionsMap map = guild->getPositions();
@@ -663,7 +660,7 @@ void PopupMenu::showChangePos(int x, int y)
mItem = nullptr;
mMapItem = nullptr;
mNick = "";
- mType = Being::UNKNOWN;
+ mType = static_cast<int>(Being::UNKNOWN);
mX = 0;
mY = 0;
setVisible(false);
@@ -799,7 +796,7 @@ void PopupMenu::handleLink(const std::string &link,
{
if (player_node)
{
- const Guild *guild = player_node->getGuild();
+ const Guild *const guild = player_node->getGuild();
if (guild)
{
if (guild->getServerGuild())
@@ -811,7 +808,7 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "nuke" && being)
{
- actorSpriteManager->addBlock(being->getId());
+ actorSpriteManager->addBlock(static_cast<uint32_t>(being->getId()));
actorSpriteManager->destroy(being);
}
// Follow Player action
@@ -830,7 +827,8 @@ void PopupMenu::handleLink(const std::string &link,
{
if (player_node && actorSpriteManager)
{
- FloorItem *item = actorSpriteManager->findItem(mFloorItemId);
+ FloorItem *const item = actorSpriteManager->findItem(
+ mFloorItemId);
if (item)
player_node->pickUp(item);
}
@@ -843,10 +841,10 @@ void PopupMenu::handleLink(const std::string &link,
{
if (mItemId < SPELL_MIN_ID)
{
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (inv)
{
- Item *item = inv->findItem(mItemId, mItemColor);
+ const Item *const item = inv->findItem(mItemId, mItemColor);
if (item)
{
if (item->isEquipment())
@@ -890,7 +888,8 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (mFloorItemId && actorSpriteManager)
{
- FloorItem *item = actorSpriteManager->findItem(mFloorItemId);
+ const FloorItem *const item = actorSpriteManager->findItem(
+ mFloorItemId);
if (item)
{
@@ -927,11 +926,12 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (player_node->isInParty())
{
- Party *party = player_node->getParty();
+ const Party *const party = player_node->getParty();
if (party)
{
- PartyMember *m = party->getMember(mNick);
- PartyMember *o = party->getMember(player_node->getName());
+ const PartyMember *const m = party->getMember(mNick);
+ const PartyMember *const o = party->getMember(
+ player_node->getName());
if (m && o && m->getMap() == o->getMap())
player_node->navigateTo(m->getX(), m->getY());
}
@@ -1070,7 +1070,8 @@ void PopupMenu::handleLink(const std::string &link,
{
if (player_node && player_node->getParty())
{
- PartyMember *member = player_node->getParty()->getMember(mNick);
+ const PartyMember *const member = player_node->
+ getParty()->getMember(mNick);
if (member)
Net::getPartyHandler()->kick(mNick);
}
@@ -1120,16 +1121,18 @@ void PopupMenu::handleLink(const std::string &link,
{
if (viewport)
{
- Map *map = viewport->getCurrentMap();
+ const Map *const map = viewport->getCurrentMap();
if (map)
{
- SpecialLayer *specialLayer = map->getSpecialLayer();
+ SpecialLayer *const specialLayer = map->getSpecialLayer();
if (specialLayer)
{
- bool isHome = (mMapItem->getType() == MapItem::HOME);
- const int x = mMapItem->getX();
- const int y = mMapItem->getY();
- specialLayer->setTile(x, y, MapItem::EMPTY);
+ const bool isHome = (mMapItem->getType()
+ == static_cast<int>(MapItem::HOME));
+ const int x = static_cast<const int>(mMapItem->getX());
+ const int y = static_cast<const int>(mMapItem->getY());
+ specialLayer->setTile(x, y,
+ static_cast<int>(MapItem::EMPTY));
if (socialWindow)
socialWindow->removePortal(x, y);
if (isHome && player_node)
@@ -1169,7 +1172,8 @@ void PopupMenu::handleLink(const std::string &link,
else if (link == "addcomment" && !mNick.empty())
{
// TRANSLATORS: number of chars in string should be near original
- TextDialog *dialog = new TextDialog(_("Player comment "),
+ TextDialog *const dialog = new TextDialog(
+ _("Player comment "),
// TRANSLATORS: number of chars in string should be near original
_("Comment: "));
mPlayerListener.setDialog(dialog);
@@ -1192,7 +1196,7 @@ void PopupMenu::handleLink(const std::string &link,
{
if (player_node)
{
- const Guild *guild = player_node->getGuild();
+ const Guild *const guild = player_node->getGuild();
if (guild)
{
if (guild->getServerGuild())
@@ -1310,7 +1314,7 @@ void PopupMenu::handleLink(const std::string &link,
{
if (actorSpriteManager)
{
- int idx = actorSpriteManager->getAttackMobIndex(mNick);
+ const int idx = actorSpriteManager->getAttackMobIndex(mNick);
if (idx > 0)
{
std::list<std::string> mobs
@@ -1340,7 +1344,8 @@ void PopupMenu::handleLink(const std::string &link,
{
if (actorSpriteManager)
{
- int idx = actorSpriteManager->getPriorityAttackMobIndex(mNick);
+ const int idx = actorSpriteManager->
+ getPriorityAttackMobIndex(mNick);
if (idx > 0)
{
std::list<std::string> mobs
@@ -1370,8 +1375,8 @@ void PopupMenu::handleLink(const std::string &link,
{
if (actorSpriteManager)
{
- int idx = actorSpriteManager->getAttackMobIndex(mNick);
- int size = actorSpriteManager->getAttackMobsSize();
+ const int idx = actorSpriteManager->getAttackMobIndex(mNick);
+ const int size = actorSpriteManager->getAttackMobsSize();
if (idx + 1 < size)
{
std::list<std::string> mobs
@@ -1404,8 +1409,9 @@ void PopupMenu::handleLink(const std::string &link,
{
if (player_node)
{
- int idx = actorSpriteManager->getPriorityAttackMobIndex(mNick);
- int size = actorSpriteManager->getPriorityAttackMobsSize();
+ const int idx = actorSpriteManager
+ ->getPriorityAttackMobIndex(mNick);
+ const int size = actorSpriteManager->getPriorityAttackMobsSize();
if (idx + 1 < size)
{
std::list<std::string> mobs
@@ -1528,8 +1534,8 @@ void PopupMenu::handleLink(const std::string &link,
{
if (player_node)
{
- int num = atoi(link.substr(10).c_str());
- const Guild *guild = player_node->getGuild();
+ const int num = atoi(link.substr(10).c_str());
+ const Guild *const guild = player_node->getGuild();
if (guild)
{
Net::getGuildHandler()->changeMemberPostion(
@@ -1554,10 +1560,10 @@ void PopupMenu::handleLink(const std::string &link,
{
if (actorSpriteManager)
{
- int id = atoi(link.substr(10).c_str());
+ const int id = atoi(link.substr(10).c_str());
if (id)
{
- FloorItem *item = actorSpriteManager->findItem(id);
+ const FloorItem *const item = actorSpriteManager->findItem(id);
if (item)
{
mFloorItemId = item->getId();
@@ -1602,13 +1608,13 @@ void PopupMenu::handleLink(const std::string &link,
mItemColor = 1;
mMapItem = nullptr;
mNick = "";
- mType = Being::UNKNOWN;
+ mType = static_cast<int>(Being::UNKNOWN);
mX = 0;
mY = 0;
}
-void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
- bool isInventory)
+void PopupMenu::showPopup(Window *const parent, const int x, const int y,
+ Item *const item, const bool isInventory)
{
if (!item)
return;
@@ -1622,7 +1628,7 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
mNick = "";
mBrowserBox->clearRows();
- int cnt = item->getQuantity();
+ const int cnt = item->getQuantity();
if (isInventory)
{
@@ -1706,13 +1712,14 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
showPopup(x, y);
}
-void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color)
+void PopupMenu::showItemPopup(const int x, const int y, const int itemId,
+ const unsigned char color)
{
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
- Item *item = inv->findItem(itemId, color);
+ Item *const item = inv->findItem(itemId, color);
if (item)
{
showItemPopup(x, y, item);
@@ -1734,7 +1741,7 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color)
}
}
-void PopupMenu::showItemPopup(int x, int y, Item *item)
+void PopupMenu::showItemPopup(const int x, const int y, Item *const item)
{
mItem = item;
mX = x;
@@ -1797,7 +1804,7 @@ void PopupMenu::showItemPopup(int x, int y, Item *item)
showPopup(x, y);
}
-void PopupMenu::showDropPopup(int x, int y, Item *item)
+void PopupMenu::showDropPopup(const int x, const int y, Item *const item)
{
mItem = item;
mX = x;
@@ -1853,7 +1860,7 @@ void PopupMenu::showDropPopup(int x, int y, Item *item)
showPopup(x, y);
}
-void PopupMenu::showPopup(int x, int y, Button *button)
+void PopupMenu::showPopup(const int x, const int y, Button *const button)
{
if (!button || !windowMenu)
return;
@@ -1867,7 +1874,7 @@ void PopupMenu::showPopup(int x, int y, Button *button)
for (std::vector <gcn::Button*>::const_iterator it = names.begin(),
it_end = names.end(); it != it_end; ++ it)
{
- Button *btn = dynamic_cast<Button*>(*it);
+ const Button *const btn = dynamic_cast<Button*>(*it);
if (!btn || btn->getActionEventId() == "SET")
continue;
@@ -1890,7 +1897,7 @@ void PopupMenu::showPopup(int x, int y, Button *button)
showPopup(x, y);
}
-void PopupMenu::showPopup(int x, int y, ProgressBar *b)
+void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b)
{
if (!b || !miniStatusWindow)
return;
@@ -1904,7 +1911,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
for (std::vector <ProgressBar*>::const_iterator it = bars.begin(),
it_end = bars.end(); it != it_end; ++it)
{
- ProgressBar *bar = *it;
+ ProgressBar *const bar = *it;
if (!bar || bar->getActionEventId() == "status bar")
continue;
@@ -1931,14 +1938,14 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
showPopup(x, y);
}
-void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
- int type)
+void PopupMenu::showAttackMonsterPopup(const int x, const int y,
+ std::string name, const int type)
{
if (!player_node || !actorSpriteManager)
return;
mNick = name;
- mType = Being::MONSTER;
+ mType = static_cast<int>(Being::MONSTER);
mX = x;
mY = y;
@@ -1952,8 +1959,8 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
{
case MapItem::ATTACK:
{
- int idx = actorSpriteManager->getAttackMobIndex(name);
- int size = actorSpriteManager->getAttackMobsSize();
+ const int idx = actorSpriteManager->getAttackMobIndex(name);
+ const int size = actorSpriteManager->getAttackMobsSize();
if (idx > 0)
mBrowserBox->addRow("attack moveup", _("Move up"));
if (idx + 1 < size)
@@ -1962,8 +1969,9 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
}
case MapItem::PRIORITY:
{
- int idx = actorSpriteManager->getPriorityAttackMobIndex(name);
- int size = actorSpriteManager->getPriorityAttackMobsSize();
+ const int idx = actorSpriteManager->
+ getPriorityAttackMobIndex(name);
+ const int size = actorSpriteManager->getPriorityAttackMobsSize();
if (idx > 0)
mBrowserBox->addRow("priority moveup", _("Move up"));
if (idx + 1 < size)
@@ -1983,13 +1991,13 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
showPopup(x, y);
}
-void PopupMenu::showPickupItemPopup(int x, int y, std::string name)
+void PopupMenu::showPickupItemPopup(const int x, const int y, std::string name)
{
if (!player_node || !actorSpriteManager)
return;
mNick = name;
- mType = Being::FLOOR_ITEM;
+ mType = static_cast<int>(Being::FLOOR_ITEM);
mX = x;
mY = y;
@@ -2007,7 +2015,8 @@ void PopupMenu::showPickupItemPopup(int x, int y, std::string name)
showPopup(x, y);
}
-void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item)
+void PopupMenu::showUndressPopup(const int x, const int y,
+ const Being *const being, Item *const item)
{
if (!being || !item)
return;
@@ -2107,7 +2116,7 @@ void PopupMenu::addFollow()
mBrowserBox->addRow("imitation", _("Imitation"));
}
-void PopupMenu::addBuySell(const Being *being)
+void PopupMenu::addBuySell(const Being *const being)
{
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
@@ -2177,6 +2186,7 @@ void PopupMenu::addPickupFilter(const std::string &name)
}
RenameListener::RenameListener() :
+ ActionListener(),
mMapItem(nullptr),
mDialog(nullptr)
{
@@ -2186,11 +2196,11 @@ void RenameListener::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok" && mMapItem && viewport && mDialog)
{
- Map *map = viewport->getMap();
+ Map *const map = viewport->getMap();
if (!map)
return;
- SpecialLayer *sl = map->getSpecialLayer();
+ SpecialLayer *const sl = map->getSpecialLayer();
MapItem *item = nullptr;
if (sl)
{
@@ -2214,9 +2224,10 @@ void RenameListener::action(const gcn::ActionEvent &event)
}
PlayerListener::PlayerListener() :
+ ActionListener(),
mNick(""),
mDialog(nullptr),
- mType(Being::UNKNOWN)
+ mType(static_cast<int>(Being::UNKNOWN))
{
}
@@ -2225,7 +2236,7 @@ void PlayerListener::action(const gcn::ActionEvent &event)
if (event.getId() == "ok" && !mNick.empty() && mDialog)
{
std::string comment = mDialog->getText();
- Being* being = actorSpriteManager->findBeingByName(
+ Being *const being = actorSpriteManager->findBeingByName(
mNick, static_cast<ActorSprite::Type>(mType));
if (being)
being->setComment(comment);
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index 094d3ae44..550fa28b0 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -99,59 +99,65 @@ class PopupMenu : public Popup, public LinkHandler
/**
* Shows the being related popup menu at the specified mouse coords.
*/
- void showPopup(int x, int y, Being *being);
+ void showPopup(const int x, const int y, const Being *const being);
/**
* Shows the beings related popup menu at the specified mouse coords.
*/
- void showPopup(int x, int y, std::vector<ActorSprite*> &beings);
+ void showPopup(const int x, const int y,
+ std::vector<ActorSprite*> &beings);
- void showPlayerPopup(int x, int y, std::string nick);
+ void showPlayerPopup(const int x, const int y, std::string nick);
/**
* Shows the floor item related popup menu at the specified
* mouse coords.
*/
- void showPopup(int x, int y, FloorItem *floorItem);
+ void showPopup(const int x, const int y,
+ const FloorItem *const floorItem);
/**
* Shows the related popup menu when right click on the inventory
* at the specified mouse coordinates.
*/
- void showPopup(Window *parent, int x, int y, Item *item,
- bool isInventory);
+ void showPopup(Window *const parent, const int x, const int y,
+ Item *const item, const bool isInventory);
- void showPopup(int x, int y, Button *button);
+ void showPopup(const int x, const int y, Button *const button);
- void showPopup(int x, int y, ProgressBar *bar);
+ void showPopup(const int x, const int y, const ProgressBar *const bar);
- void showPopup(int x, int y, MapItem *mapItem);
+ void showPopup(const int x, const int y, MapItem *const mapItem);
- void showItemPopup(int x, int y, Item *item);
+ void showItemPopup(const int x, const int y, Item *const item);
- void showItemPopup(int x, int y, int itemId, unsigned char color);
+ void showItemPopup(const int x, const int y, const int itemId,
+ const unsigned char color);
- void showDropPopup(int x, int y, Item *item);
+ void showDropPopup(const int x, const int y, Item *const item);
- void showOutfitsPopup(int x, int y);
+ void showOutfitsPopup(const int x, const int y);
- void showSpellPopup(int x, int y, TextCommand *cmd);
+ void showSpellPopup(const int x, const int y, TextCommand *const cmd);
void showAttackMonsterPopup(int x, int y, std::string name, int type);
void showPickupItemPopup(int x, int y, std::string name);
- void showUndressPopup(int x, int y, Being *being, Item *item);
+ void showUndressPopup(const int x, const int y,
+ const Being *const being,
+ Item *const item);
- void showMapPopup(int x, int y, int x2, int y2);
+ void showMapPopup(const int x, const int y,
+ const int x2, const int y2);
/**
* Shows the related popup menu when right click on the chat
* at the specified mouse coordinates.
*/
- void showChatPopup(int x, int y, ChatTab *tab);
+ void showChatPopup(const int x, const int y, ChatTab *const tab);
- void showChangePos(int x, int y);
+ void showChangePos(const int x, const int y);
/**
* Handles link action.
@@ -164,7 +170,7 @@ class PopupMenu : public Popup, public LinkHandler
void addFollow();
- void addBuySell(const Being *being);
+ void addBuySell(const Being *const being);
void addParty(const std::string &partyName);
diff --git a/src/gui/setup_input.cpp b/src/gui/setup_input.cpp
index fdc727e02..7d7c1842b 100644
--- a/src/gui/setup_input.cpp
+++ b/src/gui/setup_input.cpp
@@ -37,9 +37,6 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabstrip.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
#include <guichan/listmodel.hpp>
#include <SDL_keyboard.h>
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 0f5fb9615..fb3bbe87c 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -36,13 +36,13 @@
#include "configuration.h"
#include "localplayer.h"
-#include "logger.h"
#include "utils/gettext.h"
#include "debug.h"
-Setup_Players::Setup_Players()
+Setup_Players::Setup_Players() :
+ SetupTabScroll()
{
setName(_("Players"));
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index 51f3d9e64..b8ac3c433 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -37,7 +37,6 @@
#include "gui/setup.h"
#include "gui/theme.h"
-#include "gui/widgets/button.h"
#include "gui/widgets/chattab.h"
#include "gui/widgets/itemcontainer.h"
#include "gui/widgets/label.h"
@@ -45,12 +44,9 @@
#include "gui/widgets/textfield.h"
#include "gui/widgets/layout.h"
-#include "net/inventoryhandler.h"
-#include "net/net.h"
#include "net/tradehandler.h"
#include "utils/gettext.h"
-#include "utils/stringutils.h"
#include <guichan/font.hpp>
@@ -65,8 +61,17 @@
TradeWindow::TradeWindow():
Window(_("Trade: You"), false, nullptr, "trade.xml"),
+ ActionListener(),
+ SelectionListener(),
mMyInventory(new Inventory(Inventory::TRADE)),
mPartnerInventory(new Inventory(Inventory::TRADE)),
+ mMyItemContainer(new ItemContainer(mMyInventory.get())),
+ mPartnerItemContainer(new ItemContainer(mPartnerInventory.get())),
+ mMoneyLabel(new Label(strprintf(_("You get %s"), ""))),
+ mAddButton(new Button(_("Add"), "add", this)),
+ mOkButton(new Button("", "", this)), // Will be filled in later
+ mMoneyChangeButton(new Button(_("Change"), "money", this)),
+ mMoneyField(new TextField),
mStatus(PROPOSING),
mAutoAddItem(nullptr),
mAutoAddToNick(""),
@@ -87,10 +92,7 @@ TradeWindow::TradeWindow():
if (setupWindow)
setupWindow->registerWindowForReset(this);
- mAddButton = new Button(_("Add"), "add", this);
- mOkButton = new Button("", "", this); // Will be filled in later
-
- gcn::Font *fnt = mOkButton->getFont();
+ const gcn::Font *const fnt = mOkButton->getFont();
int width = std::max(fnt->getWidth(CAPTION_PROPOSE),
fnt->getWidth(CAPTION_CONFIRMED));
width = std::max(width, fnt->getWidth(CAPTION_ACCEPT));
@@ -98,33 +100,28 @@ TradeWindow::TradeWindow():
mOkButton->setWidth(8 + width);
- mMyItemContainer = new ItemContainer(mMyInventory.get());
mMyItemContainer->addSelectionListener(this);
- ScrollArea *myScroll = new ScrollArea(mMyItemContainer,
+ ScrollArea *const myScroll = new ScrollArea(mMyItemContainer,
true, "trade_background.xml");
myScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mPartnerItemContainer = new ItemContainer(mPartnerInventory.get());
mPartnerItemContainer->addSelectionListener(this);
- ScrollArea *partnerScroll = new ScrollArea(mPartnerItemContainer,
+ ScrollArea *const partnerScroll = new ScrollArea(mPartnerItemContainer,
true, "trade_background.xml");
partnerScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mMoneyLabel = new Label(strprintf(_("You get %s"), ""));
- gcn::Label *mMoneyLabel2 = new Label(_("You give:"));
+ gcn::Label *const moneyLabel2 = new Label(_("You give:"));
- mMoneyField = new TextField;
mMoneyField->setWidth(40);
- mMoneyChangeButton = new Button(_("Change"), "money", this);
place(1, 0, mMoneyLabel);
place(0, 1, myScroll).setPadding(3);
place(1, 1, partnerScroll).setPadding(3);
ContainerPlacer placer;
placer = getPlacer(0, 0);
- placer(0, 0, mMoneyLabel2);
+ placer(0, 0, moneyLabel2);
placer(1, 0, mMoneyField, 2);
placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
placer = getPlacer(0, 2);
@@ -146,7 +143,7 @@ TradeWindow::~TradeWindow()
{
}
-void TradeWindow::setMoney(int amount)
+void TradeWindow::setMoney(const int amount)
{
if (amount < 0 || amount < mGotMaxMoney)
{
@@ -158,12 +155,13 @@ void TradeWindow::setMoney(int amount)
else
{
mMoneyLabel->setForegroundColor(Theme::getThemeColor(
- Theme::WARNING));
+ static_cast<int>(Theme::WARNING)));
}
}
else
{
- mMoneyLabel->setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mMoneyLabel->setForegroundColor(Theme::getThemeColor(
+ static_cast<int>(Theme::TEXT)));
mGotMaxMoney = amount;
}
@@ -173,8 +171,8 @@ void TradeWindow::setMoney(int amount)
mMoneyLabel->adjustSize();
}
-void TradeWindow::addItem(int id, bool own, int quantity,
- int refine, unsigned char color)
+void TradeWindow::addItem(const int id, const bool own, const int quantity,
+ const int refine, const unsigned char color)
{
if (own)
mMyInventory->addItem(id, quantity, refine, color);
@@ -182,8 +180,9 @@ void TradeWindow::addItem(int id, bool own, int quantity,
mPartnerInventory->addItem(id, quantity, refine, color);
}
-void TradeWindow::addItem2(int id, bool own, int quantity,
- int refine, unsigned char color, bool equipment)
+void TradeWindow::addItem2(const int id, const bool own, const int quantity,
+ const int refine, const unsigned char color,
+ const bool equipment)
{
if (own)
mMyInventory->addItem(id, quantity, refine, color, equipment);
@@ -191,7 +190,8 @@ void TradeWindow::addItem2(int id, bool own, int quantity,
mPartnerInventory->addItem(id, quantity, refine, color, equipment);
}
-void TradeWindow::changeQuantity(int index, bool own, int quantity)
+void TradeWindow::changeQuantity(const int index, const bool own,
+ const int quantity)
{
if (own)
{
@@ -205,7 +205,8 @@ void TradeWindow::changeQuantity(int index, bool own, int quantity)
}
}
-void TradeWindow::increaseQuantity(int index, bool own, int quantity)
+void TradeWindow::increaseQuantity(const int index, const bool own,
+ const int quantity)
{
if (own)
{
@@ -236,7 +237,7 @@ void TradeWindow::reset()
setStatus(PREPARING);
}
-void TradeWindow::receivedOk(bool own)
+void TradeWindow::receivedOk(const bool own)
{
if (own)
mOkMe = true;
@@ -251,7 +252,8 @@ void TradeWindow::receivedOk(bool own)
}
}
-void TradeWindow::tradeItem(Item *item, int quantity, bool check)
+void TradeWindow::tradeItem(Item *const item, const int quantity,
+ const bool check)
{
if (check && !checkItem(item))
return;
@@ -278,7 +280,7 @@ void TradeWindow::valueChanged(const gcn::SelectionEvent &event)
}
}
-void TradeWindow::setStatus(Status s)
+void TradeWindow::setStatus(const Status s)
{
if (s == mStatus)
return;
@@ -314,7 +316,7 @@ void TradeWindow::action(const gcn::ActionEvent &event)
if (!inventoryWindow)
return;
- Item *item = inventoryWindow->getSelectedItem();
+ Item *const item = inventoryWindow->getSelectedItem();
if (event.getId() == "add")
{
@@ -371,7 +373,7 @@ void TradeWindow::action(const gcn::ActionEvent &event)
return;
int v = atoi(mMoneyField->getText().c_str());
- int curMoney = PlayerInfo::getAttribute(PlayerInfo::MONEY);
+ const int curMoney = PlayerInfo::getAttribute(PlayerInfo::MONEY);
if (v > curMoney)
{
if (localChatTab)
@@ -400,17 +402,19 @@ void TradeWindow::clear()
mAutoAddAmount = 0;
mGotMoney = 0;
mGotMaxMoney = 0;
- mMoneyLabel->setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mMoneyLabel->setForegroundColor(Theme::getThemeColor(
+ static_cast<int>(Theme::TEXT)));
}
-void TradeWindow::addAutoItem(std::string nick, Item* item, int amount)
+void TradeWindow::addAutoItem(const std::string nick, Item* const item,
+ const int amount)
{
mAutoAddToNick = nick;
mAutoAddItem = item;
mAutoAddAmount = amount;
}
-void TradeWindow::addAutoMoney(std::string nick, int money)
+void TradeWindow::addAutoMoney(const std::string nick, const int money)
{
mAutoAddToNick = nick;
mAutoMoney = money;
@@ -425,10 +429,10 @@ void TradeWindow::initTrade(std::string nick)
{
if (mAutoAddItem && mAutoAddItem->getQuantity())
{
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (inv)
{
- Item *item = inv->findItem(mAutoAddItem->getId(),
+ Item *const item = inv->findItem(mAutoAddItem->getId(),
mAutoAddItem->getColor());
if (item)
tradeItem(item, mAutoAddItem->getQuantity());
@@ -445,9 +449,9 @@ void TradeWindow::initTrade(std::string nick)
setCaptionFont(gui->getSecureFont());
}
-bool TradeWindow::checkItem(Item *item)
+bool TradeWindow::checkItem(const Item *const item) const
{
- Item *tItem = mMyInventory->findItem(
+ const Item *const tItem = mMyInventory->findItem(
item->getId(), item->getColor());
if (tItem && (tItem->getQuantity() > 1
@@ -463,7 +467,7 @@ bool TradeWindow::checkItem(Item *item)
return true;
}
-bool TradeWindow::isInpupFocused()
+bool TradeWindow::isInpupFocused() const
{
return (mMoneyField && mMoneyField->isFocused());
}
diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h
index 3b6967772..09c918794 100644
--- a/src/gui/tradewindow.h
+++ b/src/gui/tradewindow.h
@@ -65,13 +65,13 @@ class TradeWindow : public Window,
/**
* Displays expected money in the trade window.
*/
- void setMoney(int quantity);
+ void setMoney(const int quantity);
/**
* Add an item to the trade window.
*/
- void addItem(int id, bool own, int quantity,
- int refine, unsigned char color);
+ void addItem(const int id, const bool own, const int quantity,
+ const int refine, const unsigned char color);
/**
* Reset both item containers
@@ -81,13 +81,15 @@ class TradeWindow : public Window,
/**
* Add an item to the trade window.
*/
- void addItem2(int id, bool own, int quantity, int refine,
- unsigned char color, bool equipment);
+ void addItem2(const int id, const bool own, const int quantity,
+ const int refine, const unsigned char color,
+ const bool equipment);
/**
* Change quantity of an item.
*/
- void changeQuantity(int index, bool own, int quantity);
+ void changeQuantity(const int index, const bool own,
+ const int quantity);
/**
* Increase quantity of an item.
@@ -97,12 +99,13 @@ class TradeWindow : public Window,
/**
* Player received ok message from server
*/
- void receivedOk(bool own);
+ void receivedOk(const bool own);
/**
* Send trade packet.
*/
- void tradeItem(Item *item, int quantity, bool check = false);
+ void tradeItem(Item *const item, const int quantity,
+ const bool check = false);
/**
* Updates the labels and makes sure only one item is selected in
@@ -129,18 +132,19 @@ class TradeWindow : public Window,
/**
* Add item what will be added to trade.
*/
- void addAutoItem(std::string nick, Item* item, int amount);
+ void addAutoItem(const std::string nick, Item *const item,
+ const int amount);
- void addAutoMoney(std::string nick, int money);
+ void addAutoMoney(const std::string nick, const int money);
void initTrade(std::string nick);
std::string getAutoTradeNick() const
{ return mAutoAddToNick; }
- bool checkItem(Item *item);
+ bool checkItem(const Item *const item) const;
- bool isInpupFocused();
+ bool isInpupFocused() const;
private:
enum Status
@@ -154,7 +158,7 @@ class TradeWindow : public Window,
/**
* Sets the current status of the trade.
*/
- void setStatus(Status s);
+ void setStatus(const Status s);
typedef const std::auto_ptr<Inventory> InventoryPtr;
InventoryPtr mMyInventory;
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index 5d878a0f0..69c2b7093 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -25,12 +25,10 @@
#include "configuration.h"
#include "client.h"
-#include "logger.h"
#include "gui/gui.h"
#include "utils/gettext.h"
-#include "utils/stringutils.h"
#include <math.h>
@@ -192,7 +190,8 @@ UserPalette::~UserPalette()
}
}
-void UserPalette::setColor(int type, int r, int g, int b)
+void UserPalette::setColor(const int type, const int r,
+ const int g, const int b)
{
gcn::Color &color = mColors[type].color;
color.r = r;
@@ -200,11 +199,9 @@ void UserPalette::setColor(int type, int r, int g, int b)
color.b = b;
}
-void UserPalette::setGradient(int type, GradientType grad)
+void UserPalette::setGradient(const int type, const GradientType grad)
{
- ColorElem *elem = &mColors[type];
- if (!elem)
- return;
+ ColorElem *const elem = &mColors[type];
if (elem->grad != STATIC && grad == STATIC)
{
@@ -234,7 +231,7 @@ std::string UserPalette::getElementAt(int i)
return mColors[i].text;
}
-void UserPalette::commit(bool commitNonStatic)
+void UserPalette::commit(const bool commitNonStatic)
{
for (Colors::iterator i = mColors.begin(), iEnd = mColors.end();
i != iEnd; ++i)
@@ -279,8 +276,9 @@ int UserPalette::getColorTypeAt(int i)
return mColors[i].type;
}
-void UserPalette::addColor(unsigned type, unsigned rgb,
- Palette::GradientType grad, const std::string &text,
+void UserPalette::addColor(const unsigned type, const unsigned rgb,
+ Palette::GradientType grad,
+ const std::string &text,
int delay)
{
const unsigned maxType = sizeof(ColorTypeNames)
diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h
index 3d53cc26c..e6193baf7 100644
--- a/src/gui/userpalette.h
+++ b/src/gui/userpalette.h
@@ -128,14 +128,14 @@ class UserPalette : public Palette, public gcn::ListModel
* @param g green component
* @param b blue component
*/
- void setColor(int type, int r, int g, int b);
+ void setColor(const int type, const int r, const int g, const int b);
/**
* Sets the gradient type for the specified color.
*
* @param grad gradient type to set
*/
- void setGradient(int type, Palette::GradientType grad);
+ void setGradient(const int type, const Palette::GradientType grad);
/**
* Sets the gradient delay for the specified color.
@@ -198,7 +198,7 @@ class UserPalette : public Palette, public gcn::ListModel
* Commit the colors. Commit the non-static color values, if
* commitNonStatic is true. Only needed in the constructor.
*/
- void commit(bool commitNonStatic);
+ void commit(const bool commitNonStatic);
/**
* Prefixes the given string with "Color", lowercases all letters but
@@ -219,8 +219,9 @@ class UserPalette : public Palette, public gcn::ListModel
* @param rgb default color if not found in config
* @param text identifier of color
*/
- void addColor(unsigned type, unsigned rgb, GradientType grad,
- const std::string &text, int delay = GRADIENT_DELAY);
+ void addColor(const unsigned type, const unsigned rgb,
+ GradientType grad, const std::string &text,
+ int delay = GRADIENT_DELAY);
};
extern UserPalette *userPalette;
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 7dcd38a88..45b385255 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -135,7 +135,8 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (needDraw)
{
graphics->setColor(*backgroundColor);
- graphics->fillRectangle(gcn::Rectangle(0, y, getWidth(), mRowHeight));
+ graphics->fillRectangle(gcn::Rectangle(
+ 0, y, getWidth(), mRowHeight));
}
if (mShopItems)
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index 13a6ec018..1054cd877 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -156,7 +156,7 @@ void PlayerHandler::increaseSkill(unsigned short skillId)
outMsg.writeInt16(skillId);
}
-void PlayerHandler::pickUp(FloorItem *floorItem)
+void PlayerHandler::pickUp(const FloorItem *floorItem)
{
if (!floorItem)
return;
diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h
index a6d5be102..c0a04a52e 100644
--- a/src/net/eathena/playerhandler.h
+++ b/src/net/eathena/playerhandler.h
@@ -47,7 +47,7 @@ class PlayerHandler : public MessageHandler, public Ea::PlayerHandler
void increaseAttribute(int attr);
void increaseSkill(unsigned short skillId);
- void pickUp(FloorItem *floorItem);
+ void pickUp(const FloorItem *floorItem);
void setDirection(char direction);
void setDestination(int x, int y, int direction = -1);
void changeAction(Being::Action action);
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index c6a67afb2..8c77c356c 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -48,7 +48,7 @@ class PlayerHandler
virtual void increaseSkill(unsigned short skillId) = 0;
- virtual void pickUp(FloorItem *floorItem) = 0;
+ virtual void pickUp(const FloorItem *floorItem) = 0;
virtual void setDirection(char direction) = 0;
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 92bfaef74..ce0ce4019 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -150,7 +150,7 @@ void PlayerHandler::increaseSkill(unsigned short skillId)
outMsg.writeInt16(skillId);
}
-void PlayerHandler::pickUp(FloorItem *floorItem)
+void PlayerHandler::pickUp(const FloorItem *floorItem)
{
if (!floorItem)
return;
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index 702436d28..e7e99375f 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -47,7 +47,7 @@ class PlayerHandler : public MessageHandler, public Ea::PlayerHandler
void increaseAttribute(int attr);
void increaseSkill(unsigned short skillId);
- void pickUp(FloorItem *floorItem);
+ void pickUp(const FloorItem *floorItem);
void setDirection(char direction);
void setDestination(int x, int y, int direction = -1);
void changeAction(Being::Action action);
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 5b4feb08f..f06a7986d 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -682,7 +682,7 @@ void ResourceManager::deleteInstance()
if (instance)
{
logger->log("clean orphans start");
- while(instance->cleanOrphans(true));
+ while (instance->cleanOrphans(true));
logger->log("clean orphans end");
ResourceIterator iter = instance->mResources.begin();