summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-03 13:27:08 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 01:18:56 +0300
commit28741b7ba3eea91a80fef6e1b2e57553c67bf6ea (patch)
tree7cfc8d8048763ac6e0da521d11f3349177199ba3
parentcb392d4bf99ff06849f5891a17be59a7e509ff98 (diff)
downloadmanaplus-28741b7ba3eea91a80fef6e1b2e57553c67bf6ea.tar.gz
manaplus-28741b7ba3eea91a80fef6e1b2e57553c67bf6ea.tar.bz2
manaplus-28741b7ba3eea91a80fef6e1b2e57553c67bf6ea.tar.xz
manaplus-28741b7ba3eea91a80fef6e1b2e57553c67bf6ea.zip
Move processPlayerInventory from ea namespace into tmwa and eathena.
-rw-r--r--src/net/ea/inventoryhandler.cpp70
-rw-r--r--src/net/ea/inventoryhandler.h2
-rw-r--r--src/net/eathena/inventoryhandler.cpp70
-rw-r--r--src/net/eathena/inventoryhandler.h2
-rw-r--r--src/net/tmwa/inventoryhandler.cpp70
-rw-r--r--src/net/tmwa/inventoryhandler.h2
6 files changed, 144 insertions, 72 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 0cc84d7ae..61db381ec 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -173,76 +173,6 @@ int InventoryHandler::getSlot(const int eAthenaSlot)
return static_cast<int>(EQUIP_POINTS[position]);
}
-void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryHandler::processPlayerInventory")
- const bool playerInvintory = msg.getId() == SMSG_PLAYER_INVENTORY;
- Inventory *const inventory = localPlayer
- ? PlayerInfo::getInventory() : nullptr;
- if (playerInvintory)
- {
- if (PlayerInfo::getEquipment())
- {
- // Clear inventory - this will be a complete refresh
- mEquips.clear();
- PlayerInfo::getEquipment()->setBackend(&mEquips);
- }
-
- if (inventory)
- inventory->clear();
- }
- else
- {
- mInventoryItems.clear();
- }
-
- msg.readInt16(); // length
- const int number = (msg.getLength() - 4) / 18;
-
- for (int loop = 0; loop < number; loop++)
- {
- int cards[4];
- const int index = msg.readInt16() - (playerInvintory
- ? INVENTORY_OFFSET : STORAGE_OFFSET);
- const int itemId = msg.readInt16();
- const uint8_t itemType = msg.readUInt8();
- uint8_t identified = msg.readUInt8();
- const int amount = msg.readInt16();
- const int arrow = msg.readInt16();
- for (int i = 0; i < 4; i++)
- cards[i] = msg.readInt16();
-
- if (mDebugInventory)
- {
- logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, "
- "Qty: %d, Cards: %d, %d, %d, %d",
- index, itemId, itemType, identified, amount,
- cards[0], cards[1], cards[2], cards[3]);
- }
-
- if (serverVersion < 1 && identified > 1)
- identified = 1;
-
- if (playerInvintory)
- {
- // Trick because arrows are not considered equipment
- const bool isEquipment = arrow & 0x8000;
-
- if (inventory)
- {
- inventory->setItem(index, itemId, amount,
- 0, identified, isEquipment);
- }
- }
- else
- {
- mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
- amount, 0, identified, false));
- }
- }
- BLOCK_END("InventoryHandler::processPlayerInventory")
-}
-
void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg)
{
BLOCK_START("InventoryHandler::processPlayerStorageEquip")
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 7afd688dc..8d5f76464 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -80,8 +80,6 @@ class InventoryHandler notfinal : public Net::InventoryHandler
static int getSlot(const int eAthenaSlot) A_WARN_UNUSED;
- void processPlayerInventory(Net::MessageIn &msg);
-
void processPlayerStorageEquip(Net::MessageIn &msg);
static void processPlayerInventoryRemove(Net::MessageIn &msg);
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 3a9297984..6567eedc2 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -328,4 +328,74 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
BLOCK_END("InventoryHandler::processPlayerInventoryAdd")
}
+void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
+{
+ BLOCK_START("InventoryHandler::processPlayerInventory")
+ const bool playerInvintory = msg.getId() == SMSG_PLAYER_INVENTORY;
+ Inventory *const inventory = localPlayer
+ ? PlayerInfo::getInventory() : nullptr;
+ if (playerInvintory)
+ {
+ if (PlayerInfo::getEquipment())
+ {
+ // Clear inventory - this will be a complete refresh
+ mEquips.clear();
+ PlayerInfo::getEquipment()->setBackend(&mEquips);
+ }
+
+ if (inventory)
+ inventory->clear();
+ }
+ else
+ {
+ mInventoryItems.clear();
+ }
+
+ msg.readInt16(); // length
+ const int number = (msg.getLength() - 4) / 18;
+
+ for (int loop = 0; loop < number; loop++)
+ {
+ int cards[4];
+ const int index = msg.readInt16() - (playerInvintory
+ ? INVENTORY_OFFSET : STORAGE_OFFSET);
+ const int itemId = msg.readInt16();
+ const uint8_t itemType = msg.readUInt8();
+ uint8_t identified = msg.readUInt8();
+ const int amount = msg.readInt16();
+ const int arrow = msg.readInt16();
+ for (int i = 0; i < 4; i++)
+ cards[i] = msg.readInt16();
+
+ if (mDebugInventory)
+ {
+ logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, "
+ "Qty: %d, Cards: %d, %d, %d, %d",
+ index, itemId, itemType, identified, amount,
+ cards[0], cards[1], cards[2], cards[3]);
+ }
+
+ if (serverVersion < 1 && identified > 1)
+ identified = 1;
+
+ if (playerInvintory)
+ {
+ // Trick because arrows are not considered equipment
+ const bool isEquipment = arrow & 0x8000;
+
+ if (inventory)
+ {
+ inventory->setItem(index, itemId, amount,
+ 0, identified, isEquipment);
+ }
+ }
+ else
+ {
+ mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
+ amount, 0, identified, false));
+ }
+ }
+ BLOCK_END("InventoryHandler::processPlayerInventory")
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h
index 1eb7e7d44..00e9a3044 100644
--- a/src/net/eathena/inventoryhandler.h
+++ b/src/net/eathena/inventoryhandler.h
@@ -62,6 +62,8 @@ class InventoryHandler final : public MessageHandler,
void processPlayerEquipment(Net::MessageIn &msg);
void processPlayerInventoryAdd(Net::MessageIn &msg);
+
+ void processPlayerInventory(Net::MessageIn &msg);
};
} // namespace EAthena
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 78aacb523..aa619a9f0 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -326,4 +326,74 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg)
BLOCK_END("InventoryHandler::processPlayerInventoryAdd")
}
+void InventoryHandler::processPlayerInventory(Net::MessageIn &msg)
+{
+ BLOCK_START("InventoryHandler::processPlayerInventory")
+ const bool playerInvintory = msg.getId() == SMSG_PLAYER_INVENTORY;
+ Inventory *const inventory = localPlayer
+ ? PlayerInfo::getInventory() : nullptr;
+ if (playerInvintory)
+ {
+ if (PlayerInfo::getEquipment())
+ {
+ // Clear inventory - this will be a complete refresh
+ mEquips.clear();
+ PlayerInfo::getEquipment()->setBackend(&mEquips);
+ }
+
+ if (inventory)
+ inventory->clear();
+ }
+ else
+ {
+ mInventoryItems.clear();
+ }
+
+ msg.readInt16(); // length
+ const int number = (msg.getLength() - 4) / 18;
+
+ for (int loop = 0; loop < number; loop++)
+ {
+ int cards[4];
+ const int index = msg.readInt16() - (playerInvintory
+ ? INVENTORY_OFFSET : STORAGE_OFFSET);
+ const int itemId = msg.readInt16();
+ const uint8_t itemType = msg.readUInt8();
+ uint8_t identified = msg.readUInt8();
+ const int amount = msg.readInt16();
+ const int arrow = msg.readInt16();
+ for (int i = 0; i < 4; i++)
+ cards[i] = msg.readInt16();
+
+ if (mDebugInventory)
+ {
+ logger->log("Index: %d, ID: %d, Type: %d, Identified: %d, "
+ "Qty: %d, Cards: %d, %d, %d, %d",
+ index, itemId, itemType, identified, amount,
+ cards[0], cards[1], cards[2], cards[3]);
+ }
+
+ if (serverVersion < 1 && identified > 1)
+ identified = 1;
+
+ if (playerInvintory)
+ {
+ // Trick because arrows are not considered equipment
+ const bool isEquipment = arrow & 0x8000;
+
+ if (inventory)
+ {
+ inventory->setItem(index, itemId, amount,
+ 0, identified, isEquipment);
+ }
+ }
+ else
+ {
+ mInventoryItems.push_back(Ea::InventoryItem(index, itemId,
+ amount, 0, identified, false));
+ }
+ }
+ BLOCK_END("InventoryHandler::processPlayerInventory")
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 97d5ec0b3..3ec37c5b5 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -62,6 +62,8 @@ class InventoryHandler final : public MessageHandler,
void processPlayerEquipment(Net::MessageIn &msg);
void processPlayerInventoryAdd(Net::MessageIn &msg);
+
+ void processPlayerInventory(Net::MessageIn &msg);
};
} // namespace TmwAthena