summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-10-21 01:13:46 +0300
committerAndrei Karas <akaras@inbox.ru>2014-10-21 01:13:46 +0300
commit76e55447563fae6f8d17f2fd90231c81e0b3f927 (patch)
treefa0b2b5daaa50149329f12b7f47b28901d95cc79
parent8d12abe6ff4114a04b8fc9549e8f44683fed9e3d (diff)
downloadmv-76e55447563fae6f8d17f2fd90231c81e0b3f927.tar.gz
mv-76e55447563fae6f8d17f2fd90231c81e0b3f927.tar.bz2
mv-76e55447563fae6f8d17f2fd90231c81e0b3f927.tar.xz
mv-76e55447563fae6f8d17f2fd90231c81e0b3f927.zip
Add to item field identified.
-rw-r--r--src/beingequipbackend.cpp2
-rw-r--r--src/gui/widgets/itemcontainer.cpp2
-rw-r--r--src/gui/windows/itemamountwindow.cpp2
-rw-r--r--src/gui/windows/npcdialog.cpp2
-rw-r--r--src/gui/windows/tradewindow.cpp26
-rw-r--r--src/gui/windows/tradewindow.h16
-rw-r--r--src/inventory.cpp24
-rw-r--r--src/inventory.h19
-rw-r--r--src/item.cpp13
-rw-r--r--src/item.h10
-rw-r--r--src/net/ea/inventoryhandler.cpp10
-rw-r--r--src/net/ea/inventoryitem.h10
-rw-r--r--src/net/eathena/inventoryhandler.cpp12
-rw-r--r--src/net/eathena/itemflags.h2
-rw-r--r--src/net/eathena/tradehandler.cpp2
-rw-r--r--src/net/tmwa/inventoryhandler.cpp90
-rw-r--r--src/net/tmwa/tradehandler.cpp16
-rw-r--r--src/shopitem.cpp4
18 files changed, 185 insertions, 77 deletions
diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp
index f6d50ea64..1b1b3edc6 100644
--- a/src/beingequipbackend.cpp
+++ b/src/beingequipbackend.cpp
@@ -43,7 +43,7 @@ BeingEquipBackend::BeingEquipBackend(Being *const being)
if (id > 0 && idx >= 0 && idx < EQUIPMENT_SIZE)
{
mEquipment[idx] = new Item(id, 1, 0,
- being->mSpriteColorsIds[f], true, true);
+ being->mSpriteColorsIds[f], true, true, true);
}
}
}
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 784fc56db..8f8f886da 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -553,7 +553,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
if (item && !PlayerInfo::isItemProtected(item->getId()))
{
mInventory->addItem(item->getId(), 1, 1, item->getColor(),
- false, false);
+ item->getIdentified(), false, false);
}
return;
}
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index 975cbbd20..31c6c8adc 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -319,7 +319,7 @@ void ItemAmountWindow::action(const ActionEvent &event)
const int id = ItemDB::get(mItemsModal->getElementAt(
mItemDropDown->getSelected())).getId();
- mItem = new Item(id, 10000, 0, 1, false, false);
+ mItem = new Item(id, 10000, 0, 1, true, false, false);
if (mUsage == ShopBuyAdd)
mMax = 10000;
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index c0551299b..ff434c07c 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -468,7 +468,7 @@ void NpcDialog::action(const ActionEvent &event)
if (item)
{
mInventory->addItem(item->getId(), 1, 1, item->getColor(),
- false, false);
+ item->getIdentified(), false, false);
}
}
}
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index 1f4325413..34164758c 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -194,26 +194,38 @@ void TradeWindow::addItem(const int id,
const bool own,
const int quantity,
const uint8_t refine,
- const unsigned char color) const
+ const unsigned char color,
+ const bool identified) const
{
if (own)
- mMyInventory->addItem(id, quantity, refine, color, false, false);
+ {
+ mMyInventory->addItem(id, quantity, refine, color,
+ identified, false, false);
+ }
else
- mPartnerInventory->addItem(id, quantity, refine, color, false, false);
+ {
+ mPartnerInventory->addItem(id, quantity, refine, color,
+ identified, false, false);
+ }
}
-void TradeWindow::addItem2(const int id, const bool own, const int quantity,
- const uint8_t refine, const unsigned char color,
+void TradeWindow::addItem2(const int id,
+ const bool own,
+ const int quantity,
+ const uint8_t refine,
+ const unsigned char color,
+ const bool identified,
const bool equipment) const
{
if (own)
{
- mMyInventory->addItem(id, quantity, refine, color, equipment, false);
+ mMyInventory->addItem(id, quantity, refine, color,
+ identified, equipment, false);
}
else
{
mPartnerInventory->addItem(id, quantity, refine, color,
- equipment, false);
+ identified, equipment, false);
}
}
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
index 0c01c81cd..ef60b051e 100644
--- a/src/gui/windows/tradewindow.h
+++ b/src/gui/windows/tradewindow.h
@@ -67,8 +67,12 @@ class TradeWindow final : public Window,
/**
* Add an item to the trade window.
*/
- void addItem(const int id, const bool own, const int quantity,
- const uint8_t refine, const unsigned char color) const;
+ void addItem(const int id,
+ const bool own,
+ const int quantity,
+ const uint8_t refine,
+ const unsigned char color,
+ const bool identified) const;
/**
* Reset both item containers
@@ -78,8 +82,12 @@ class TradeWindow final : public Window,
/**
* Add an item to the trade window.
*/
- void addItem2(const int id, const bool own, const int quantity,
- const uint8_t refine, const unsigned char color,
+ void addItem2(const int id,
+ const bool own,
+ const int quantity,
+ const uint8_t refine,
+ const unsigned char color,
+ const bool identified,
const bool equipment) const;
/**
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 245927ce9..d407d94f9 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -103,16 +103,26 @@ Item *Inventory::findItem(const int itemId, const unsigned char color) const
return nullptr;
}
-void Inventory::addItem(const int id, const int quantity, const uint8_t refine,
- const uint8_t color, const bool equipment,
+void Inventory::addItem(const int id,
+ const int quantity,
+ const uint8_t refine,
+ const uint8_t color,
+ const bool identified,
+ const bool equipment,
const bool equipped)
{
- setItem(getFreeSlot(), id, quantity, refine, color, equipment, equipped);
+ setItem(getFreeSlot(), id, quantity, refine, color,
+ identified, equipment, equipped);
}
-void Inventory::setItem(const int index, const int id, const int quantity,
- const uint8_t refine, const unsigned char color,
- const bool equipment, const bool equipped)
+void Inventory::setItem(const int index,
+ const int id,
+ const int quantity,
+ const uint8_t refine,
+ const unsigned char color,
+ const bool identified,
+ const bool equipment,
+ const bool equipped)
{
if (index < 0 || index >= static_cast<int>(mSize))
{
@@ -124,7 +134,7 @@ void Inventory::setItem(const int index, const int id, const int quantity,
if (!item1 && id > 0)
{
Item *const item = new Item(id, quantity, refine, color,
- equipment, equipped);
+ identified, equipment, equipped);
item->setInvIndex(index);
mItems[index] = item;
mUsed++;
diff --git a/src/inventory.h b/src/inventory.h
index 702f6c4dd..6ec889a10 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -87,16 +87,25 @@ class Inventory final
/**
* Adds a new item in a free slot.
*/
- void addItem(const int id, const int quantity, const uint8_t refine,
- const unsigned char color, const bool equipment,
+ void addItem(const int id,
+ const int quantity,
+ const uint8_t refine,
+ const unsigned char color,
+ const bool identified,
+ const bool equipment,
const bool equipped);
/**
* Sets the item at the given position.
*/
- void setItem(const int index, const int id, const int quantity,
- const uint8_t refine, const unsigned char color,
- const bool equipment, const bool equipped);
+ void setItem(const int index,
+ const int id,
+ const int quantity,
+ const uint8_t refine,
+ const unsigned char color,
+ const bool identified,
+ const bool equipment,
+ const bool equipped);
/**
* Remove a item from the inventory.
diff --git a/src/item.cpp b/src/item.cpp
index 8b9253822..da4483874 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -37,8 +37,12 @@
DragDrop dragDrop(nullptr, DRAGDROP_SOURCE_EMPTY);
-Item::Item(const int id, const int quantity, const uint8_t refine,
- const unsigned char color, const bool equipment,
+Item::Item(const int id,
+ const int quantity,
+ const uint8_t refine,
+ const unsigned char color,
+ const bool identified,
+ const bool equipment,
const bool equipped) :
mId(0),
mColor(0),
@@ -50,7 +54,10 @@ Item::Item(const int id, const int quantity, const uint8_t refine,
mInvIndex(0),
mEquipment(equipment),
mEquipped(equipped),
- mInEquipment(false)
+ mInEquipment(false),
+ mIdentified(identified),
+ mDamaged(false),
+ mFavorite(false)
{
setId(id, color);
}
diff --git a/src/item.h b/src/item.h
index be6820d2a..fbc6abac6 100644
--- a/src/item.h
+++ b/src/item.h
@@ -44,6 +44,7 @@ class Item notfinal
const int quantity,
const uint8_t refine,
const uint8_t color,
+ const bool identified,
const bool equipment,
const bool equipped);
@@ -168,6 +169,12 @@ class Item notfinal
const std::string &getDescription() const A_WARN_UNUSED
{ return mDescription; }
+ void setIdentified(const bool b)
+ { mIdentified = b; }
+
+ bool getIdentified() const A_WARN_UNUSED
+ { return mIdentified; }
+
int mId; /**< Item type id. */
unsigned char mColor;
int mQuantity; /**< Number of items. */
@@ -181,6 +188,9 @@ class Item notfinal
bool mEquipment; /**< Item is equipment. */
bool mEquipped; /**< Item is equipped. */
bool mInEquipment; /**< Item is in equipment */
+ bool mIdentified;
+ bool mDamaged;
+ bool mFavorite;
};
#endif // ITEM_H
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index dbfcf2b98..c38871797 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -278,8 +278,14 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg)
FOR_EACH (Ea::InventoryItems::const_iterator, it, mInventoryItems)
{
- mStorage->setItem((*it).slot, (*it).id, (*it).quantity,
- (*it).refine, (*it).color, (*it).equip, false);
+ mStorage->setItem((*it).slot,
+ (*it).id,
+ (*it).quantity,
+ (*it).refine,
+ (*it).color,
+ (*it).identified,
+ (*it).equip,
+ false);
}
mInventoryItems.clear();
diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h
index 0f1e372ee..20ea399d4 100644
--- a/src/net/ea/inventoryitem.h
+++ b/src/net/ea/inventoryitem.h
@@ -45,16 +45,22 @@ class InventoryItem final
int quantity;
uint8_t refine;
unsigned char color;
+ bool identified;
bool equip;
- InventoryItem(const int slot0, const int id0, const int quantity0,
- const uint8_t refine0, const unsigned char color0,
+ InventoryItem(const int slot0,
+ const int id0,
+ const int quantity0,
+ const uint8_t refine0,
+ const unsigned char color0,
+ const bool identified0,
const bool equip0) :
slot(slot0),
id(id0),
quantity(quantity0),
refine(refine0),
color(color0),
+ identified(identified0),
equip(equip0)
{
}
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 1e0ccd072..b016b6a17 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -326,7 +326,7 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
if (inventory)
{
inventory->setItem(index, itemId, 1, refine,
- 1, true, false);
+ 1, flags.bits.isIdentified, true, false);
}
if (equipType)
@@ -422,7 +422,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
amount += item->getQuantity();
inventory->setItem(index, itemId, amount, refine,
- 1, equipType != 0, false);
+ 1, identified != 0, equipType != 0, false);
}
ArrowsListener::distributeEvent();
}
@@ -466,7 +466,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
if (inventory)
{
inventory->setItem(index, itemId, amount,
- 0, 1, false, false);
+ 0, 1, flags.bits.isIdentified, false, false);
}
}
BLOCK_END("InventoryHandler::processPlayerInventory")
@@ -498,7 +498,7 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg)
flags.byte = msg.readUInt8("flags");
mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
- amount, 0, 1, false));
+ amount, 0, 1, flags.bits.isIdentified, false));
}
BLOCK_END("InventoryHandler::processPlayerInventory")
}
@@ -596,7 +596,7 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
flags.byte = msg.readUInt8("flags");
mInventoryItems.push_back(Ea::InventoryItem(index,
- itemId, amount, refine, 1, false));
+ itemId, amount, refine, 1, flags.bits.isIdentified, false));
}
BLOCK_END("InventoryHandler::processPlayerStorageEquip")
}
@@ -627,7 +627,7 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
if (mStorage)
{
mStorage->setItem(index, itemId, amount,
- refine, 1, false, false);
+ refine, 1, identified != 0, false, false);
}
}
BLOCK_END("InventoryHandler::processPlayerStorageAdd")
diff --git a/src/net/eathena/itemflags.h b/src/net/eathena/itemflags.h
index df4a98eaf..c7af6ee95 100644
--- a/src/net/eathena/itemflags.h
+++ b/src/net/eathena/itemflags.h
@@ -33,7 +33,7 @@ namespace EAthena
unsigned char isDamaged : 1;
unsigned char isFavorite : 1;
unsigned char spareBits : 5;
- } __attribute__((packed));
+ } bits;
uint8_t byte;
} __attribute__((packed));
} // namespace EAthena
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index a183b70a6..dffc68057 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -201,7 +201,7 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
else
{
tradeWindow->addItem2(type, false, amount,
- refine, identify, false);
+ refine, 1, identify != 0, false);
}
}
}
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 2620fd1cc..32dc8fdc0 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -266,13 +266,18 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
index, itemId, itemType, identified);
}
- if (!serverFeatures->haveItemColors() && identified > 1)
- identified = 1;
-
if (inventory)
{
- inventory->setItem(index, itemId, 1, refine,
- identified, true, false);
+ if (serverFeatures->haveItemColors())
+ {
+ inventory->setItem(index, itemId, 1, refine,
+ identified, true, true, false);
+ }
+ else
+ {
+ inventory->setItem(index, itemId, 1, refine,
+ 1, identified != 0, true, false);
+ }
}
if (equipType)
@@ -363,11 +368,16 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
if (item && item->getId() == itemId)
amount += item->getQuantity();
- if (!serverFeatures->haveItemColors() && identified > 1)
- identified = 1;
-
- inventory->setItem(index, itemId, amount, refine,
- identified, equipType != 0, false);
+ if (serverFeatures->haveItemColors())
+ {
+ inventory->setItem(index, itemId, amount, refine,
+ identified, true, equipType != 0, false);
+ }
+ else
+ {
+ inventory->setItem(index, itemId, amount, refine,
+ 1, identified != 0, equipType != 0, false);
+ }
}
ArrowsListener::distributeEvent();
}
@@ -413,16 +423,21 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
cards[0], cards[1], cards[2], cards[3]);
}
- if (!serverFeatures->haveItemColors() && identified > 1)
- identified = 1;
-
// Trick because arrows are not considered equipment
const bool isEquipment = arrow & 0x8000;
if (inventory)
{
- inventory->setItem(index, itemId, amount,
- 0, identified, isEquipment, false);
+ if (serverFeatures->haveItemColors())
+ {
+ inventory->setItem(index, itemId, amount,
+ 0, identified, true, isEquipment, false);
+ }
+ else
+ {
+ inventory->setItem(index, itemId, amount,
+ 0, 1, identified != 0, isEquipment, false);
+ }
}
}
BLOCK_END("InventoryHandler::processPlayerInventory")
@@ -456,11 +471,16 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg)
cards[0], cards[1], cards[2], cards[3]);
}
- if (!serverFeatures->haveItemColors() && identified > 1)
- identified = 1;
-
- mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
- amount, 0, identified, false));
+ if (serverFeatures->haveItemColors())
+ {
+ mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
+ amount, 0, identified, true, false));
+ }
+ else
+ {
+ mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
+ amount, 0, 1, identified != 0, false));
+ }
}
BLOCK_END("InventoryHandler::processPlayerInventory")
}
@@ -524,11 +544,16 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
static_cast<unsigned int>(refine));
}
- if (!serverFeatures->haveItemColors() && identified > 1U)
- identified = 1U;
-
- mInventoryItems.push_back(Ea::InventoryItem(index,
- itemId, amount, refine, identified, false));
+ if (serverFeatures->haveItemColors())
+ {
+ mInventoryItems.push_back(Ea::InventoryItem(index,
+ itemId, amount, refine, identified, true, false));
+ }
+ else
+ {
+ mInventoryItems.push_back(Ea::InventoryItem(index,
+ itemId, amount, refine, 1, identified != 0, false));
+ }
}
BLOCK_END("InventoryHandler::processPlayerStorageEquip")
}
@@ -555,11 +580,16 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
{
if (mStorage)
{
- if (!serverFeatures->haveItemColors() && identified > 1)
- identified = 1;
-
- mStorage->setItem(index, itemId, amount,
- refine, identified, false, false);
+ if (serverFeatures->haveItemColors())
+ {
+ mStorage->setItem(index, itemId, amount,
+ refine, identified, true, false, false);
+ }
+ else
+ {
+ mStorage->setItem(index, itemId, amount,
+ refine, 1, identified != 0, false, false);
+ }
}
}
BLOCK_END("InventoryHandler::processPlayerStorageAdd")
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index 12e6b94ab..5598d3781 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -30,6 +30,8 @@
#include "gui/windows/tradewindow.h"
+#include "net/serverfeatures.h"
+
#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
@@ -178,8 +180,16 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
}
else
{
- tradeWindow->addItem2(type, false, amount,
- refine, identify, false);
+ if (serverFeatures->haveItemColors())
+ {
+ tradeWindow->addItem2(type, false, amount,
+ refine, identify, true, false);
+ }
+ else
+ {
+ tradeWindow->addItem2(type, false, amount,
+ refine, 1, identify != 0, false);
+ }
}
}
}
@@ -209,7 +219,7 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg)
{
tradeWindow->addItem2(item->getId(), true,
quantity, item->getRefine(), item->getColor(),
- item->isEquipment());
+ item->getIdentified(), item->isEquipment());
}
item->increaseQuantity(-quantity);
break;
diff --git a/src/shopitem.cpp b/src/shopitem.cpp
index 814b99330..6e01eabf6 100644
--- a/src/shopitem.cpp
+++ b/src/shopitem.cpp
@@ -35,7 +35,7 @@
ShopItem::ShopItem(const int inventoryIndex, const int id,
const unsigned char color,
const int quantity, const int price) :
- Item(id, 0, 0, color, false, false),
+ Item(id, 0, 0, color, true, false, false),
mDisplayName(),
mDuplicates(),
mPrice(price),
@@ -47,7 +47,7 @@ ShopItem::ShopItem(const int inventoryIndex, const int id,
}
ShopItem::ShopItem(const int id, const unsigned char color, const int price) :
- Item(id, 0, 0, color, false, false),
+ Item(id, 0, 0, color, true, false, false),
mDisplayName(),
mDuplicates(),
mPrice(price),