summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buy.cpp13
-rw-r--r--src/gui/char_select.cpp6
-rw-r--r--src/gui/chat.cpp9
-rw-r--r--src/gui/sell.cpp3
-rw-r--r--src/gui/trade.cpp15
5 files changed, 19 insertions, 27 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 63a6e20e..165fa7dc 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -215,9 +215,9 @@ void BuyDialog::action(const std::string &eventId, gcn::Widget *widget)
// of items to be bought ever fails, Bertram removed the assertions, is
// there a better way to ensure this fails in an _obivous_ way in C++?
else if (eventId == "buy" && (mAmountItems > 0 &&
- mAmountItems <= mMaxItems)) {
- MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_BUY_REQUEST);
+ mAmountItems <= mMaxItems))
+ {
+ MessageOut outMsg(CMSG_NPC_BUY_REQUEST);
outMsg.writeShort(8);
outMsg.writeShort(mAmountItems);
outMsg.writeShort(mShopItems->at(selectedItem).id);
@@ -262,9 +262,12 @@ void BuyDialog::mouseClick(int x, int y, int button, int count)
int selectedItem = mItemList->getSelected();
if (selectedItem > -1)
{
+ int itemId = mShopItems->at(selectedItem).id;
+ ItemInfo *itemInfo = itemDb->getItemInfo(itemId);
+
mItemDescLabel->setCaption("Description: " +
- itemDb->getItemInfo(mShopItems->at(selectedItem).id)->getDescription());
+ itemInfo->getDescription());
mItemEffectLabel->setCaption("Effect: " +
- itemDb->getItemInfo(mShopItems->at(selectedItem).id)->getEffect());
+ itemInfo->getEffect());
}
}
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 7e0a1a29..adcbe290 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -203,8 +203,7 @@ void CharSelectDialog::updatePlayerInfo()
void CharSelectDialog::attemptCharDelete()
{
// Request character deletion
- MessageOut msg;
- msg.writeShort(PAMSG_CHAR_DELETE);
+ MessageOut msg(PAMSG_CHAR_DELETE);
// TODO: Send the selected slot
msg.writeByte(0);
Network::send(Network::ACCOUNT, msg);
@@ -214,8 +213,7 @@ void CharSelectDialog::attemptCharDelete()
void CharSelectDialog::attemptCharSelect()
{
// Request character selection
- MessageOut msg;
- msg.writeShort(PAMSG_CHAR_SELECT);
+ MessageOut msg(PAMSG_CHAR_SELECT);
msg.writeByte(mCharInfo->getPos());
Network::send(Network::ACCOUNT, msg);
mCharInfo->lock();
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 04ac3996..9098f9f0 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -249,16 +249,14 @@ ChatWindow::chatSend(const std::string &nick, std::string msg)
// Prepare ordinary message
if (msg.substr(0, 1) != "/") {
- MessageOut outMsg;
- outMsg.writeShort(PGMSG_SAY);
+ MessageOut outMsg(PGMSG_SAY);
outMsg.writeString(msg);
Network::send(Network::GAME, outMsg);
}
else if (msg.substr(0, IS_ANNOUNCE_LENGTH) == IS_ANNOUNCE)
{
msg.erase(0, IS_ANNOUNCE_LENGTH);
- MessageOut outMsg;
- outMsg.writeShort(0x0099);
+ MessageOut outMsg(0x0099);
outMsg.writeShort(msg.length() + 4);
outMsg.writeString(msg, msg.length());
}
@@ -276,8 +274,7 @@ ChatWindow::chatSend(const std::string &nick, std::string msg)
}
else if (msg.substr(0, IS_WHO_LENGTH) == IS_WHO)
{
- MessageOut outMsg;
- outMsg.writeShort(0x00c1);
+ MessageOut outMsg(0x00c1);
}
else
{
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 3aa7c889..33813271 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -212,8 +212,7 @@ void SellDialog::action(const std::string &eventId, gcn::Widget *widget)
// Attempt sell
assert(mAmountItems > 0 && mAmountItems <= mMaxItems);
- MessageOut outMsg;
- outMsg.writeShort(CMSG_NPC_SELL_REQUEST);
+ MessageOut outMsg(CMSG_NPC_SELL_REQUEST);
outMsg.writeShort(8);
outMsg.writeShort(mShopItems->at(selectedItem).index);
outMsg.writeShort(mAmountItems);
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 6b247901..0cd49013 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -214,8 +214,7 @@ void TradeWindow::receivedOk(bool own)
void TradeWindow::tradeItem(Item *item, int quantity)
{
- MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST);
+ MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST);
outMsg.writeShort(item->getInvIndex());
outMsg.writeLong(quantity);
}
@@ -286,8 +285,7 @@ void TradeWindow::action(const std::string &eventId, gcn::Widget *widget)
}
else if (eventId == "cancel")
{
- MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_CANCEL_REQUEST);
+ MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST);
}
else if (eventId == "ok")
{
@@ -297,20 +295,17 @@ void TradeWindow::action(const std::string &eventId, gcn::Widget *widget)
{
mMoneyField->setText(toString(tempInt));
- MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_ITEM_ADD_REQUEST);
+ MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST);
outMsg.writeShort(0);
outMsg.writeLong(tempInt);
} else {
mMoneyField->setText("");
}
mMoneyField->setEnabled(false);
- MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_ADD_COMPLETE);
+ MessageOut outMsg(CMSG_TRADE_ADD_COMPLETE);
}
else if (eventId == "trade")
{
- MessageOut outMsg;
- outMsg.writeShort(CMSG_TRADE_OK);
+ MessageOut outMsg(CMSG_TRADE_OK);
}
}