diff options
36 files changed, 220 insertions, 129 deletions
diff --git a/src/net/ea/inventoryrecv.cpp b/src/net/ea/inventoryrecv.cpp index 3bae51555..5dd4075d6 100644 --- a/src/net/ea/inventoryrecv.cpp +++ b/src/net/ea/inventoryrecv.cpp @@ -63,7 +63,7 @@ void InventoryRecv::processPlayerInventoryUse(Net::MessageIn &msg) ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readInt32("id?"); const int amount = msg.readInt16("amount"); msg.readUInt8("type"); diff --git a/src/net/eathena/auctionrecv.cpp b/src/net/eathena/auctionrecv.cpp index eed21a5e2..3f91d89a8 100644 --- a/src/net/eathena/auctionrecv.cpp +++ b/src/net/eathena/auctionrecv.cpp @@ -47,14 +47,14 @@ void AuctionRecv::processAuctionResults(Net::MessageIn &msg) { msg.readInt32("auction id"); msg.readString(24, "seller name"); - msg.readInt32("item id"); + msg.readInt16("item id"); // here item always 16 bit msg.readInt32("auction type"); msg.readInt16("item amount"); // always 1 msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); for (int d = 0; d < maxCards; d ++) - msg.readUInt16("card"); + msg.readUInt16("card"); // here item always 16 bit msg.readInt32("price"); msg.readInt32("buy now"); msg.readString(24, "buyer name"); diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index 440fb5971..56cf4d35c 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -74,6 +74,7 @@ extern Window *deathNotice; extern bool packets_re; extern bool packets_main; extern bool packets_zero; +extern int itemIdLen; namespace EAthena { @@ -248,7 +249,7 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg) id2 = 1; for (int f = 0; f < maxCards; f ++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readUInt16("card"); // +++ probably need use int32 if (dstBeing == nullptr) return; @@ -500,9 +501,14 @@ void BeingRecv::processBeingVisible(Net::MessageIn &msg) const int hairStyle = msg.readInt16("hair style"); uint32_t weapon; if (msg.getVersion() >= 7) - weapon = CAST_U32(msg.readInt32("weapon")); + { + weapon = msg.readItemId("weapon"); + msg.readItemId("shield"); + } else + { weapon = CAST_U32(msg.readInt16("weapon")); + } const uint16_t headBottom = msg.readInt16("head bottom"); if (msg.getVersion() < 7) msg.readInt16("shield"); @@ -689,9 +695,14 @@ void BeingRecv::processBeingMove(Net::MessageIn &msg) const int hairStyle = msg.readInt16("hair style"); uint32_t weapon; if (msg.getVersion() >= 7) - weapon = CAST_U32(msg.readInt32("weapon")); + { + weapon = msg.readItemId("weapon"); + msg.readItemId("shield"); + } else + { weapon = CAST_U32(msg.readInt16("weapon")); + } const uint16_t headBottom = msg.readInt16("head bottom"); msg.readInt32("tick"); if (msg.getVersion() < 7) @@ -883,9 +894,14 @@ void BeingRecv::processBeingSpawn(Net::MessageIn &msg) const int hairStyle = msg.readInt16("hair style"); uint32_t weapon; if (msg.getVersion() >= 7) - weapon = CAST_U32(msg.readInt32("weapon")); + { + weapon = msg.readItemId("weapon"); + msg.readItemId("shield"); + } else + { weapon = CAST_U32(msg.readInt16("weapon")); + } const uint16_t headBottom = msg.readInt16("head bottom"); if (msg.getVersion() < 7) msg.readInt16("shield"); @@ -1963,7 +1979,7 @@ void BeingRecv::processBeingViewEquipment(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - const int count = (msg.readInt16("len") - 45) / 31; + const int count = (msg.readInt16("len") - 45) / (21 + itemIdLen * 5); msg.readString(24, "name"); msg.readInt16("job"); msg.readInt16("head"); @@ -1978,13 +1994,13 @@ void BeingRecv::processBeingViewEquipment(Net::MessageIn &msg) for (int f = 0; f < count; f ++) { msg.readInt16("index"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readUInt8("item type"); msg.readInt32("location"); msg.readInt32("wear state"); msg.readInt8("refine"); for (int d = 0; d < maxCards; d ++) - msg.readUInt16("card"); + msg.readItemId("card"); msg.readInt32("hire expire date (?)"); msg.readInt16("equip type"); msg.readInt16("item sprite number"); diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp index 44a63a658..3a5bfb9d3 100644 --- a/src/net/eathena/buyingstorehandler.cpp +++ b/src/net/eathena/buyingstorehandler.cpp @@ -35,6 +35,7 @@ #include "debug.h" extern int packetVersion; +extern int itemIdLen; namespace EAthena { @@ -57,14 +58,14 @@ void BuyingStoreHandler::create(const std::string &name, if (packetVersion < 20100303) return; createOutPacket(CMSG_BUYINGSTORE_CREATE); - outMsg.writeInt16(CAST_S16(89 + items.size() * 8), "len"); + outMsg.writeInt16(CAST_S16(89 + items.size() * (6 + itemIdLen)), "len"); outMsg.writeInt32(maxMoney, "limit money"); outMsg.writeInt8(static_cast<int8_t>(flag), "flag"); outMsg.writeString(name, 80, "store name"); FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items) { const ShopItem *const item = *it; - outMsg.writeInt16(CAST_S16(item->getId()), "item id"); + outMsg.writeItemId(item->getId(), "item id"); outMsg.writeInt16(CAST_S16(item->getQuantity()), "amount"); outMsg.writeInt32(item->getPrice(), "price"); } @@ -105,7 +106,7 @@ void BuyingStoreHandler::sell(const Being *const being, outMsg.writeInt16(CAST_S16( item->getInvIndex() + INVENTORY_OFFSET), "index"); - outMsg.writeInt16(CAST_S16(item->getId()), "item id"); + outMsg.writeItemId(item->getId(), "item id"); outMsg.writeInt16(CAST_S16(amount), "amount"); } diff --git a/src/net/eathena/buyingstorerecv.cpp b/src/net/eathena/buyingstorerecv.cpp index 90766686a..5f35172e5 100644 --- a/src/net/eathena/buyingstorerecv.cpp +++ b/src/net/eathena/buyingstorerecv.cpp @@ -46,6 +46,8 @@ #include "debug.h" +extern int itemIdLen; + namespace EAthena { @@ -77,7 +79,7 @@ void BuyingStoreRecv::processBuyingStoreCreateFailed(Net::MessageIn &msg) void BuyingStoreRecv::processBuyingStoreOwnItems(Net::MessageIn &msg) { - const int count = (msg.readInt16("len") - 12) / 9; + const int count = (msg.readInt16("len") - 12) / (7 + itemIdLen); msg.readBeingId("account id"); msg.readInt32("money limit"); for (int f = 0; f < count; f ++) @@ -85,7 +87,7 @@ void BuyingStoreRecv::processBuyingStoreOwnItems(Net::MessageIn &msg) msg.readInt32("price"); msg.readInt16("amount"); msg.readUInt8("item type"); - msg.readInt16("item id"); + msg.readItemId("item id"); } PlayerInfo::enableVending(true); BuyingStoreModeListener::distributeEvent(true); @@ -126,7 +128,7 @@ void BuyingStoreRecv::processBuyingStoreItemsList(Net::MessageIn &msg) { if (actorManager == nullptr) return; - const int count = (msg.readInt16("len") - 16) / 9; + const int count = (msg.readInt16("len") - 16) / (7 + itemIdLen); const BeingId id = msg.readBeingId("account id"); const int storeId = msg.readInt32("store id"); // +++ in future need use it too @@ -147,7 +149,7 @@ void BuyingStoreRecv::processBuyingStoreItemsList(Net::MessageIn &msg) const int amount = msg.readInt16("amount"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); if (inv == nullptr) continue; @@ -180,7 +182,7 @@ void BuyingStoreRecv::processBuyingStoreSellFailed(Net::MessageIn &msg) void BuyingStoreRecv::processBuyingStoreSellerSellFailed(Net::MessageIn &msg) { const int16_t result = msg.readInt16("result"); - msg.readInt16("item id"); + msg.readItemId("item id"); switch (result) { case 5: @@ -205,7 +207,7 @@ void BuyingStoreRecv::processBuyingStoreSellerSellFailed(Net::MessageIn &msg) void BuyingStoreRecv::processBuyingStoreReport(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readInt16("amount"); if (msg.getVersion() >= 20141016) { diff --git a/src/net/eathena/buysellrecv.cpp b/src/net/eathena/buysellrecv.cpp index c49375fd3..9bb91520b 100644 --- a/src/net/eathena/buysellrecv.cpp +++ b/src/net/eathena/buysellrecv.cpp @@ -46,13 +46,15 @@ #include "debug.h" +extern int itemIdLen; + namespace EAthena { void BuySellRecv::processNpcBuy(Net::MessageIn &msg) { msg.readInt16("len"); - const int sz = 11; + const int sz = 9 + itemIdLen; const int n_items = (msg.getLength() - 4) / sz; const BeingTypeId npcId = NpcRecv::mNpcTypeId; @@ -83,7 +85,7 @@ void BuySellRecv::processNpcBuy(Net::MessageIn &msg) msg.readInt32("dc value?"); const ItemTypeT type = static_cast<ItemTypeT>( msg.readUInt8("type")); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemColor color = ItemColor_one; Ea::BuySellRecv::mBuyDialog->addItem(itemId, type, color, 0, value); } diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp index f6292c818..3585c4903 100644 --- a/src/net/eathena/cashshophandler.cpp +++ b/src/net/eathena/cashshophandler.cpp @@ -31,6 +31,7 @@ #include "debug.h" extern int packetVersion; +extern int itemIdLen; namespace EAthena { @@ -55,11 +56,11 @@ void CashShopHandler::buyItem(const int points, if (packetVersion < 20101124) return; createOutPacket(CMSG_NPC_CASH_SHOP_BUY); - outMsg.writeInt16(10 + 4, "len"); + outMsg.writeInt16(10 + (2 + itemIdLen), "len"); outMsg.writeInt32(points, "points"); outMsg.writeInt16(1, "count"); outMsg.writeInt16(CAST_S16(amount), "amount"); - outMsg.writeInt16(CAST_S16(itemId), "item id"); + outMsg.writeItemId(itemId, "item id"); } void CashShopHandler::buyItems(const int points, @@ -69,7 +70,7 @@ void CashShopHandler::buyItems(const int points, return; int cnt = 0; - const int pairSize = 4; + const int pairSize = 2 + itemIdLen; FOR_EACH (STD_VECTOR<ShopItem*>::const_iterator, it, items) { @@ -116,14 +117,14 @@ void CashShopHandler::buyItems(const int points, for (int f = 0; f < usedQuantity; f ++) { outMsg.writeInt16(CAST_S16(1), "amount"); - outMsg.writeInt16(CAST_S16(item->getId()), + outMsg.writeItemId(item->getId(), "item id"); } } else { outMsg.writeInt16(CAST_S16(usedQuantity), "amount"); - outMsg.writeInt16(CAST_S16(item->getId()), "item id"); + outMsg.writeItemId(item->getId(), "item id"); } } } diff --git a/src/net/eathena/cashshoprecv.cpp b/src/net/eathena/cashshoprecv.cpp index 8190fd560..5d062175e 100644 --- a/src/net/eathena/cashshoprecv.cpp +++ b/src/net/eathena/cashshoprecv.cpp @@ -41,6 +41,7 @@ #include "debug.h" extern int packetVersion; +extern int itemIdLen; namespace EAthena { @@ -53,10 +54,13 @@ namespace CashShopRecv void CashShopRecv::processCashShopOpen(Net::MessageIn &msg) { int count; + int blockSize = 11; + if (itemIdLen == 4) + blockSize += 2; if (packetVersion >= 20070711) - count = (msg.readInt16("len") - 12) / 11; + count = (msg.readInt16("len") - 12) / blockSize; else - count = (msg.readInt16("len") - 8) / 11; + count = (msg.readInt16("len") - 8) / blockSize; const BeingTypeId npcId = NpcRecv::mNpcTypeId; std::string currency; @@ -88,7 +92,7 @@ void CashShopRecv::processCashShopOpen(Net::MessageIn &msg) const int value = msg.readInt32("discount price"); const ItemTypeT type = static_cast<ItemTypeT>( msg.readUInt8("item type")); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemColor color = ItemColor_one; mBuyDialog->addItem(itemId, type, color, 0, value); } @@ -157,7 +161,7 @@ void CashShopRecv::processCashShopTabPriceList(Net::MessageIn &msg) for (int f = 0; f < count; f ++) { - msg.readInt16("item id"); + msg.readInt16("item id"); // item id size always 16 bit msg.readInt32("price"); } } @@ -165,7 +169,10 @@ void CashShopRecv::processCashShopTabPriceList(Net::MessageIn &msg) void CashShopRecv::processCashShopSchedule(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - const int count = (msg.readInt16("len") - 8) / 6; + int blockSize = 6; + if (itemIdLen == 4) + blockSize += 2; + const int count = (msg.readInt16("len") - 8) / blockSize; const int itemsCount = msg.readInt16("count"); msg.readInt16("tab"); if (count != itemsCount) @@ -173,7 +180,7 @@ void CashShopRecv::processCashShopSchedule(Net::MessageIn &msg) for (int f = 0; f < count; f ++) { - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readInt32("price"); } } diff --git a/src/net/eathena/chatrecv.cpp b/src/net/eathena/chatrecv.cpp index 12ebe2ee9..66edbebe7 100644 --- a/src/net/eathena/chatrecv.cpp +++ b/src/net/eathena/chatrecv.cpp @@ -728,13 +728,13 @@ void ChatRecv::processChatRoomRoleChange(Net::MessageIn &msg) void ChatRecv::processMVPItem(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - msg.readInt16("item id"); + msg.readItemId("item id"); } void ChatRecv::processMVPExp(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - msg.readInt32("exo"); + msg.readInt32("exp"); } void ChatRecv::processMVPNoItem(Net::MessageIn &msg) diff --git a/src/net/eathena/homunculusrecv.cpp b/src/net/eathena/homunculusrecv.cpp index 0f0d619ae..5f0b586bd 100644 --- a/src/net/eathena/homunculusrecv.cpp +++ b/src/net/eathena/homunculusrecv.cpp @@ -227,7 +227,7 @@ void HomunculusRecv::processHomunculusSkillUp(Net::MessageIn &msg) void HomunculusRecv::processHomunculusFood(Net::MessageIn &msg) { const int flag = msg.readUInt8("fail"); - const int itemId = msg.readInt16("food id"); + const int itemId = msg.readItemId("food id"); if (flag != 0) { NotifyManager::notify(NotifyTypes::HOMUNCULUS_FEED_OK); diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index 8ea2597ee..d1351229c 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -62,6 +62,7 @@ extern int serverVersion; extern int packetVersion; +extern int itemIdLen; namespace EAthena { @@ -125,13 +126,14 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) packetLen += 2; if (msg.getVersion() >= 20150226) packetLen += 26; + packetLen += itemIdLen * 5 - 2 * 5; // - 5 items by 2 bytes. + 5 items const int number = (msg.getLength() - 4) / packetLen; for (int loop = 0; loop < number; loop++) { const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); int equipType; @@ -150,7 +152,7 @@ void InventoryRecv::processPlayerEquipment(Net::MessageIn &msg) const uint8_t refine = CAST_U8(msg.readInt8("refine")); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); if (msg.getVersion() >= 20071002) msg.readInt32("hire expire date (?)"); if (msg.getVersion() >= 20080102) @@ -216,14 +218,14 @@ void InventoryRecv::processPlayerInventoryAdd(Net::MessageIn &msg) } const int index = msg.readInt16("index") - INVENTORY_OFFSET; int amount = msg.readInt16("count"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const uint8_t identified = msg.readUInt8("identified"); const uint8_t damaged = msg.readUInt8("is damaged"); const uint8_t refine = msg.readUInt8("refine"); Favorite favorite = Favorite_false; int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); int equipType; if (msg.getVersion() >= 20120925) equipType = msg.readInt32("location"); @@ -389,13 +391,14 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) packetLen += 8; if (msg.getVersion() >= 20080102) packetLen += 4; + packetLen += itemIdLen * 5 - 10; const int number = (msg.getLength() - 4) / packetLen; for (int loop = 0; loop < number; loop++) { const int index = msg.readInt16("item index") - INVENTORY_OFFSET; - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); if (msg.getVersion() < 20120925) @@ -409,7 +412,7 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) if (packetVersion >= 5) { for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); } else { @@ -459,6 +462,7 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) packetLen += 8; if (msg.getVersion() >= 20080102) packetLen += 4; + packetLen += itemIdLen * 5 - 10; int number; if (msg.getVersion() >= 20120925) @@ -474,7 +478,7 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) for (int loop = 0; loop < number; loop++) { const int index = msg.readInt16("item index") - STORAGE_OFFSET; - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); if (msg.getVersion() < 20120925) @@ -488,7 +492,7 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) if (msg.getVersion() >= 5) { for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); } else { @@ -661,6 +665,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) packetLen += 2; if (msg.getVersion() >= 20150226) packetLen += 26; + packetLen += itemIdLen * 5 - 10; int number; if (msg.getVersion() >= 20120925) @@ -676,7 +681,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) for (int loop = 0; loop < number; loop++) { const int index = msg.readInt16("index") - STORAGE_OFFSET; - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); const int amount = 1; @@ -695,7 +700,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) const uint8_t refine = msg.readUInt8("refine level"); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); if (msg.getVersion() >= 20071002) msg.readInt32("hire expire date"); if (msg.getVersion() >= 20080102) @@ -745,7 +750,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) // Move an item into storage const int index = msg.readInt16("index") - STORAGE_OFFSET; const int amount = msg.readInt32("amount"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); ItemTypeT itemType; if (msg.getVersion() >= 5) itemType = static_cast<ItemTypeT>(msg.readUInt8("type")); @@ -756,7 +761,7 @@ void InventoryRecv::processPlayerStorageAdd(Net::MessageIn &msg) const uint8_t refine = msg.readUInt8("refine"); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { @@ -857,7 +862,7 @@ void InventoryRecv::processPlayerInsertCard(Net::MessageIn &msg) void InventoryRecv::processPlayerItemRentalTime(Net::MessageIn &msg) { - const int id = msg.readInt16("item id"); + const int id = msg.readItemId("item id"); const int seconds = msg.readInt32("seconds"); const ItemInfo &info = ItemDB::get(id); const std::string timeStr = timeDiffToString(seconds); @@ -873,7 +878,7 @@ void InventoryRecv::processPlayerItemRentalExpired(Net::MessageIn &msg) ? PlayerInfo::getInventory() : nullptr; const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int id = msg.readInt16("item id"); + const int id = msg.readItemId("item id"); const ItemInfo &info = ItemDB::get(id); NotifyManager::notify(NotifyTypes::RENTAL_TIME_EXPIRED, @@ -957,7 +962,7 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) const int index = msg.readInt16("index") - INVENTORY_OFFSET; int amount = msg.readInt32("count"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); ItemTypeT itemType = ItemType::Unknown; if (msg.getVersion() >= 5) { @@ -969,7 +974,7 @@ void InventoryRecv::processPlayerCartAdd(Net::MessageIn &msg) const uint8_t refine = msg.readUInt8("refine"); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { @@ -1042,12 +1047,13 @@ void InventoryRecv::processPlayerCartEquip(Net::MessageIn &msg) packetLen += 2; if (msg.getVersion() >= 20150226) packetLen += 26; + packetLen += itemIdLen * 5 - 10; const int number = (msg.getLength() - 4) / packetLen; for (int loop = 0; loop < number; loop++) { const int index = msg.readInt16("index") - INVENTORY_OFFSET; - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); const int amount = 1; @@ -1066,7 +1072,7 @@ void InventoryRecv::processPlayerCartEquip(Net::MessageIn &msg) const uint8_t refine = msg.readUInt8("refine level"); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); if (msg.getVersion() >= 20071002) msg.readInt32("hire expire date"); if (msg.getVersion() >= 20080102) @@ -1124,12 +1130,13 @@ void InventoryRecv::processPlayerCartItems(Net::MessageIn &msg) packetLen += 8; if (msg.getVersion() >= 20080102) packetLen += 4; + packetLen += itemIdLen * 5 - 10; const int number = (msg.getLength() - 4) / packetLen; for (int loop = 0; loop < number; loop++) { const int index = msg.readInt16("item index") - INVENTORY_OFFSET; - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); if (msg.getVersion() < 20120925) @@ -1141,7 +1148,7 @@ void InventoryRecv::processPlayerCartItems(Net::MessageIn &msg) if (msg.getVersion() >= 5) { for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); } else { @@ -1252,14 +1259,15 @@ void InventoryRecv::processPlayerRepairList(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - const int count = (msg.readInt16("len") - 4) / 13; + const int count = (msg.readInt16("len") - 4) / + (3 + (1 + maxCards) * itemIdLen); for (int f = 0; f < count; f ++) { msg.readInt16("index"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readUInt8("refine"); for (int d = 0; d < maxCards; d ++) - msg.readUInt16("card"); + msg.readItemId("card"); } menu = MenuType::RepairWespon; } @@ -1276,15 +1284,16 @@ void InventoryRecv::processPlayerRefineList(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - const int count = (msg.readInt16("len") - 4) / 13; + const int count = (msg.readInt16("len") - 4) / + (3 + (1 + maxCards) * itemIdLen); for (int f = 0; f < count; f ++) { msg.readInt16("item index"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readUInt8("refine"); for (int d = 0; d < maxCards; d ++) - msg.readUInt16("card"); + msg.readItemId("card"); } menu = MenuType::WeaponeRefine; } @@ -1308,10 +1317,10 @@ void InventoryRecv::processPlayerCookingList(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - const int count = (msg.readInt16("len") - 6) / 2; + const int count = (msg.readInt16("len") - 6) / itemIdLen; msg.readInt16("list type"); for (int f = 0; f < count; f ++) - msg.readInt16("item id"); + msg.readItemId("item id"); } void InventoryRecv::processItemDamaged(Net::MessageIn &msg) diff --git a/src/net/eathena/itemrecv.cpp b/src/net/eathena/itemrecv.cpp index 9b8fb3400..1a3806f55 100644 --- a/src/net/eathena/itemrecv.cpp +++ b/src/net/eathena/itemrecv.cpp @@ -41,7 +41,7 @@ namespace EAthena void ItemRecv::processItemDropped(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("id"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); ItemTypeT itemType = ItemType::Unknown; if (msg.getVersion() >= 20130000) itemType = static_cast<ItemTypeT>(msg.readInt16("type")); @@ -77,7 +77,7 @@ void ItemRecv::processItemDropped(Net::MessageIn &msg) void ItemRecv::processItemDropped2(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("id"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readInt16("item id"); // +++ need use int32 const ItemTypeT itemType = static_cast<ItemTypeT>(msg.readUInt8("type")); const Identified identified = fromInt( msg.readUInt8("identify"), Identified); @@ -85,12 +85,13 @@ void ItemRecv::processItemDropped2(Net::MessageIn &msg) const uint8_t refine = msg.readUInt8("refine"); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readUInt16("card"); // ++ need use int32 const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); const int amount = msg.readInt16("amount"); const int subX = CAST_S32(msg.readInt8("subx")); const int subY = CAST_S32(msg.readInt8("suby")); + // +++ probably need add drop effect fields? if (actorManager != nullptr) { @@ -113,7 +114,7 @@ void ItemRecv::processItemMvpDropped(Net::MessageIn &msg) UNIMPLEMENTEDPACKET; msg.readInt16("len"); msg.readUInt8("type"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readUInt8("len"); msg.readString(24, "name"); msg.readUInt8("monster name len"); @@ -123,7 +124,7 @@ void ItemRecv::processItemMvpDropped(Net::MessageIn &msg) void ItemRecv::processItemVisible(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("item object id"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const Identified identified = fromInt( msg.readUInt8("identify"), Identified); const int x = msg.readInt16("x"); @@ -151,7 +152,7 @@ void ItemRecv::processItemVisible(Net::MessageIn &msg) void ItemRecv::processItemVisible2(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("item object id"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readInt16("item id"); // +++ need use int32 const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("type")); const Identified identified = fromInt( @@ -160,7 +161,7 @@ void ItemRecv::processItemVisible2(Net::MessageIn &msg) const uint8_t refine = msg.readUInt8("refine"); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readUInt16("card"); // +++ need use int32 const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); const int amount = msg.readInt16("amount"); diff --git a/src/net/eathena/mail2recv.cpp b/src/net/eathena/mail2recv.cpp index 5c1db8de6..d22bc211e 100644 --- a/src/net/eathena/mail2recv.cpp +++ b/src/net/eathena/mail2recv.cpp @@ -81,7 +81,7 @@ void Mail2Recv::processAddItemResult(Net::MessageIn &msg) const int res = msg.readUInt8("result"); const int index = msg.readInt16("index") - INVENTORY_OFFSET; const int amount = msg.readInt16("amount"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); const uint8_t identify = msg.readUInt8("identify"); @@ -89,7 +89,7 @@ void Mail2Recv::processAddItemResult(Net::MessageIn &msg) const uint8_t refine = msg.readUInt8("refine"); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); ItemOptionsList *options = new ItemOptionsList(5); for (int f = 0; f < 5; f ++) { @@ -99,11 +99,8 @@ void Mail2Recv::processAddItemResult(Net::MessageIn &msg) options->add(idx, val); } msg.readInt16("weight"); - msg.readUInt8("unknown 1"); - msg.readUInt8("unknown 2"); - msg.readUInt8("unknown 3"); - msg.readUInt8("unknown 4"); - msg.readUInt8("unknown 5"); + Favorite favorite = fromBool(msg.readUInt8("favorite"), Favorite); + msg.readInt32("location"); if (mailEditWindow == nullptr) { @@ -159,7 +156,7 @@ void Mail2Recv::processAddItemResult(Net::MessageIn &msg) ItemColorManager::getColorFromCards(&cards[0]), fromBool(identify, Identified), damaged, - Favorite_false, + favorite, Equipm_false, Equipped_false); if (slot == -1) @@ -412,15 +409,16 @@ void Mail2Recv::processReadMail(Net::MessageIn &msg) for (int f = 0; f < itemsCount; f ++) { msg.readInt16("amount"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readUInt8("identify"); msg.readUInt8("damaged"); msg.readUInt8("refine"); for (int d = 0; d < maxCards; d ++) - msg.readUInt16("card"); - msg.readInt32("unknown"); + msg.readItemId("card"); + msg.readInt32("location"); msg.readUInt8("type"); - msg.readInt32("unknown"); + msg.readInt16("view sprite"); + msg.readInt16("bind on equip"); for (int d = 0; d < 5; d ++) { msg.readInt16("option index"); @@ -443,17 +441,18 @@ void Mail2Recv::processReadMail(Net::MessageIn &msg) if (msg.getUnreadLength() == 0) break; const int amount = msg.readInt16("amount"); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const uint8_t identify = msg.readUInt8("identify"); const Damaged damaged = fromBool(msg.readUInt8("attribute"), Damaged); const uint8_t refine = msg.readUInt8("refine"); int cards[maxCards]; for (int d = 0; d < maxCards; d ++) - cards[d] = msg.readUInt16("card"); - msg.readInt32("unknown"); + cards[d] = msg.readItemId("card"); + msg.readInt32("location"); const ItemTypeT itemType = static_cast<ItemTypeT>( msg.readUInt8("item type")); - msg.readInt32("unknown"); + msg.readInt16("view sprite"); + msg.readInt16("bind on equip"); ItemOptionsList *options = new ItemOptionsList(5); for (int d = 0; d < 5; d ++) { diff --git a/src/net/eathena/markethandler.cpp b/src/net/eathena/markethandler.cpp index 17e1bffd5..31e930a67 100644 --- a/src/net/eathena/markethandler.cpp +++ b/src/net/eathena/markethandler.cpp @@ -75,7 +75,7 @@ void MarketHandler::buyItem(const int itemId, outMsg.writeInt16(CAST_S16(4 + 6 * cnt), "len"); for (int f = 0; f < cnt; f ++) { - outMsg.writeInt16(CAST_S16(itemId), "item id"); + outMsg.writeInt16(CAST_S16(itemId), "item id"); // +++ 20180711 re outMsg.writeInt32(CAST_S16(amount2), "amount"); } } @@ -130,13 +130,14 @@ void MarketHandler::buyItems(const STD_VECTOR<ShopItem*> &items) const for (int f = 0; f < usedQuantity; f ++) { outMsg.writeInt16(CAST_S16(item->getId()), - "item id"); + "item id"); // +++ 20180711 re outMsg.writeInt32(CAST_S16(1), "amount"); } } else { - outMsg.writeInt16(CAST_S16(item->getId()), "item id"); + outMsg.writeInt16(CAST_S16(item->getId()), + "item id"); // +++ 20180711 re outMsg.writeInt32(CAST_S16(usedQuantity), "amount"); } } diff --git a/src/net/eathena/marketrecv.cpp b/src/net/eathena/marketrecv.cpp index 54947ccaa..c2d310193 100644 --- a/src/net/eathena/marketrecv.cpp +++ b/src/net/eathena/marketrecv.cpp @@ -42,6 +42,8 @@ #include "debug.h" +extern int itemIdLen; + namespace EAthena { @@ -53,7 +55,7 @@ namespace MarketRecv void MarketRecv::processMarketOpen(Net::MessageIn &msg) { - const int len = (msg.readInt16("len") - 4) / 13; + const int len = (msg.readInt16("len") - 4) / (11 + itemIdLen); const BeingTypeId npcId = NpcRecv::mNpcTypeId; std::string currency; @@ -78,7 +80,7 @@ void MarketRecv::processMarketOpen(Net::MessageIn &msg) for (int f = 0; f < len; f ++) { - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); const ItemTypeT type = static_cast<ItemTypeT>(msg.readUInt8("type")); const int value = msg.readInt32("price"); const int amount = msg.readInt32("amount"); @@ -91,11 +93,11 @@ void MarketRecv::processMarketOpen(Net::MessageIn &msg) void MarketRecv::processMarketBuyAck(Net::MessageIn &msg) { - const int len = (msg.readInt16("len") - 5) / 8; + const int len = (msg.readInt16("len") - 5) / (6 + itemIdLen); const int res = msg.readUInt8("result"); for (int f = 0; f < len; f ++) { - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readInt16("amount"); msg.readInt32("price"); } diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index 384b38d18..eb4108bb2 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -48,6 +48,7 @@ extern int packetVersion; extern int packetVersionMain; extern int packetVersionRe; +extern int itemIdLen; namespace EAthena { @@ -164,13 +165,13 @@ void NpcHandler::buyItem(const BeingId beingId A_UNUSED, createOutPacket(CMSG_NPC_BUY_REQUEST); outMsg.writeInt16(8, "len"); outMsg.writeInt16(CAST_S16(amount), "amount"); - outMsg.writeInt16(CAST_S16(itemId), "item id"); + outMsg.writeItemId(itemId, "item id"); } void NpcHandler::buyItems(STD_VECTOR<ShopItem*> &items) const { int cnt = 0; - const int pairSize = 4; + const int pairSize = 2 + itemIdLen; FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items) { @@ -214,14 +215,14 @@ void NpcHandler::buyItems(STD_VECTOR<ShopItem*> &items) const for (int f = 0; f < usedQuantity; f ++) { outMsg.writeInt16(CAST_S16(1), "amount"); - outMsg.writeInt16(CAST_S16(item->getId()), + outMsg.writeItemId(item->getId(), "item id"); } } else { outMsg.writeInt16(CAST_S16(usedQuantity), "amount"); - outMsg.writeInt16(CAST_S16(item->getId()), "item id"); + outMsg.writeItemId(item->getId(), "item id"); } } } @@ -374,7 +375,7 @@ void NpcHandler::requestAirship(const std::string &mapName, } createOutPacket(CMSG_PRIVATE_AIRSHIP_REQUEST); outMsg.writeString(mapName, 16, "map name"); - outMsg.writeInt16(CAST_S16(itemId), "item"); + outMsg.writeItemId(itemId, "item"); } } // namespace EAthena diff --git a/src/net/eathena/partyrecv.cpp b/src/net/eathena/partyrecv.cpp index 336c7cfd0..daef7a148 100644 --- a/src/net/eathena/partyrecv.cpp +++ b/src/net/eathena/partyrecv.cpp @@ -355,12 +355,12 @@ void PartyRecv::processPartyItemPickup(Net::MessageIn &msg) // +++ probably need add option to show pickup notifications // in party tab msg.readBeingId("account id"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); for (int f = 0; f < maxCards; f++) - msg.readUInt16("card"); + msg.readItemId("card"); msg.readInt16("equip location"); msg.readUInt8("item type"); // for color can be used ItemColorManager diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp index 72243057f..29e814ff7 100644 --- a/src/net/eathena/pethandler.cpp +++ b/src/net/eathena/pethandler.cpp @@ -135,7 +135,7 @@ void PetHandler::evolution(const Item *const item) const return; } createOutPacket(CMSG_PET_EVOLUTION); - outMsg.writeInt16(CAST_S16(item->getId()), "egg id"); + outMsg.writeItemId(item->getId(), "egg id"); } } // namespace EAthena diff --git a/src/net/eathena/petrecv.cpp b/src/net/eathena/petrecv.cpp index 344b388ac..b8edee09a 100644 --- a/src/net/eathena/petrecv.cpp +++ b/src/net/eathena/petrecv.cpp @@ -145,7 +145,7 @@ void PetRecv::processPetStatus(Net::MessageIn &msg) const int level = msg.readInt16("level"); const int hungry = msg.readInt16("hungry"); const int intimacy = msg.readInt16("intimacy"); - const int equip = msg.readInt16("equip"); + const int equip = msg.readInt16("equip"); // look like always int16 // Being *const being = PlayerInfo::getPetBeing(); // if (being) @@ -168,7 +168,7 @@ void PetRecv::processPetStatus(Net::MessageIn &msg) void PetRecv::processPetFood(Net::MessageIn &msg) { const int result = msg.readUInt8("result"); - msg.readInt16("food id"); + msg.readItemId("food id"); if (result != 0) NotifyManager::notify(NotifyTypes::PET_FEED_OK); else diff --git a/src/net/eathena/playerrecv.cpp b/src/net/eathena/playerrecv.cpp index 11d9e9bc1..95811448f 100644 --- a/src/net/eathena/playerrecv.cpp +++ b/src/net/eathena/playerrecv.cpp @@ -388,7 +388,7 @@ void PlayerRecv::processPlayerUpgradeMessage(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; msg.readInt32("result"); - msg.readInt16("item id"); + msg.readItemId("item id"); } void PlayerRecv::processPlayerFameTaekwon(Net::MessageIn &msg) @@ -407,6 +407,7 @@ void PlayerRecv::processPlayerReadBook(Net::MessageIn &msg) void PlayerRecv::processPlayerEquipTickAck(Net::MessageIn &msg) { + // +++ actually ZC_CONFIG UNIMPLEMENTEDPACKET; msg.readInt32("unused"); msg.readInt32("flag"); diff --git a/src/net/eathena/rouletterecv.cpp b/src/net/eathena/rouletterecv.cpp index 49666f49f..352da948a 100644 --- a/src/net/eathena/rouletterecv.cpp +++ b/src/net/eathena/rouletterecv.cpp @@ -57,7 +57,7 @@ void RouletteRecv::processRouletteItemAck(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; msg.readUInt8("result"); - msg.readInt16("item id"); + msg.readItemId("item id"); } void RouletteRecv::processRouletteGenerateAckType(Net::MessageIn &msg) @@ -66,7 +66,7 @@ void RouletteRecv::processRouletteGenerateAckType(Net::MessageIn &msg) msg.readUInt8("result"); msg.readInt16("step"); msg.readInt16("idx"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readInt32("remain gold"); msg.readInt32("remain silver"); msg.readInt32("remain bronze"); @@ -79,7 +79,7 @@ void RouletteRecv::processRouletteOpenAck(Net::MessageIn &msg) msg.readInt32("serial"); msg.readUInt8("step"); msg.readUInt8("idx"); - msg.readInt16("additional item id"); + msg.readItemId("additional item id"); msg.readInt32("gold point"); msg.readInt32("silver point"); msg.readInt32("bronze point"); diff --git a/src/net/eathena/searchstorehandler.cpp b/src/net/eathena/searchstorehandler.cpp index 48b4be501..66bbc1674 100644 --- a/src/net/eathena/searchstorehandler.cpp +++ b/src/net/eathena/searchstorehandler.cpp @@ -56,7 +56,8 @@ void SearchStoreHandler::search(const StoreSearchTypeT type, outMsg.writeInt32(minPrice, "min price"); outMsg.writeInt32(1, "items count"); outMsg.writeInt32(0, "cards count"); - outMsg.writeInt16(CAST_S16(itemId), "item id"); + outMsg.writeItemId(itemId, "item id"); + // +++ missing for by items and cards } void SearchStoreHandler::nextPage() const @@ -82,7 +83,7 @@ void SearchStoreHandler::select(const int accountId, createOutPacket(CMSG_SEARCHSTORE_CLICK); outMsg.writeInt32(accountId, "account id"); outMsg.writeInt32(storeId, "store id"); - outMsg.writeInt16(CAST_S16(itemId), "item id"); + outMsg.writeItemId(itemId, "item id"); } } // namespace EAthena diff --git a/src/net/eathena/searchstorerecv.cpp b/src/net/eathena/searchstorerecv.cpp index 22fdec26b..b0dacb263 100644 --- a/src/net/eathena/searchstorerecv.cpp +++ b/src/net/eathena/searchstorerecv.cpp @@ -31,13 +31,15 @@ #include "debug.h" +extern int itemIdLen; + namespace EAthena { void SearchStoreRecv::processSearchAck(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - const int count = (msg.readInt16("len") - 7) / 106; + const int count = (msg.readInt16("len") - 7) / (104 + itemIdLen); msg.readUInt8("is first page"); msg.readUInt8("is next page"); msg.readUInt8("remain uses"); @@ -46,13 +48,13 @@ void SearchStoreRecv::processSearchAck(Net::MessageIn &msg) msg.readInt32("store id"); msg.readInt32("aoount id"); msg.readString(80, "store name"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readUInt8("item type"); msg.readInt32("price"); msg.readInt16("amount"); msg.readUInt8("refine"); for (int d = 0; d < maxCards; d++) - msg.readUInt16("card"); + msg.readItemId("card"); if (msg.getVersion() >= 20150226) { for (int d = 0; d < 5; d ++) diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp index 2d7bb04a9..609f71250 100644 --- a/src/net/eathena/skillrecv.cpp +++ b/src/net/eathena/skillrecv.cpp @@ -60,6 +60,7 @@ static const unsigned int RFAIL_NEED_EQUIPMENT = 72; static const unsigned int RFAIL_SPIRITS = 74; extern int serverVersion; +extern int itemIdLen; namespace EAthena { @@ -273,7 +274,8 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) // Action failed (ex. sit because you have not reached the // right level) const int skillId = msg.readInt16("skill id"); - const int bskill = msg.readInt32("btype"); + const int bskill = msg.readItemId("btype"); + const int itemId = msg.readItemId("item id"); const signed char success = msg.readUInt8("success"); const signed char reason = msg.readUInt8("reason"); if (success != CAST_S32(SKILL_FAILED) @@ -372,8 +374,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) break; case RFAIL_NEED_EQUIPMENT: { - const int itemId = bskill >> 16U; - const int amount = bskill & 0xFFFFU; + const int amount = bskill; const ItemInfo &info = ItemDB::get(itemId); if (amount == 1) { @@ -392,8 +393,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) } case RFAIL_NEED_ITEM: { - const int itemId = bskill >> 16U; - const int amount = bskill & 0xFFFFU; + const int amount = bskill; const ItemInfo &info = ItemDB::get(itemId); if (amount == 1) { @@ -466,12 +466,12 @@ void SkillRecv::processSkillProduceMixList(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - const int count = (msg.readInt16("len") - 8) / 8; + const int count = (msg.readInt16("len") - 4) / 4 * itemIdLen; for (int f = 0; f < count; f ++) { - msg.readInt16("item id"); + msg.readItemId("item id"); for (int d = 0; d < 3; d ++) - msg.readInt16("material id"); + msg.readItemId("material id"); } } @@ -480,7 +480,7 @@ void SkillRecv::processSkillProduceEffect(Net::MessageIn &msg) UNIMPLEMENTEDPACKET; msg.readInt16("flag"); - msg.readInt16("item id"); + msg.readItemId("item id"); } void SkillRecv::processSkillUnitUpdate(Net::MessageIn &msg) @@ -494,9 +494,9 @@ void SkillRecv::processSkillArrowCreateList(Net::MessageIn &msg) { UNIMPLEMENTEDPACKET; - const int count = (msg.readInt16("len") - 4) / 2; + const int count = (msg.readInt16("len") - 4) / itemIdLen; for (int f = 0; f < count; f ++) - msg.readInt16("item id"); + msg.readItemId("item id"); } void SkillRecv::processSkillAutoSpells(Net::MessageIn &msg) diff --git a/src/net/eathena/traderecv.cpp b/src/net/eathena/traderecv.cpp index 69b215620..72f6dc583 100644 --- a/src/net/eathena/traderecv.cpp +++ b/src/net/eathena/traderecv.cpp @@ -74,7 +74,7 @@ void TradeRecv::processTradeResponse(Net::MessageIn &msg) void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) { - const int type = msg.readInt16("type"); + const int type = msg.readItemId("item id"); ItemTypeT itemType = ItemType::Unknown; if (msg.getVersion() >= 20100223) { @@ -87,7 +87,7 @@ void TradeRecv::processTradeItemAdd(Net::MessageIn &msg) const uint8_t refine = msg.readUInt8("refine"); int cards[maxCards]; for (int f = 0; f < maxCards; f++) - cards[f] = msg.readUInt16("card"); + cards[f] = msg.readItemId("card"); ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { diff --git a/src/net/eathena/updateprotocol.cpp b/src/net/eathena/updateprotocol.cpp index 15050d099..21f6c001a 100644 --- a/src/net/eathena/updateprotocol.cpp +++ b/src/net/eathena/updateprotocol.cpp @@ -36,12 +36,14 @@ extern int evolPacketOffset; extern bool packets_main; extern bool packets_re; extern bool packets_zero; +extern int itemIdLen; namespace EAthena { void updateProtocol() { + itemIdLen = 2; logger->log("packet version: %d", packetVersion); if (packets_main == true) { @@ -64,6 +66,10 @@ void updateProtocol() packetVersionMain = 0; packetVersionRe = 0; } + if (packetVersionRe >= 20180704) + { + itemIdLen = 4; + } #define PACKETS_UPDATE #include "net/protocoloutupdate.h" #include "net/eathena/packetsout.inc" diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp index 2e8092886..b16c3eefa 100644 --- a/src/net/eathena/vendingrecv.cpp +++ b/src/net/eathena/vendingrecv.cpp @@ -58,6 +58,7 @@ extern int packetVersion; extern int serverVersion; +extern int itemIdLen; namespace EAthena { @@ -112,6 +113,8 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) packetLen = 53; else if (msg.getVersion() >= 20150226) packetLen = 47; + if (itemIdLen == 4) + packetLen += 10; int offset = 8; if (msg.getVersion() >= 20100105) offset += 4; @@ -133,12 +136,12 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) const int index = msg.readInt16("inv index"); const ItemTypeT type = static_cast<ItemTypeT>( msg.readUInt8("item type")); - const int itemId = msg.readInt16("item id"); + const int itemId = msg.readItemId("item id"); msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); for (int d = 0; d < maxCards; d ++) - cards[d] = msg.readUInt16("card"); + cards[d] = msg.readItemId("card"); ItemOptionsList *options = nullptr; if (msg.getVersion() >= 20150226) { @@ -207,6 +210,8 @@ void VendingRecv::processOpen(Net::MessageIn &msg) int packetLen = 22; if (msg.getVersion() >= 20150226) packetLen += 25; + if (itemIdLen == 4) + packetLen += 10; const int count = (msg.readInt16("len") - 8) / packetLen; msg.readInt32("id"); @@ -216,12 +221,12 @@ void VendingRecv::processOpen(Net::MessageIn &msg) msg.readInt16("inv index"); msg.readInt16("amount"); msg.readUInt8("item type"); - msg.readInt16("item id"); + msg.readItemId("item id"); msg.readUInt8("identify"); msg.readUInt8("attribute"); msg.readUInt8("refine"); for (int d = 0; d < maxCards; d ++) - msg.readUInt16("card"); + msg.readItemId("card"); if (msg.getVersion() >= 20150226) { for (int d = 0; d < 5; d ++) diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 5b942a2d0..d5888534e 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -42,6 +42,8 @@ PRAGMA48(GCC diagnostic pop) (CAST_U16((CAST_U8(low)) | \ (CAST_U16(CAST_U8(high))) << 8)) +extern int itemIdLen; + namespace Net { @@ -208,6 +210,13 @@ uint32_t MessageIn::readUInt32(const char *const str) return value; } +int MessageIn::readItemId(const char *const str) +{ + if (itemIdLen == 2) + return readUInt16(str); + return readInt32(str); +} + BeingId MessageIn::readBeingId(const char *const str) { return fromInt(readUInt32(str), BeingId); diff --git a/src/net/messagein.h b/src/net/messagein.h index ea2caa499..255710349 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -80,6 +80,8 @@ class MessageIn notfinal uint32_t readUInt32(const char *const str); + int readItemId(const char *const str); + int64_t readInt64(const char *const str); BeingId readBeingId(const char *const str); diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index 69993e4d8..841e1183d 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -40,6 +40,8 @@ PRAGMA48(GCC diagnostic pop) #error missing SDL_endian.h #endif // SDL_BYTEORDER +extern int itemIdLen; + namespace Net { @@ -98,6 +100,15 @@ void MessageOut::writeInt32(const int32_t value, const char *const str) mPos += 4; } +void MessageOut::writeItemId(const int32_t value, + const char *const str) +{ + if (itemIdLen == 2) + writeInt16(CAST_S32(value), str); + else + writeInt32(value, str); +} + void MessageOut::writeInt64(const int64_t value, const char *const str) { DEBUGLOG2("writeInt64: " + toStringPrint(CAST_U32(value)), diff --git a/src/net/messageout.h b/src/net/messageout.h index 9cf9b7e3e..e158430d6 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -61,6 +61,9 @@ class MessageOut notfinal void writeInt32(const int32_t value, const char *const str); + void writeItemId(const int32_t value, + const char *const str); + void writeInt64(const int64_t value, const char *const str); diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 0aa086831..b097d9040 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -33,6 +33,7 @@ #include "debug.h" extern unsigned int tmwServerVersion; +extern int itemIdLen; namespace TmwAthena { @@ -137,6 +138,7 @@ void LoginHandler::ping() const void LoginHandler::updatePacketVersion() const { + itemIdLen = 2; } } // namespace TmwAthena diff --git a/src/net/tmwa/loginrecv.cpp b/src/net/tmwa/loginrecv.cpp index 67e6b21e8..91d11b05e 100644 --- a/src/net/tmwa/loginrecv.cpp +++ b/src/net/tmwa/loginrecv.cpp @@ -41,6 +41,7 @@ #include "debug.h" extern int packetVersion; +extern int itemIdLen; namespace TmwAthena { @@ -55,6 +56,7 @@ enum ServerFlags void LoginRecv::processServerVersion(Net::MessageIn &msg) { packetVersion = 0; + itemIdLen = 2; const uint8_t b1 = msg.readUInt8("b1"); // -1 const uint8_t b2 = msg.readUInt8("b2"); const uint8_t b3 = msg.readUInt8("b3"); diff --git a/src/net/tmwa/updateprotocol.cpp b/src/net/tmwa/updateprotocol.cpp index 78aa2031b..0726bed6c 100644 --- a/src/net/tmwa/updateprotocol.cpp +++ b/src/net/tmwa/updateprotocol.cpp @@ -25,11 +25,14 @@ #include "debug.h" +extern int itemIdLen; + namespace TmwAthena { void updateProtocol() { + itemIdLen = 2; #define PACKETS_UPDATE #include "net/protocoloutupdate.h" #include "net/tmwa/packetsout.inc" diff --git a/src/progs/dyecmd/client.cpp b/src/progs/dyecmd/client.cpp index 385a50919..a905c326b 100644 --- a/src/progs/dyecmd/client.cpp +++ b/src/progs/dyecmd/client.cpp @@ -126,6 +126,7 @@ int packetVersionMain = 0; int packetVersionRe = 0; int packetVersionZero = 0; int packetsType = 0; +int itemIdLen = 2; bool packets_main = true; bool packets_re = false; bool packets_zero = false; diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp index f9f608102..880f05a0b 100644 --- a/src/progs/manaplus/client.cpp +++ b/src/progs/manaplus/client.cpp @@ -195,6 +195,7 @@ int packetVersionMain = 0; int packetVersionRe = 0; int packetVersionZero = 0; int packetsType = 0; +int itemIdLen = 2; bool packets_main = true; bool packets_re = false; bool packets_zero = false; |