summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-01 02:55:46 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 01:18:54 +0300
commita15146e08d00f9986edfde7a15a70790b64cc1ce (patch)
tree21dc4ad2911d4ba3fc4ff70b3e16b0ae18674778
parenta1d70b6c12ef1edb2028d573176fc240777f5bcf (diff)
downloadplus-a15146e08d00f9986edfde7a15a70790b64cc1ce.tar.gz
plus-a15146e08d00f9986edfde7a15a70790b64cc1ce.tar.bz2
plus-a15146e08d00f9986edfde7a15a70790b64cc1ce.tar.xz
plus-a15146e08d00f9986edfde7a15a70790b64cc1ce.zip
Move processPlayerEquipment from ea into tmwa and eathena namespace.
-rw-r--r--src/net/ea/inventoryhandler.cpp49
-rw-r--r--src/net/ea/inventoryhandler.h2
-rw-r--r--src/net/eathena/inventoryhandler.cpp48
-rw-r--r--src/net/eathena/inventoryhandler.h3
-rw-r--r--src/net/tmwa/inventoryhandler.cpp52
-rw-r--r--src/net/tmwa/inventoryhandler.h3
6 files changed, 106 insertions, 51 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index c73dc5757..fb651ae25 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -523,55 +523,6 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED)
BLOCK_END("InventoryHandler::processPlayerStorageClose")
}
-void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
-{
- BLOCK_START("InventoryHandler::processPlayerEquipment")
- Inventory *const inventory = localPlayer
- ? PlayerInfo::getInventory() : nullptr;
-
- msg.readInt16(); // length
- Equipment *const equipment = PlayerInfo::getEquipment();
- if (equipment && !equipment->getBackend())
- { // look like SMSG_PLAYER_INVENTORY was not received
- mEquips.clear();
- equipment->setBackend(&mEquips);
- }
- const int number = (msg.getLength() - 4) / 20;
-
- for (int loop = 0; loop < number; loop++)
- {
- const int index = msg.readInt16() - INVENTORY_OFFSET;
- const int itemId = msg.readInt16();
- const uint8_t itemType = msg.readUInt8(); // type
- uint8_t identified = msg.readUInt8(); // identify flag
-
- msg.readInt16(); // equip type
- const int equipType = msg.readInt16();
- msg.readUInt8(); // attribute
- const uint8_t refine = msg.readUInt8();
- msg.skip(8); // card
-
- if (mDebugInventory)
- {
- logger->log("Index: %d, ID: %d, Type: %d, Identified: %d",
- index, itemId, itemType, identified);
- }
-
- if (serverVersion < 1 && identified > 1)
- identified = 1;
-
- if (inventory)
- {
- inventory->setItem(index, itemId, 1, refine,
- identified, true);
- }
-
- if (equipType)
- mEquips.setEquipment(getSlot(equipType), index);
- }
- BLOCK_END("InventoryHandler::processPlayerEquipment")
-}
-
void InventoryHandler::processPlayerEquip(Net::MessageIn &msg)
{
BLOCK_START("InventoryHandler::processPlayerEquip")
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 3fe0ec6bb..b45c4e337 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -100,8 +100,6 @@ class InventoryHandler notfinal : public Net::InventoryHandler
void processPlayerStorageClose(Net::MessageIn &msg);
- void processPlayerEquipment(Net::MessageIn &msg);
-
void processPlayerEquip(Net::MessageIn &msg);
void processPlayerUnEquip(Net::MessageIn &msg);
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 7e10bc69d..3bdedcb8f 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -22,6 +22,8 @@
#include "net/eathena/inventoryhandler.h"
+#include "being/localplayer.h"
+
#include "net/eathena/messageout.h"
#include "net/eathena/protocol.h"
@@ -202,4 +204,50 @@ void InventoryHandler::moveItem2(const int source, const int slot,
}
}
+void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
+{
+ BLOCK_START("InventoryHandler::processPlayerEquipment")
+ Inventory *const inventory = localPlayer
+ ? PlayerInfo::getInventory() : nullptr;
+
+ msg.readInt16(); // length
+ Equipment *const equipment = PlayerInfo::getEquipment();
+ if (equipment && !equipment->getBackend())
+ { // look like SMSG_PLAYER_INVENTORY was not received
+ mEquips.clear();
+ equipment->setBackend(&mEquips);
+ }
+ const int number = (msg.getLength() - 4) / 20;
+
+ for (int loop = 0; loop < number; loop++)
+ {
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ const int itemId = msg.readInt16();
+ const uint8_t itemType = msg.readUInt8(); // type
+ uint8_t identified = msg.readUInt8(); // identify flag
+
+ msg.readInt16(); // equip type
+ const int equipType = msg.readInt16();
+ msg.readUInt8(); // attribute
+ const uint8_t refine = msg.readUInt8();
+ msg.skip(8); // card
+
+ if (mDebugInventory)
+ {
+ logger->log("Index: %d, ID: %d, Type: %d, Identified: %d",
+ index, itemId, itemType, identified);
+ }
+
+ if (inventory)
+ {
+ inventory->setItem(index, itemId, 1, refine,
+ identified, true);
+ }
+
+ if (equipType)
+ mEquips.setEquipment(getSlot(equipType), index);
+ }
+ BLOCK_END("InventoryHandler::processPlayerEquipment")
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h
index 53051a4f9..2b795c68c 100644
--- a/src/net/eathena/inventoryhandler.h
+++ b/src/net/eathena/inventoryhandler.h
@@ -57,6 +57,9 @@ class InventoryHandler final : public MessageHandler,
const int slot,
const int amount,
const int destination) const override final;
+
+ protected:
+ void processPlayerEquipment(Net::MessageIn &msg);
};
} // namespace EAthena
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 8d38d4feb..e3ff4e3a7 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -22,6 +22,8 @@
#include "net/tmwa/inventoryhandler.h"
+#include "being/localplayer.h"
+
#include "net/tmwa/messageout.h"
#include "net/tmwa/protocol.h"
@@ -30,6 +32,7 @@
#include "debug.h"
extern Net::InventoryHandler *inventoryHandler;
+extern int serverVersion;
namespace TmwAthena
{
@@ -204,4 +207,53 @@ void InventoryHandler::moveItem2(const int source, const int slot,
}
}
+void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg)
+{
+ BLOCK_START("InventoryHandler::processPlayerEquipment")
+ Inventory *const inventory = localPlayer
+ ? PlayerInfo::getInventory() : nullptr;
+
+ msg.readInt16(); // length
+ Equipment *const equipment = PlayerInfo::getEquipment();
+ if (equipment && !equipment->getBackend())
+ { // look like SMSG_PLAYER_INVENTORY was not received
+ mEquips.clear();
+ equipment->setBackend(&mEquips);
+ }
+ const int number = (msg.getLength() - 4) / 20;
+
+ for (int loop = 0; loop < number; loop++)
+ {
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ const int itemId = msg.readInt16();
+ const uint8_t itemType = msg.readUInt8(); // type
+ uint8_t identified = msg.readUInt8(); // identify flag
+
+ msg.readInt16(); // equip type
+ const int equipType = msg.readInt16();
+ msg.readUInt8(); // attribute
+ const uint8_t refine = msg.readUInt8();
+ msg.skip(8); // card
+
+ if (mDebugInventory)
+ {
+ logger->log("Index: %d, ID: %d, Type: %d, Identified: %d",
+ index, itemId, itemType, identified);
+ }
+
+ if (serverVersion < 1 && identified > 1)
+ identified = 1;
+
+ if (inventory)
+ {
+ inventory->setItem(index, itemId, 1, refine,
+ identified, true);
+ }
+
+ if (equipType)
+ mEquips.setEquipment(getSlot(equipType), index);
+ }
+ BLOCK_END("InventoryHandler::processPlayerEquipment")
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index d0df79ae0..e575853d8 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -57,6 +57,9 @@ class InventoryHandler final : public MessageHandler,
const int slot,
const int amount,
const int destination) const override final;
+
+ protected:
+ void processPlayerEquipment(Net::MessageIn &msg);
};
} // namespace TmwAthena