summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-10-20 17:53:38 +0300
committerAndrei Karas <akaras@inbox.ru>2014-10-20 18:28:49 +0300
commit2ce675592a1a96cc9960082485797045a921676d (patch)
treef55cdb7c20ccc2a15c2649657caadd0ba0675c6e /src
parent12596b11b89baa167704d8cddd4599c937826062 (diff)
downloadmanaplus-2ce675592a1a96cc9960082485797045a921676d.tar.gz
manaplus-2ce675592a1a96cc9960082485797045a921676d.tar.bz2
manaplus-2ce675592a1a96cc9960082485797045a921676d.tar.xz
manaplus-2ce675592a1a96cc9960082485797045a921676d.zip
eathena: parse item flags.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/net/eathena/inventoryhandler.cpp48
-rw-r--r--src/net/eathena/itemflags.h41
4 files changed, 61 insertions, 30 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c83c60319..684f6afd4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1410,6 +1410,7 @@ SET(SRCS_EATHENA
net/eathena/homunculushandler.h
net/eathena/inventoryhandler.cpp
net/eathena/inventoryhandler.h
+ net/eathena/itemflags.h
net/eathena/itemhandler.cpp
net/eathena/itemhandler.h
net/eathena/loginhandler.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index d3ccb5b36..da4e77bf4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1345,6 +1345,7 @@ manaplus_SOURCES += net/eathena/adminhandler.cpp \
net/eathena/homunculushandler.h \
net/eathena/inventoryhandler.cpp \
net/eathena/inventoryhandler.h \
+ net/eathena/itemflags.h \
net/eathena/itemhandler.cpp \
net/eathena/itemhandler.h \
net/eathena/loginhandler.cpp \
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index b14bfbfb6..cf46a95d8 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -31,6 +31,7 @@
#include "net/serverfeatures.h"
+#include "net/eathena/itemflags.h"
#include "net/eathena/menu.h"
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
@@ -304,15 +305,12 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
equipment->setBackend(&mEquips);
}
const int number = (msg.getLength() - 4) / 31;
- const uint8_t identified = 1;
for (int loop = 0; loop < number; loop++)
{
const int index = msg.readInt16("index") - INVENTORY_OFFSET;
const int itemId = msg.readInt16("item id");
msg.readUInt8("item type");
-// uint8_t identified = msg.readUInt8(); // identify flag
-
msg.readInt32("location");
const int equipType = msg.readInt32("wear state");
const uint8_t refine = static_cast<uint8_t>(msg.readInt8("refine"));
@@ -323,13 +321,12 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
msg.readInt32("hire expire date (?)");
msg.readInt16("equip type");
msg.readInt16("item sprite number");
- msg.readInt8("flags");
-
- // need get actual identify flag
+ ItemFlags flags;
+ flags.byte = msg.readUInt8("flags");
if (inventory)
{
inventory->setItem(index, itemId, 1, refine,
- identified, true);
+ 1, true);
}
if (equipType)
@@ -407,14 +404,14 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
break;
}
if (localPlayer)
- localPlayer->pickedUp(itemInfo, 0, identified, floorId, pickup);
+ localPlayer->pickedUp(itemInfo, 0, 1, floorId, pickup);
}
else
{
if (localPlayer)
{
localPlayer->pickedUp(itemInfo, amount,
- identified, floorId, Pickup::OKAY);
+ 1, floorId, Pickup::OKAY);
}
if (inventory)
@@ -424,11 +421,8 @@ 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);
+ 1, equipType != 0);
}
ArrowsListener::distributeEvent();
}
@@ -453,7 +447,6 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
msg.readInt16("len");
const int number = (msg.getLength() - 4) / 24;
- const uint8_t identified = 1;
for (int loop = 0; loop < number; loop++)
{
@@ -467,16 +460,13 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
msg.readInt16("card2");
msg.readInt16("card3");
msg.readInt32("hire expire date (?)");
- msg.readInt8("flags");
-
- // need get actual identify flag
- // Trick because arrows are not considered equipment
-// const bool isEquipment = arrow & 0x8000;
+ ItemFlags flags;
+ flags.byte = msg.readUInt8("flags");
if (inventory)
{
inventory->setItem(index, itemId, amount,
- 0, identified, false);
+ 0, 1, false);
}
}
BLOCK_END("InventoryHandler::processPlayerInventory")
@@ -491,7 +481,6 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg)
msg.readString(24, "storage name");
const int number = (msg.getLength() - 4) / 23;
- const uint8_t identified = 1;
for (int loop = 0; loop < number; loop++)
{
@@ -505,11 +494,11 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg)
msg.readInt16("card2");
msg.readInt16("card3");
msg.readInt32("hire expire date (?)");
- msg.readInt8("flags");
+ ItemFlags flags;
+ flags.byte = msg.readUInt8("flags");
- // need get actual identify flag
mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
- amount, 0, identified, false));
+ amount, 0, 1, false));
}
BLOCK_END("InventoryHandler::processPlayerInventory")
}
@@ -585,7 +574,6 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
BLOCK_START("InventoryHandler::processPlayerStorageEquip")
msg.readInt16("len");
const int number = (msg.getLength() - 4 - 24) / 31;
- const uint8_t identified = 1;
msg.readString(24, "storage name");
for (int loop = 0; loop < number; loop++)
@@ -604,11 +592,11 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
msg.readInt32("hire expire date");
msg.readInt16("bind on equip");
msg.readInt16("sprite");
- msg.readInt8("flags");
+ ItemFlags flags;
+ flags.byte = msg.readUInt8("flags");
- // need get identified from flags
mInventoryItems.push_back(Ea::InventoryItem(index,
- itemId, amount, refine, identified, false));
+ itemId, amount, refine, 1, false));
}
BLOCK_END("InventoryHandler::processPlayerStorageEquip")
}
@@ -631,7 +619,7 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
if (Item *const item = mStorage->getItem(index))
{
- item->setId(itemId, identified);
+ item->setId(itemId, 1);
item->increaseQuantity(amount);
}
else
@@ -639,7 +627,7 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg)
if (mStorage)
{
mStorage->setItem(index, itemId, amount,
- refine, identified, false);
+ refine, 1, false);
}
}
BLOCK_END("InventoryHandler::processPlayerStorageAdd")
diff --git a/src/net/eathena/itemflags.h b/src/net/eathena/itemflags.h
new file mode 100644
index 000000000..df4a98eaf
--- /dev/null
+++ b/src/net/eathena/itemflags.h
@@ -0,0 +1,41 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_EATHENA_ITEMFLAGS_H
+#define NET_EATHENA_ITEMFLAGS_H
+
+#include "localconsts.h"
+
+namespace EAthena
+{
+ union ItemFlags final
+ {
+ struct bits
+ {
+ unsigned char isIdentified : 1;
+ unsigned char isDamaged : 1;
+ unsigned char isFavorite : 1;
+ unsigned char spareBits : 5;
+ } __attribute__((packed));
+ uint8_t byte;
+ } __attribute__((packed));
+} // namespace EAthena
+
+#endif // NET_EATHENA_ITEMFLAGS_H