Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_LIST_INVENTORY");
- Creature* vendor = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR);
- if (!vendor)
- {
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: SendListInventory - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(vendorGuid)));
- _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, 0, 0);
- return;
- }
- // remove fake death
- if (GetPlayer()->HasUnitState(UNIT_STAT_DIED))
- GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
- // Stop the npc if moving
- if (vendor->HasUnitState(UNIT_STAT_MOVING))
- vendor->StopMoving();
- uint8 bytes[8] = { };
- *(uint64*)bytes = vendorGuid;
- VendorItemData const* items = vendor->GetVendorItems();
- if (!items)
- {
- WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + 1);
- data.WriteByteMask(bytes[5]);
- data.WriteByteMask(bytes[6]);
- data.WriteByteMask(bytes[1]);
- data.WriteByteMask(bytes[2]);
- data.WriteByteMask(bytes[3]);
- data.WriteByteMask(bytes[0]);
- data.WriteByteMask(bytes[7]);
- data.WriteByteMask(bytes[4]);
- data.WriteByteSeq(bytes[2]);
- data.WriteByteSeq(bytes[3]);
- data << uint8(0); // count == 0, next will be error code
- data << uint8(0xA0); // Only seen 0xA0 (160) so far ( should we send 0 here?)
- data.WriteByteSeq(bytes[4]);
- data.WriteByteSeq(bytes[7]);
- data.WriteByteSeq(bytes[6]);
- SendPacket(&data);
- return;
- }
- uint8 itemCount = items->GetItemCount();
- uint8 count = 0;
- WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + itemCount * 8 * 4);
- data.WriteByteMask(bytes[5]);
- data.WriteByteMask(bytes[6]);
- data.WriteByteMask(bytes[1]);
- data.WriteByteMask(bytes[2]);
- data.WriteByteMask(bytes[3]);
- data.WriteByteMask(bytes[0]);
- data.WriteByteMask(bytes[7]);
- data.WriteByteMask(bytes[4]);
- data.WriteByteSeq(bytes[2]);
- data.WriteByteSeq(bytes[3]);
- size_t countPos = data.wpos();
- data << uint32(count);
- data.WriteByteSeq(bytes[5]);
- data.WriteByteSeq(bytes[0]);
- data.WriteByteSeq(bytes[1]);
- data << uint8(0xA0); // Only seen 0xA0 (160) so far
- data.WriteByteSeq(bytes[4]);
- data.WriteByteSeq(bytes[7]);
- data.WriteByteSeq(bytes[6]);
- float discountMod = _player->GetReputationPriceDiscount(vendor);
- for (uint8 slot = 0; slot < itemCount; ++slot)
- {
- if (VendorItem const* item = items->GetItem(slot))
- {
- if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(item->item))
- {
- if (!(itemTemplate->AllowableClass & _player->getClassMask()) && itemTemplate->Bonding == BIND_WHEN_PICKED_UP && !_player->isGameMaster())
- continue;
- // Only display items in vendor lists for the team the
- // player is on. If GM on, display all items.
- if (!_player->isGameMaster() && ((itemTemplate->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY && _player->GetTeam() == ALLIANCE) || (itemTemplate->Flags2 == ITEM_FLAGS_EXTRA_ALLIANCE_ONLY && _player->GetTeam() == HORDE)))
- continue;
- // Items sold out are not displayed in list
- uint32 leftInStock = !item->maxcount ? 0xFFFFFFFF : vendor->GetVendorItemCurrentCount(item);
- if (!_player->isGameMaster() && !leftInStock)
- continue;
- // reputation discount
- int32 price = item->IsGoldRequired(itemTemplate) ? uint32(floor(itemTemplate->BuyPrice * discountMod)) : 0;
- data << uint32(itemTemplate->MaxDurability);
- data << uint32(slot + 1); // client expects counting to start at 1
- data << uint32(item->item);
- data << uint32(0);
- data << uint32(itemTemplate->DisplayInfoID);
- data << uint32(leftInStock);
- data << uint32(itemTemplate->BuyCount);
- data << uint32(item->ExtendedCost);
- data << uint32(1);
- data << uint32(price);
- }
- }
- }
- if (count == 0)
- {
- SendPacket(&data);
- return;
- }
- data.put<uint32>(countPos, count);
- SendPacket(&data);
Add Comment
Please, Sign In to add comment