diff options
Diffstat (limited to 'src/net/inventoryhandler.cpp')
-rw-r--r-- | src/net/inventoryhandler.cpp | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp index 3742d327..51c71f8d 100644 --- a/src/net/inventoryhandler.cpp +++ b/src/net/inventoryhandler.cpp @@ -57,18 +57,16 @@ void InventoryHandler::handleMessage(MessageIn *msg) // Only called on map load / warp. First reset all items // to not load them twice on map change. player_node->clearInventory(); - msg->readInt16(); // length + msg->readShort(); // length number = (msg->getLength() - 4) / 18; for (int loop = 0; loop < number; loop++) { - index = msg->readInt16(); - itemId = msg->readInt16(); - msg->readInt8(); // type - msg->readInt8(); // identify flag - amount = msg->readInt16(); - msg->skip(2); // unknown - msg->skip(8); // card (4 shorts) + index = msg->readShort(); + itemId = msg->readShort(); + msg->readByte(); // type + msg->readByte(); // identify flag + amount = msg->readShort(); player_node->addInvItem(index, itemId, amount, false); @@ -81,17 +79,16 @@ void InventoryHandler::handleMessage(MessageIn *msg) break; case SMSG_PLAYER_INVENTORY_ADD: - index = msg->readInt16(); - amount = msg->readInt16(); - itemId = msg->readInt16(); - msg->readInt8(); // identify flag - msg->readInt8(); // attribute - msg->readInt8(); // refine - msg->skip(8); // card - equipType = msg->readInt16(); - msg->readInt8(); // type - - if (msg->readInt8()> 0) { + 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 { player_node->addInvItem(index, itemId, amount, equipType != 0); @@ -99,26 +96,26 @@ void InventoryHandler::handleMessage(MessageIn *msg) break; case SMSG_PLAYER_INVENTORY_REMOVE: - index = msg->readInt16(); - amount = msg->readInt16(); + index = msg->readShort(); + amount = msg->readShort(); player_node->getInvItem(index)->increaseQuantity(-amount); break; case SMSG_PLAYER_INVENTORY_USE: - index = msg->readInt16(); - msg->readInt16(); // item id - msg->readInt32(); // id - amount = msg->readInt16(); - msg->readInt8(); // type + 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->readInt16(); - amount = msg->readInt16(); + index = msg->readShort(); + amount = msg->readShort(); - if (msg->readInt8() == 0) { + if (msg->readByte() == 0) { chatWindow->chatLog("Failed to use item", BY_SERVER); } else { player_node->getInvItem(index)->setQuantity(amount); |