diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-04-21 04:44:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-04-21 20:37:02 +0300 |
commit | 862e8f821789014b6167f37976b80694d6d310e3 (patch) | |
tree | 7c4d77a370f4da3d84a649b0d10e4d0a05725e6a /src/net/eathena | |
parent | 62fa051ace7097e78134d46505070a70c08e128f (diff) | |
download | manaplus-862e8f821789014b6167f37976b80694d6d310e3.tar.gz manaplus-862e8f821789014b6167f37976b80694d6d310e3.tar.bz2 manaplus-862e8f821789014b6167f37976b80694d6d310e3.tar.xz manaplus-862e8f821789014b6167f37976b80694d6d310e3.zip |
Add item options into item and get it from server.
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/inventoryrecv.cpp | 58 | ||||
-rw-r--r-- | src/net/eathena/traderecv.cpp | 11 | ||||
-rw-r--r-- | src/net/eathena/vendingrecv.cpp | 12 |
3 files changed, 62 insertions, 19 deletions
diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index 7887cba7c..b0a79df47 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -54,6 +54,8 @@ #include "resources/iteminfo.h" +#include "resources/item/itemoptionslist.h" + #include "utils/gettext.h" #include "utils/stringutils.h" @@ -156,14 +158,16 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) msg.readInt16("equip type"); if (msg.getVersion() >= 20100629) msg.readInt16("item sprite number"); + ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { - msg.readUInt8("option count"); + options = new ItemOptionsList(msg.readUInt8("option count")); for (int f = 0; f < 5; f ++) { - msg.readInt16("option index"); - msg.readInt16("option value"); + const uint16_t idx = msg.readInt16("option index"); + const uint16_t val = msg.readInt16("option value"); msg.readUInt8("option param"); + options->add(idx, val); } } ItemFlags flags; @@ -185,7 +189,9 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) Equipm_true, Equipped_false); inventory->setCards(index, cards, 4); + inventory->setOptions(index, options); } + delete options; if (equipType) { @@ -230,13 +236,16 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) msg.readInt32("hire expire date"); if (msg.getVersion() >= 20071002) msg.readInt16("bind on equip"); + ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { + options = new ItemOptionsList; for (int f = 0; f < 5; f ++) { - msg.readInt16("option index"); - msg.readInt16("option value"); + const uint16_t idx = msg.readInt16("option index"); + const uint16_t val = msg.readInt16("option value"); msg.readUInt8("option param"); + options->add(idx, val); } } @@ -341,9 +350,11 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) fromBool(equipType, Equipm), Equipped_false); inventory->setCards(index, cards, 4); + inventory->setOptions(index, options); } ArrowsListener::distributeEvent(); } + delete options; BLOCK_END("InventoryRecv::processPlayerInventoryAdd") } @@ -492,6 +503,7 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) itemId, itemType, cards, + nullptr, amount, 0, ItemColorManager::getColorFromCards(&cards[0]), @@ -685,14 +697,16 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) msg.readInt16("bind on equip"); if (msg.getVersion() >= 20100629) msg.readInt16("sprite"); + ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { - msg.readUInt8("option count"); + options = new ItemOptionsList(msg.readUInt8("option count")); for (int f = 0; f < 5; f ++) { - msg.readInt16("option index"); - msg.readInt16("option value"); + const uint16_t idx = msg.readInt16("option index"); + const uint16_t val = msg.readInt16("option value"); msg.readUInt8("option param"); + options->add(idx, val); } } @@ -707,6 +721,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) itemId, itemType, cards, + options, amount, refine, ItemColorManager::getColorFromCards(&cards[0]), @@ -736,13 +751,16 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) int cards[maxCards]; for (int f = 0; f < maxCards; f++) cards[f] = msg.readUInt16("card"); + ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { + options = new ItemOptionsList; for (int f = 0; f < 5; f ++) { - msg.readInt16("option index"); - msg.readInt16("option value"); + const uint16_t idx = msg.readInt16("option index"); + const uint16_t val = msg.readInt16("option value"); msg.readUInt8("option param"); + options->add(idx, val); } } @@ -768,6 +786,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) Equipm_false, Equipped_false); Ea::InventoryRecv::mStorage->setCards(index, cards, 4); + Ea::InventoryRecv::mStorage->setOptions(index, options); } } BLOCK_END("InventoryRecv::processPlayerStorageAdd") @@ -942,13 +961,16 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) int cards[maxCards]; for (int f = 0; f < maxCards; f++) cards[f] = msg.readUInt16("card"); + ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { + options = new ItemOptionsList; for (int f = 0; f < 5; f ++) { - msg.readInt16("option index"); - msg.readInt16("option value"); + const uint16_t idx = msg.readInt16("option index"); + const uint16_t val = msg.readInt16("option value"); msg.readUInt8("option param"); + options->add(idx, val); } } @@ -972,6 +994,7 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) Equipm_false, Equipped_false); inventory->setCards(index, cards, 4); + inventory->setOptions(index, options); } else { @@ -979,6 +1002,7 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) itemId, itemType, cards, + options, amount, refine, ItemColorManager::getColorFromCards(&cards[0]), @@ -1039,14 +1063,16 @@ void InventoryRecv::processPlayerCartEquip(Net::MessageIn &msg) msg.readInt16("bind on equip"); if (msg.getVersion() >= 20100629) msg.readInt16("sprite"); + ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { - msg.readUInt8("option count"); + options = new ItemOptionsList(msg.readUInt8("option count")); for (int f = 0; f < 5; f ++) { - msg.readInt16("option index"); - msg.readInt16("option value"); + const uint16_t idx = msg.readInt16("option index"); + const uint16_t val = msg.readInt16("option value"); msg.readUInt8("option param"); + options->add(idx, val); } } ItemFlags flags; @@ -1059,6 +1085,7 @@ void InventoryRecv::processPlayerCartEquip(Net::MessageIn &msg) itemId, itemType, cards, + options, amount, refine, ItemColorManager::getColorFromCards(&cards[0]), @@ -1122,6 +1149,7 @@ void InventoryRecv::processPlayerCartItems(Net::MessageIn &msg) itemId, itemType, cards, + nullptr, amount, 0, ItemColorManager::getColorFromCards(&cards[0]), diff --git a/src/net/eathena/traderecv.cpp b/src/net/eathena/traderecv.cpp index 03dcf62a6..2dcacc609 100644 --- a/src/net/eathena/traderecv.cpp +++ b/src/net/eathena/traderecv.cpp @@ -38,6 +38,7 @@ #include "resources/inventory/inventory.h" #include "resources/item/item.h" +#include "resources/item/itemoptionslist.h" #include "debug.h" @@ -87,13 +88,16 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) int cards[maxCards]; for (int f = 0; f < maxCards; f++) cards[f] = msg.readUInt16("card"); + ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { + options = new ItemOptionsList; for (int f = 0; f < 5; f ++) { - msg.readInt16("option index"); - msg.readInt16("option value"); + const uint16_t idx = msg.readInt16("option index"); + const uint16_t val = msg.readInt16("option value"); msg.readUInt8("option param"); + options->add(idx, val); } } @@ -108,6 +112,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) tradeWindow->addItem2(type, itemType, cards, + options, 4, false, amount, @@ -119,6 +124,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) Equipm_false); } } + delete options; } void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) @@ -139,6 +145,7 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) tradeWindow->addItem2(item->getId(), item->getType(), item->getCards(), + item->getOptions(), 4, true, mQuantity, diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp index 119e5ffa9..bf0cd20eb 100644 --- a/src/net/eathena/vendingrecv.cpp +++ b/src/net/eathena/vendingrecv.cpp @@ -48,6 +48,7 @@ #include "resources/inventory/inventory.h" +#include "resources/item/itemoptionslist.h" #include "resources/item/shopitem.h" #include "utils/gettext.h" @@ -125,13 +126,16 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) msg.readUInt8("refine"); for (int d = 0; d < maxCards; d ++) cards[d] = msg.readUInt16("card"); + ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { + options = new ItemOptionsList; for (int d = 0; d < 5; d ++) { - msg.readInt16("option index"); - msg.readInt16("option value"); + const uint16_t idx = msg.readInt16("option index"); + const uint16_t val = msg.readInt16("option value"); msg.readUInt8("option param"); + options->add(idx, val); } } @@ -139,7 +143,11 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) ShopItem *const item = mBuyDialog->addItem(itemId, type, color, amount, value); if (item) + { item->setInvIndex(index); + item->setOptions(options); + } + delete options; } mBuyDialog->sort(); } |