summaryrefslogtreecommitdiff
path: root/src/net
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 /src/net
parent8d12abe6ff4114a04b8fc9549e8f44683fed9e3d (diff)
downloadmv-76e55447563fae6f8d17f2fd90231c81e0b3f927.tar.gz
mv-76e55447563fae6f8d17f2fd90231c81e0b3f927.tar.bz2
mv-76e55447563fae6f8d17f2fd90231c81e0b3f927.tar.xz
mv-76e55447563fae6f8d17f2fd90231c81e0b3f927.zip
Add to item field identified.
Diffstat (limited to 'src/net')
-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
7 files changed, 97 insertions, 45 deletions
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;