summaryrefslogtreecommitdiff
path: root/src/net/inventoryhandler.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-31 21:29:00 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-31 21:29:00 +0000
commit36d28236321b6a2824ad4f394faeabbf79626808 (patch)
tree7d2475acf84852f2a21cc29eecbf7524cd58ff52 /src/net/inventoryhandler.cpp
parentc9f930c759004e179545c3b82992e3f8a12345f2 (diff)
downloadmana-36d28236321b6a2824ad4f394faeabbf79626808.tar.gz
mana-36d28236321b6a2824ad4f394faeabbf79626808.tar.bz2
mana-36d28236321b6a2824ad4f394faeabbf79626808.tar.xz
mana-36d28236321b6a2824ad4f394faeabbf79626808.zip
Removed legacy inventory code. Added display of equipment.
Diffstat (limited to 'src/net/inventoryhandler.cpp')
-rw-r--r--src/net/inventoryhandler.cpp95
1 files changed, 9 insertions, 86 deletions
diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp
index 40febee2..ce01c3dc 100644
--- a/src/net/inventoryhandler.cpp
+++ b/src/net/inventoryhandler.cpp
@@ -28,22 +28,17 @@
#include "messagein.h"
#include "protocol.h"
-#include "../resources/iteminfo.h"
+#include "../equipment.h"
+#include "../inventory.h"
#include "../item.h"
#include "../localplayer.h"
#include "../gui/chat.h"
+#include "../resources/iteminfo.h"
InventoryHandler::InventoryHandler()
{
static const Uint16 _messages[] = {
- /*
- SMSG_PLAYER_INVENTORY,
- SMSG_PLAYER_INVENTORY_ADD,
- SMSG_PLAYER_INVENTORY_REMOVE,
- SMSG_PLAYER_INVENTORY_USE,
- SMSG_ITEM_USE_RESPONSE,
- */
GPMSG_INVENTORY_FULL,
GPMSG_INVENTORY,
0
@@ -64,90 +59,18 @@ void InventoryHandler::handleMessage(MessageIn &msg)
{
int slot = msg.readByte();
int id = msg.readShort();
- if (slot >= 32)
+ if (slot < EQUIPMENT_SIZE)
+ {
+ player_node->mEquipment->setEquipment(slot, id);
+ }
+ else if (slot >= 32 && slot < 32 + INVENTORY_SIZE)
{
- int amount = msg.readByte();
+ int amount = id ? msg.readByte() : 0;
Item *it = player_node->getInvItem(slot - 32);
it->setId(id);
it->setQuantity(amount);
}
};
break;
-
-
-#if 0
- case SMSG_PLAYER_INVENTORY:
- // Only called on map load / warp. First reset all items
- // to not load them twice on map change.
- player_node->clearInventory();
- msg.readShort(); // length
- number = (msg.getLength() - 4) / 18;
-
- for (int loop = 0; loop < number; loop++)
- {
- index = msg.readShort();
- itemId = msg.readShort();
- msg.readByte(); // type
- msg.readByte(); // identify flag
- amount = msg.readShort();
-
- player_node->addInvItem(index, itemId, amount, false);
-
- // Trick because arrows are not considered equipment
- if (itemId == 1199 || itemId == 529)
- {
- player_node->getInvItem(index)->setEquipment(true);
- }
- }
- break;
-
- case SMSG_PLAYER_INVENTORY_ADD:
- index = msg.readShort();
- amount = msg.readShort();
- itemId = msg.readShort();
- msg.readByte(); // identify flag
- msg.readByte(); // attribute
- msg.readByte(); // refine
- equipType = msg.readShort();
- msg.readByte(); // type
-
- if (msg.readByte()> 0) {
- chatWindow->chatLog("Unable to pick up item", BY_SERVER);
- } else {
- const ItemInfo &itemInfo = ItemDB::get(itemId);
- chatWindow->chatLog("You picked up a " +
- itemInfo.getName(), BY_SERVER);
- player_node->addInvItem(index, itemId, amount, equipType != 0);
- }
- break;
-
- case SMSG_PLAYER_INVENTORY_REMOVE:
- index = msg.readShort();
- amount = msg.readShort();
- player_node->getInvItem(index)->increaseQuantity(-amount);
- break;
-
- case SMSG_PLAYER_INVENTORY_USE:
- index = msg.readShort();
- msg.readShort(); // item id
- msg.readLong(); // id
- amount = msg.readShort();
- msg.readByte(); // type
-
- player_node->getInvItem(index)->setQuantity(amount);
- break;
-
- case SMSG_ITEM_USE_RESPONSE:
- index = msg.readShort();
- amount = msg.readShort();
-
- if (msg.readByte() == 0) {
- chatWindow->chatLog("Failed to use item", BY_SERVER);
- } else {
- player_node->getInvItem(index)->setQuantity(amount);
- }
- break;
-#endif
-
}
}