SHOW:
|
|
- or go back to the newest paste.
| 1 | - | void WorldSession::SendListInventory(uint64 vendorGuid, uint32 vendorEntry) |
| 1 | + | std::vector<uint32> vendorItems = {
|
| 2 | 25, | |
| 3 | 25, | |
| 4 | 25, | |
| 5 | - | Creature* vendor = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR); |
| 5 | + | }; |
| 6 | ||
| 7 | void SendListInventoryCustom(Player* player, uint64 vendorGuid, uint32 vendorEntry) | |
| 8 | {
| |
| 9 | - | _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, 0); |
| 9 | + | |
| 10 | ||
| 11 | Creature* vendor = player->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR); | |
| 12 | if (!vendor) | |
| 13 | {
| |
| 14 | - | if (GetPlayer()->HasUnitState(UNIT_STATE_DIED)) |
| 14 | + | |
| 15 | - | GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); |
| 15 | + | player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, 0); |
| 16 | return; | |
| 17 | } | |
| 18 | ||
| 19 | // remove fake death | |
| 20 | if (player->HasUnitState(UNIT_STATE_DIED)) | |
| 21 | player->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH); | |
| 22 | - | //VendorItemData const* items = vendorEntry ? sObjectMgr->GetNpcVendorItemList(vendorEntry) : vendor->GetVendorItems(); |
| 22 | + | |
| 23 | - | VendorItemData const* vendorItems = vendorEntry ? sObjectMgr->GetNpcVendorItemList(vendorEntry) : vendor->GetVendorItems(); |
| 23 | + | |
| 24 | - | /*if (!vendorItems) |
| 24 | + | |
| 25 | - | {
|
| 25 | + | |
| 26 | - | WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + 1);*/ |
| 26 | + | |
| 27 | - | uint16 rawItemCount = vendorItems ? vendorItems->GetItemCount() : 0; |
| 27 | + | |
| 28 | //VendorItemData const* items = vendorEntry ? sObjectMgr->GetNpcVendorItemList(vendorEntry) : vendor->GetVendorItems(); | |
| 29 | // VendorItemData const* vendorItems = vendorEntry ? sObjectMgr->GetNpcVendorItemList(vendorEntry) : vendor->GetVendorItems(); | |
| 30 | /*if (!vendorItems) | |
| 31 | {
| |
| 32 | WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + 1);*/ | |
| 33 | - | SetCurrentVendor(vendorEntry, GUID_LOPART(vendorGuid), GUID_HIPART(vendorGuid)); |
| 33 | + | uint16 rawItemCount = vendorItems.size(); // vendorItems ? vendorItems->GetItemCount() : 0; |
| 34 | ||
| 35 | - | const float discountMod = _player->GetReputationPriceDiscount(vendor); |
| 35 | + | |
| 36 | std::vector<bool> enablers; | |
| 37 | enablers.reserve(2 * rawItemCount); | |
| 38 | ||
| 39 | SetCurrentVendor(vendorEntry, GUID_LOPART(vendorGuid), GUID_HIPART(vendorGuid)); | |
| 40 | ||
| 41 | const float discountMod = player->GetReputationPriceDiscount(vendor); | |
| 42 | uint16 count = 0; | |
| 43 | for (uint16 slot = 0; slot < rawItemCount; ++slot) | |
| 44 | - | VendorItem const* vendorItem = vendorItems->GetItem(slot); |
| 44 | + | |
| 45 | - | if (!vendorItem) continue; |
| 45 | + | |
| 46 | {
| |
| 47 | - | if (vendorItem->Type == ITEM_VENDOR_TYPE_ITEM) |
| 47 | + | |
| 48 | break; | |
| 49 | - | ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(vendorItem->item); |
| 49 | + | |
| 50 | // VendorItem const* vendorItem = vendorItems->GetItem(slot); | |
| 51 | // if (!vendorItem) continue; | |
| 52 | ||
| 53 | // if (vendorItem->Type == ITEM_VENDOR_TYPE_ITEM) | |
| 54 | - | if (!_player->isGameMaster()) // ignore conditions if GM on |
| 54 | + | |
| 55 | ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(vendorItems[slot]); | |
| 56 | if (!itemTemplate) | |
| 57 | - | if (!(itemTemplate->AllowableClass & _player->getClassMask()) && itemTemplate->Bonding == BIND_WHEN_PICKED_UP) |
| 57 | + | |
| 58 | ||
| 59 | /* | |
| 60 | uint32 leftInStock = !vendorItem->maxcount ? 0xFFFFFFFF : vendor->GetVendorItemCurrentCount(vendorItem); | |
| 61 | - | if ((itemTemplate->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY && _player->GetTeam() == ALLIANCE) || |
| 61 | + | if (!player->isGameMaster()) // ignore conditions if GM on |
| 62 | - | (itemTemplate->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY && _player->GetTeam() == HORDE)) |
| 62 | + | |
| 63 | // Respect allowed class | |
| 64 | if (!(itemTemplate->AllowableClass & player->getClassMask()) && itemTemplate->Bonding == BIND_WHEN_PICKED_UP) | |
| 65 | continue; | |
| 66 | ||
| 67 | // Only display items in vendor lists for the team the player is on | |
| 68 | if ((itemTemplate->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY && player->GetTeam() == ALLIANCE) || | |
| 69 | (itemTemplate->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY && player->GetTeam() == HORDE)) | |
| 70 | continue; | |
| 71 | - | if (!sConditionMgr->IsObjectMeetToConditions(_player, vendor, conditions)) |
| 71 | + | |
| 72 | // Items sold out are not displayed in list | |
| 73 | if (leftInStock == 0) | |
| 74 | continue; | |
| 75 | } | |
| 76 | ||
| 77 | ConditionList conditions = sConditionMgr->GetConditionsForNpcVendorEvent(vendor->GetEntry(), vendorItem->item); | |
| 78 | if (!sConditionMgr->IsObjectMeetToConditions(player, vendor, conditions)) | |
| 79 | - | if (int32 priceMod = _player->GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES)) |
| 79 | + | |
| 80 | TC_LOG_DEBUG("condition", "SendListInventory: conditions not met for creature entry %u item %u", vendor->GetEntry(), vendorItem->item);
| |
| 81 | continue; | |
| 82 | } | |
| 83 | ||
| 84 | int32 price = vendorItem->IsGoldRequired(itemTemplate) ? uint32(floor(itemTemplate->BuyPrice * discountMod)) : 0; | |
| 85 | ||
| 86 | if (int32 priceMod = player->GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES)) | |
| 87 | price -= CalculatePct(price, priceMod); | |
| 88 | */ | |
| 89 | ||
| 90 | ++count; | |
| 91 | itemsData << uint32(slot + 1); // client expects counting to start at 1 | |
| 92 | itemsData << uint32(itemTemplate->MaxDurability); | |
| 93 | ||
| 94 | /* | |
| 95 | if (vendorItem->ExtendedCost != 0) | |
| 96 | - | itemsData << uint32(vendorItem->Type); // 1 is items, 2 is currency |
| 96 | + | |
| 97 | - | itemsData << uint32(price); |
| 97 | + | |
| 98 | itemsData << uint32(vendorItem->ExtendedCost); | |
| 99 | } | |
| 100 | - | itemsData << int32(leftInStock); |
| 100 | + | |
| 101 | */ | |
| 102 | enablers.push_back(1); | |
| 103 | enablers.push_back(1); // unk bit | |
| 104 | ||
| 105 | itemsData << uint32(vendorItems[slot]); | |
| 106 | itemsData << uint32(1); // 1 is items, 2 is currency | |
| 107 | itemsData << uint32(0); | |
| 108 | itemsData << uint32(itemTemplate->DisplayInfoID); | |
| 109 | // if (!unk "enabler") data << uint32(something); | |
| 110 | itemsData << int32(0xFFFFFFFF); | |
| 111 | itemsData << uint32(itemTemplate->BuyCount); | |
| 112 | } | |
| 113 | /* | |
| 114 | else if (vendorItem->Type == ITEM_VENDOR_TYPE_CURRENCY) | |
| 115 | {
| |
| 116 | CurrencyTypesEntry const* currencyTemplate = sCurrencyTypesStore.LookupEntry(vendorItem->item); | |
| 117 | if (!currencyTemplate) | |
| 118 | continue; | |
| 119 | ||
| 120 | if (vendorItem->ExtendedCost == 0) | |
| 121 | continue; // there's no price defined for currencies, only extendedcost is used | |
| 122 | ||
| 123 | ++count; | |
| 124 | itemsData << uint32(slot + 1); // client expects counting to start at 1 | |
| 125 | itemsData << uint32(0); // max durability | |
| 126 | ||
| 127 | if (vendorItem->ExtendedCost != 0) | |
| 128 | {
| |
| 129 | enablers.push_back(0); | |
| 130 | itemsData << uint32(vendorItem->ExtendedCost); | |
| 131 | } | |
| 132 | else | |
| 133 | enablers.push_back(1); | |
| 134 | ||
| 135 | enablers.push_back(1); // unk bit | |
| 136 | ||
| 137 | itemsData << uint32(vendorItem->item); | |
| 138 | itemsData << uint32(vendorItem->Type); // 1 is items, 2 is currency | |
| 139 | itemsData << uint32(0); // price, only seen currency types that have Extended cost | |
| 140 | itemsData << uint32(0); // displayId | |
| 141 | // if (!unk "enabler") data << uint32(something); | |
| 142 | itemsData << int32(-1); | |
| 143 | itemsData << uint32(vendorItem->maxcount); | |
| 144 | } | |
| 145 | */ | |
| 146 | // else error | |
| 147 | } | |
| 148 | ||
| 149 | ObjectGuid guid = vendorGuid; | |
| 150 | ||
| 151 | WorldPacket data(SMSG_LIST_INVENTORY, 12 + itemsData.size()); | |
| 152 | ||
| 153 | data.WriteBit(guid[1]); | |
| 154 | data.WriteBit(guid[0]); | |
| 155 | ||
| 156 | data.WriteBits(count, 21); // item count | |
| 157 | ||
| 158 | data.WriteBit(guid[3]); | |
| 159 | data.WriteBit(guid[6]); | |
| 160 | data.WriteBit(guid[5]); | |
| 161 | data.WriteBit(guid[2]); | |
| 162 | data.WriteBit(guid[7]); | |
| 163 | ||
| 164 | for (std::vector<bool>::const_iterator itr = enablers.begin(); itr != enablers.end(); ++itr) | |
| 165 | data.WriteBit(*itr); | |
| 166 | ||
| 167 | data.WriteBit(guid[4]); | |
| 168 | ||
| 169 | data.FlushBits(); | |
| 170 | data.append(itemsData); | |
| 171 | ||
| 172 | - | SendPacket(&data); |
| 172 | + | |
| 173 | data.WriteByteSeq(guid[4]); | |
| 174 | data.WriteByteSeq(guid[1]); | |
| 175 | data.WriteByteSeq(guid[0]); | |
| 176 | data.WriteByteSeq(guid[6]); | |
| 177 | ||
| 178 | data << uint8(count == 0); // unk byte, item count 0: 1, item count != 0: 0 or some "random" value below 300 | |
| 179 | ||
| 180 | data.WriteByteSeq(guid[2]); | |
| 181 | data.WriteByteSeq(guid[3]); | |
| 182 | data.WriteByteSeq(guid[7]); | |
| 183 | ||
| 184 | player->GetSession()->SendPacket(&data); | |
| 185 | } |