diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 909eef1e92e..7ae02e31b10 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -5370,7 +5370,8 @@ void ProtocolGame::sendForgingData() { void ProtocolGame::sendOpenForge() { // We will use it when sending the bytes to send the item information to the client std::map> fusionItemsMap; - std::map>> convergenceItemsMap; + std::map>> convergenceFusionItemsMap; + std::map>> convergenceTransferItemsMap; std::map> donorTierItemMap; std::map> receiveTierItemMap; @@ -5405,7 +5406,12 @@ void ProtocolGame::sendOpenForge() { getForgeInfoMap(item, receiveTierItemMap); } if (itemClassification == 4) { - getForgeInfoMap(item, convergenceItemsMap[item->getClassification()]); + auto slotPosition = item->getSlotPosition(); + if ((slotPosition & SLOTP_TWO_HAND) != 0) { + slotPosition = SLOTP_HAND; + } + getForgeInfoMap(item, convergenceFusionItemsMap[slotPosition]); + getForgeInfoMap(item, convergenceTransferItemsMap[item->getClassification()]); } } } @@ -5413,7 +5419,7 @@ void ProtocolGame::sendOpenForge() { // Checking size of map to send in the addByte (total fusion items count) uint8_t fusionTotalItemsCount = 0; for (const auto &[itemId, tierAndCountMap] : fusionItemsMap) { - for (const auto [itemTier, itemCount] : tierAndCountMap) { + for (const auto &[itemTier, itemCount] : tierAndCountMap) { if (itemCount >= 2) { fusionTotalItemsCount++; } @@ -5430,7 +5436,7 @@ void ProtocolGame::sendOpenForge() { msg.add(fusionTotalItemsCount); for (const auto &[itemId, tierAndCountMap] : fusionItemsMap) { - for (const auto [itemTier, itemCount] : tierAndCountMap) { + for (const auto &[itemTier, itemCount] : tierAndCountMap) { if (itemCount >= 2) { msg.addByte(0x01); // Number of friend items? msg.add(itemId); @@ -5452,12 +5458,12 @@ void ProtocolGame::sendOpenForge() { 1 byte: tier 2 bytes: count */ - for (const auto &[slot, itemMap] : convergenceItemsMap) { + for (const auto &[slot, itemMap] : convergenceFusionItemsMap) { uint8_t totalItemsCount = 0; auto totalItemsCountPosition = msg.getBufferPosition(); msg.skipBytes(1); // Total items count for (const auto &[itemId, tierAndCountMap] : itemMap) { - for (const auto [tier, itemCount] : tierAndCountMap) { + for (const auto &[tier, itemCount] : tierAndCountMap) { if (tier >= maxConfigTier) { continue; } @@ -5488,11 +5494,15 @@ void ProtocolGame::sendOpenForge() { // Let's access the itemType to check the item's (donator of tier) classification level // Must be the same as the item that will receive the tier const ItemType &donorType = Item::items[itemId]; + auto donorSlotPosition = donorType.slotPosition; + if ((donorSlotPosition & SLOTP_TWO_HAND) != 0) { + donorSlotPosition = SLOTP_HAND; + } // Total count of item (donator of tier) auto donorTierTotalItemsCount = getIterationIncreaseCount(tierAndCountMap); msg.add(donorTierTotalItemsCount); - for (const auto [donorItemTier, donorItemCount] : tierAndCountMap) { + for (const auto &[donorItemTier, donorItemCount] : tierAndCountMap) { msg.add(itemId); msg.addByte(donorItemTier); msg.add(donorItemCount); @@ -5502,7 +5512,11 @@ void ProtocolGame::sendOpenForge() { for (const auto &[iteratorItemId, unusedTierAndCountMap] : receiveTierItemMap) { // Let's access the itemType to check the item's (receiver of tier) classification level const ItemType &receiveType = Item::items[iteratorItemId]; - if (donorType.upgradeClassification == receiveType.upgradeClassification) { + auto receiveSlotPosition = receiveType.slotPosition; + if ((receiveSlotPosition & SLOTP_TWO_HAND) != 0) { + receiveSlotPosition = SLOTP_HAND; + } + if (donorType.upgradeClassification == receiveType.upgradeClassification && donorSlotPosition == receiveSlotPosition) { receiveTierTotalItemCount++; } } @@ -5513,8 +5527,12 @@ void ProtocolGame::sendOpenForge() { for (const auto &[receiveItemId, receiveTierAndCountMap] : receiveTierItemMap) { // Let's access the itemType to check the item's (receiver of tier) classification level const ItemType &receiveType = Item::items[receiveItemId]; - if (donorType.upgradeClassification == receiveType.upgradeClassification) { - for (const auto [receiveItemTier, receiveItemCount] : receiveTierAndCountMap) { + auto receiveSlotPosition = receiveType.slotPosition; + if ((receiveSlotPosition & SLOTP_TWO_HAND) != 0) { + receiveSlotPosition = SLOTP_HAND; + } + if (donorType.upgradeClassification == receiveType.upgradeClassification && donorSlotPosition == receiveSlotPosition) { + for (const auto &[receiveItemTier, receiveItemCount] : receiveTierAndCountMap) { msg.add(receiveItemId); msg.add(receiveItemCount); } @@ -5540,7 +5558,7 @@ void ProtocolGame::sendOpenForge() { 2 bytes: item id 2 bytes: count */ - for (const auto &[slot, itemMap] : convergenceItemsMap) { + for (const auto &[slot, itemMap] : convergenceTransferItemsMap) { uint16_t donorCount = 0; uint16_t receiverCount = 0; auto donorCountPosition = msg.getBufferPosition();