aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLopin <davca.hr@seznam.cz>2011-06-23 21:24:53 +0200
committerLopin <davca.hr@seznam.cz>2011-06-23 21:24:53 +0200
commitabc1aa18a96098a02a3d9f43944e9529c0bce752 (patch)
tree946d09b25b2ccb22ed13d8db1d3d9ac2b5482838 /src
parent36d6ca471115b101ffb62d7cd4b994ba3b6347fd (diff)
parent0ae926e28e9ea913174526b942515eeaec5bf96c (diff)
Merge branch 'master' of https://github.com/TrinityCore/TrinityCore
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/ItemHandler.cpp67
-rwxr-xr-xsrc/server/game/Server/WorldSession.h2
2 files changed, 39 insertions, 30 deletions
diff --git a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
index db2c76b422a..97e17f487be 100755
--- a/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/ItemHandler.cpp
@@ -718,12 +718,12 @@ void WorldSession::HandleListInventoryOpcode(WorldPacket & recv_data)
SendListInventory(guid);
}
-void WorldSession::SendListInventory(uint64 vendorguid)
+void WorldSession::SendListInventory(uint64 vendorGuid)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_LIST_INVENTORY");
- Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR);
- if (!pCreature)
+ 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);
@@ -735,56 +735,65 @@ void WorldSession::SendListInventory(uint64 vendorguid)
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
// Stop the npc if moving
- if (pCreature->HasUnitState(UNIT_STAT_MOVING))
- pCreature->StopMoving();
+ if (vendor->HasUnitState(UNIT_STAT_MOVING))
+ vendor->StopMoving();
- VendorItemData const* vItems = pCreature->GetVendorItems();
- if (!vItems)
+ VendorItemData const* items = vendor->GetVendorItems();
+ if (!items)
{
- WorldPacket data(SMSG_LIST_INVENTORY, (8+1+1));
- data << uint64(vendorguid);
- data << uint8(0); // count==0, next will be error code
+ WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + 1);
+ data << uint64(vendorGuid);
+ data << uint8(0); // count == 0, next will be error code
data << uint8(0); // "Vendor has no inventory"
SendPacket(&data);
return;
}
- uint8 numitems = vItems->GetItemCount();
+ uint8 itemCount = items->GetItemCount();
uint8 count = 0;
- WorldPacket data(SMSG_LIST_INVENTORY, (8+1+numitems*8*4));
- data << uint64(vendorguid);
+ WorldPacket data(SMSG_LIST_INVENTORY, 8 + 1 + itemCount * 8 * 4);
+ data << uint64(vendorGuid);
- size_t count_pos = data.wpos();
+ size_t countPos = data.wpos();
data << uint8(count);
- float discountMod = _player->GetReputationPriceDiscount(pCreature);
+ float discountMod = _player->GetReputationPriceDiscount(vendor);
- for (uint8 vendorslot = 0; vendorslot < numitems; ++vendorslot )
+ for (uint8 slot = 0; slot < itemCount; ++slot)
{
- if (VendorItem const* crItem = vItems->GetItem(vendorslot))
+ if (VendorItem const* item = items->GetItem(slot))
{
- if (ItemTemplate const *pProto = sObjectMgr->GetItemTemplate(crItem->item))
+ if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(item->item))
{
- if ((pProto->AllowableClass & _player->getClassMask()) == 0 && pProto->Bonding == BIND_WHEN_PICKED_UP && !_player->isGameMaster())
+ 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() && ((pProto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY && _player->GetTeam() == ALLIANCE) || (pProto->Flags2 == ITEM_FLAGS_EXTRA_ALLIANCE_ONLY && _player->GetTeam() == HORDE)))
+ 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 (!leftInStock)
continue;
+
+ if (itemTemplate->Class == ITEM_CLASS_QUEST && !_player->HasQuestForItem(item->item))
+ continue;
+
++count;
// reputation discount
- int32 price = crItem->IsGoldRequired(pProto) ? uint32(floor(pProto->BuyPrice * discountMod)) : 0;
+ int32 price = item->IsGoldRequired(itemTemplate) ? uint32(floor(itemTemplate->BuyPrice * discountMod)) : 0;
- data << uint32(vendorslot+1); // client expects counting to start at 1
- data << uint32(crItem->item);
- data << uint32(pProto->DisplayInfoID);
- data << int32(crItem->maxcount <= 0 ? 0xFFFFFFFF : pCreature->GetVendorItemCurrentCount(crItem));
+ data << uint32(slot + 1); // client expects counting to start at 1
+ data << uint32(item->item);
+ data << uint32(itemTemplate->DisplayInfoID);
+ data << int32(leftInStock);
data << uint32(price);
- data << uint32(pProto->MaxDurability);
- data << uint32(pProto->BuyCount);
- data << uint32(crItem->ExtendedCost);
+ data << uint32(itemTemplate->MaxDurability);
+ data << uint32(itemTemplate->BuyCount);
+ data << uint32(item->ExtendedCost);
}
}
}
@@ -796,7 +805,7 @@ void WorldSession::SendListInventory(uint64 vendorguid)
return;
}
- data.put<uint8>(count_pos, count);
+ data.put<uint8>(countPos, count);
SendPacket(&data);
}
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index eb1fd068bc3..f45ee79847c 100755
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -284,7 +284,7 @@ class WorldSession
void SendTrainerList(uint64 guid);
void SendTrainerList(uint64 guid, const std::string& strTitle);
- void SendListInventory(uint64 guid);
+ void SendListInventory(uint64 vendorGuid);
void SendShowBank(uint64 guid);
void SendTabardVendorActivate(uint64 guid);
void SendSpiritResurrect();