rendered paste bodyvoid WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4+1+1+1+4+4+4+4+1);
std::string searchedname, name, FullName;
uint8 levelmin, levelmax, usable, location;
uint32 count, totalcount, listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory,
quality, ItemEnchant;
uint64 guid;
recv_data >> guid;
recv_data >> listfrom;
recv_data >> searchedname;
// recheck with known string size
CHECK_PACKET_SIZE(recv_data,8+4+(searchedname.size()+1)+1+1+4+4+4+4+1);
recv_data >> levelmin >> levelmax;
recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory;
recv_data >> quality >> usable;
Creature *pCreature = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid,UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
{
sLog.outDebug( "WORLD: HandleAuctionListItems - Unit (GUID: %u) not found or you can't
interact with him.", uint32(GUID_LOPART(guid)) );
return;
}
location = AuctioneerFactionToLocation(pCreature->getFaction());
AuctionHouseObject * mAuctions;
mAuctions = objmgr.GetAuctionsMap( location );
//sLog.outDebug("Auctionhouse search guid: " I64FMTD ", list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", guid, listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) );
count = 0;
totalcount = 0;
data << (uint32) 0;
uint8 SubType = NULL;
//pre-load...
std::transform( searchedname.begin(), searchedname.end(), searchedname.begin(), ::tolower );
uint32 RandomPropertiesValidid = sItemRandomPropertiesStore.GetNumRows();
for (AuctionHouseObject::AuctionEntryMap::iterator itr = mAuctions->GetAuctionsBegin();itr != mAuctions->GetAuctionsEnd();++itr)
{
if (totalcount > 299) break;
AuctionEntry *Aentry = itr->second;
Item *item = objmgr.GetAItem(Aentry->item_guid);
if(!item) continue;
ItemPrototype const *proto = item->GetProto();
if(!proto) continue;
if( auctionMainCategory == (0xffffffff) || proto->Class == auctionMainCategory )
{
if( auctionSubCategory == (0xffffffff) || proto->SubClass == auctionSubCategory )
{
if( auctionSlotID == (0xffffffff) || proto->InventoryType == auctionSlotID )
{
if( quality == (0xffffffff) || proto->Quality == quality )
{
if( usable == (0x00) || _player->CanUseItem( item ) == EQUIP_ERR_OK )
{
if( ( levelmin == (0x00) || proto->RequiredLevel >= levelmin ) && ( levelmax == (0x00) || proto->RequiredLevel <= levelmax ) )
{
if(searchedname.empty())
{
totalcount++;
if (totalcount < listfrom) continue;
if (count > 49) continue;
count++;
SendAuctionInfo( data, Aentry);
continue;
}
FullName = "";
FullName += proto->Name1;
ItemEnchant = item->GetItemRandomPropertyId();
if(ItemEnchant)
{ //SantaCl hf036: add Item Enchantmant name support to text search of items.
ItemRandomPropertiesEntry const *rp_data = sItemRandomPropertiesStore.LookupEntry(ItemEnchant);
if(rp_data)
{
FullName += " ";
FullName += rp_data->internalName;
}
}
std::transform( FullName.begin(), FullName.end(), FullName.begin(), ::tolower );
if(FullName.find( searchedname ) == std::string::npos) continue;
totalcount++;
if (totalcount < listfrom) continue;
if (count > 49) continue;
count++;
SendAuctionInfo( data, Aentry);
}
}
}
}
}
}
}
data.put<uint32>(0, count);
data << (uint32) totalcount;
SendPacket(&data);
}