summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-26 22:20:21 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-26 22:23:41 +0300
commit65411bf4ffa75a8bc143e37a4cfbe65fb14c6f05 (patch)
treec065b66a7c5e47715a269566c8b42d98d298baa6 /src
parentb2736792cec7d15ba4ba80b0eb8da8e8014aa085 (diff)
downloadmanaverse-65411bf4ffa75a8bc143e37a4cfbe65fb14c6f05.tar.gz
manaverse-65411bf4ffa75a8bc143e37a4cfbe65fb14c6f05.tar.bz2
manaverse-65411bf4ffa75a8bc143e37a4cfbe65fb14c6f05.tar.xz
manaverse-65411bf4ffa75a8bc143e37a4cfbe65fb14c6f05.zip
Show attached item in item container in old mail system.
Diffstat (limited to 'src')
-rw-r--r--src/gui/windows/mailviewwindow.cpp1
-rw-r--r--src/net/eathena/mailrecv.cpp60
2 files changed, 48 insertions, 13 deletions
diff --git a/src/gui/windows/mailviewwindow.cpp b/src/gui/windows/mailviewwindow.cpp
index c4c396cec..d8734a21f 100644
--- a/src/gui/windows/mailviewwindow.cpp
+++ b/src/gui/windows/mailviewwindow.cpp
@@ -221,7 +221,6 @@ Inventory *MailViewWindow::getInventory() const
void MailViewWindow::updateAttachButton()
{
if ((mMessage->money != 0 && !mUseMail2) ||
- mMessage->itemId != 0 ||
mInventory->getLastUsedSlot() != -1)
{
mGetAttachButton->setVisible(Visible_true);
diff --git a/src/net/eathena/mailrecv.cpp b/src/net/eathena/mailrecv.cpp
index d8897f38c..1293904ba 100644
--- a/src/net/eathena/mailrecv.cpp
+++ b/src/net/eathena/mailrecv.cpp
@@ -20,6 +20,7 @@
#include "net/eathena/mailrecv.h"
+#include "itemcolormanager.h"
#include "notifymanager.h"
#include "enums/resources/notifytypes.h"
@@ -32,9 +33,12 @@
#include "net/mailhandler.h"
#include "net/messagein.h"
+#include "utils/checkutils.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
+#include "resources/inventory/inventory.h"
+
#include "debug.h"
namespace EAthena
@@ -97,24 +101,56 @@ void MailRecv::processReadMail(Net::MessageIn &msg)
mail->sender = msg.readString(24, "sender name");
msg.readInt32("unused");
mail->money = msg.readInt32("money");
- mail->itemAmount = msg.readInt32("item amount");
- mail->itemId = msg.readInt16("item id");
- mail->itemType = msg.readInt16("item type");
- mail->itemIdentify = (msg.readUInt8("identify") != 0u);
- mail->itemAttribute = msg.readUInt8("attribute");
- mail->itemRefine = msg.readUInt8("refine");
- for (int f = 0; f < maxCards; f ++)
- mail->card[f] = msg.readUInt16("card");
+
+ const int amount = msg.readInt32("item amount");
+ const int itemId = msg.readInt16("item id");
+ const ItemTypeT itemType = static_cast<ItemTypeT>(
+ msg.readInt16("item type"));
+ const uint8_t identify = msg.readUInt8("identify");
+ const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged);
+ const uint8_t refine = msg.readUInt8("refine");
+ int cards[maxCards];
+ for (int d = 0; d < maxCards; d ++)
+ cards[d] = msg.readUInt16("card");
const int msgLen = msg.readUInt8("msg len");
if (msgLen != sz)
logger->log("error: wrong message size");
mail->text = msg.readString(sz, "message");
msg.readUInt8("zero");
mail->strTime = timeToStr(mail->time);
- mailWindow->showMessage(mail, mail->itemId != 0 ? 1 : 0);
- // +++ here need add item into item container
- if (mailViewWindow)
- mailViewWindow->updateItems();
+ if (!mailWindow)
+ {
+ reportAlways("Mail window not created");
+ return;
+ }
+ mailWindow->showMessage(mail, itemId != 0 ? 1 : 0);
+ if (!mailViewWindow)
+ {
+ reportAlways("Mail view window not created");
+ return;
+ }
+
+ Inventory *const inventory = mailViewWindow->getInventory();
+ if (!inventory)
+ {
+ reportAlways("Mail view window missing inventory");
+ return;
+ }
+
+ const int slot = inventory->addItem(itemId,
+ itemType,
+ amount,
+ refine,
+ ItemColorManager::getColorFromCards(&cards[0]),
+ fromBool(identify, Identified),
+ damaged,
+ Favorite_false,
+ Equipm_false,
+ Equipped_false);
+ if (slot != -1)
+ inventory->setCards(slot, cards, 4);
+
+ mailViewWindow->updateItems();
}
void MailRecv::processGetAttachment(Net::MessageIn &msg)