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 | |
parent | 62fa051ace7097e78134d46505070a70c08e128f (diff) | |
download | mv-862e8f821789014b6167f37976b80694d6d310e3.tar.gz mv-862e8f821789014b6167f37976b80694d6d310e3.tar.bz2 mv-862e8f821789014b6167f37976b80694d6d310e3.tar.xz mv-862e8f821789014b6167f37976b80694d6d310e3.zip |
Add item options into item and get it from server.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/inventoryitem.h | 11 | ||||
-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 | ||||
-rw-r--r-- | src/net/tmwa/inventoryrecv.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/traderecv.cpp | 2 |
6 files changed, 77 insertions, 19 deletions
diff --git a/src/net/ea/inventoryitem.h b/src/net/ea/inventoryitem.h index bc5611dfc..da0f63283 100644 --- a/src/net/ea/inventoryitem.h +++ b/src/net/ea/inventoryitem.h @@ -33,6 +33,8 @@ #include "enums/simpletypes/identified.h" #include "enums/simpletypes/itemcolor.h" +#include "resources/item/itemoptionslist.h" + #include <vector> #include "localconsts.h" @@ -50,6 +52,7 @@ class InventoryItem final int id; ItemTypeT type; int cards[maxCards]; + ItemOptionsList *options; int quantity; uint8_t refine; ItemColor color; @@ -62,6 +65,7 @@ class InventoryItem final const int id0, const ItemTypeT type0, const int *const cards0, + ItemOptionsList *options0, const int quantity0, const uint8_t refine0, const ItemColor color0, @@ -72,6 +76,8 @@ class InventoryItem final slot(slot0), id(id0), type(type0), + cards(), + options(ItemOptionsList::copy(options0)), quantity(quantity0), refine(refine0), color(color0), @@ -87,6 +93,11 @@ class InventoryItem final } A_DEFAULT_COPY(InventoryItem) + + ~InventoryItem() + { + delete [] options; + } }; typedef std::vector<InventoryItem> InventoryItems; 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(); } diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp index 9be77c993..974fd40c8 100644 --- a/src/net/tmwa/inventoryrecv.cpp +++ b/src/net/tmwa/inventoryrecv.cpp @@ -362,6 +362,7 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) itemId, itemType, cards, + nullptr, amount, 0, ItemColor_one, @@ -448,6 +449,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) itemId, itemType, cards, + nullptr, amount, refine, ItemColor_one, diff --git a/src/net/tmwa/traderecv.cpp b/src/net/tmwa/traderecv.cpp index a737845fe..a8233ef50 100644 --- a/src/net/tmwa/traderecv.cpp +++ b/src/net/tmwa/traderecv.cpp @@ -79,6 +79,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) tradeWindow->addItem2(type, ItemType::Unknown, cards, + nullptr, 4, false, amount, @@ -118,6 +119,7 @@ void TradeRecv::processTradeItemAddResponse(Net::MessageIn &msg) tradeWindow->addItem2(item->getId(), item->getType(), item->getCards(), + nullptr, 4, true, quantity, |