[8483] Implement glyph 43361.
[getmangos.git] / src / game / AuctionHouseHandler.cpp
blob80b3dee84002c71c296fcb13be275729db3817ef
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "WorldPacket.h"
20 #include "WorldSession.h"
21 #include "Opcodes.h"
22 #include "Log.h"
23 #include "World.h"
24 #include "ObjectMgr.h"
25 #include "Player.h"
26 #include "UpdateMask.h"
27 #include "AuctionHouseMgr.h"
28 #include "Util.h"
30 //please DO NOT use iterator++, because it is slower than ++iterator!!!
31 //post-incrementation is always slower than pre-incrementation !
33 //void called when player click on auctioneer npc
34 void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
36 uint64 guid; //NPC guid
37 recv_data >> guid;
39 Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER);
40 if (!unit)
42 sLog.outDebug( "WORLD: HandleAuctionHelloOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
43 return;
46 // remove fake death
47 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
48 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
50 SendAuctionHello(guid, unit);
53 //this void causes that auction window is opened
54 void WorldSession::SendAuctionHello( uint64 guid, Creature* unit )
56 AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction());
57 if(!ahEntry)
58 return;
60 WorldPacket data( MSG_AUCTION_HELLO, 12 );
61 data << (uint64) guid;
62 data << (uint32) ahEntry->houseId;
63 SendPacket( &data );
66 //call this method when player bids, creates, or deletes auction
67 void WorldSession::SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError )
69 WorldPacket data( SMSG_AUCTION_COMMAND_RESULT, 16 );
70 data << auctionId;
71 data << Action;
72 data << ErrorCode;
73 if ( !ErrorCode && Action )
74 data << bidError; //when bid, then send 0, once...
75 SendPacket(&data);
78 //this function sends notification, if bidder is online
79 void WorldSession::SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template)
81 WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8*4));
82 data << uint32(location);
83 data << uint32(auctionId);
84 data << uint64(bidder);
85 data << uint32(bidSum);
86 data << uint32(diff);
87 data << uint32(item_template);
88 data << uint32(0);
89 SendPacket(&data);
92 //this void causes on client to display: "Your auction sold"
93 void WorldSession::SendAuctionOwnerNotification( AuctionEntry* auction)
95 WorldPacket data(SMSG_AUCTION_OWNER_NOTIFICATION, (7*4));
96 data << auction->Id;
97 data << auction->bid;
98 data << (uint32) 0; //unk
99 data << (uint32) 0; //unk
100 data << (uint32) 0; //unk
101 data << auction->item_template;
102 data << (uint32) 0; //unk
103 SendPacket(&data);
106 //this function sends mail to old bidder
107 void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPrice)
109 uint64 oldBidder_guid = MAKE_NEW_GUID(auction->bidder,0, HIGHGUID_PLAYER);
110 Player *oldBidder = objmgr.GetPlayer(oldBidder_guid);
112 uint32 oldBidder_accId = 0;
113 if(!oldBidder)
114 oldBidder_accId = objmgr.GetPlayerAccountIdByGUID(oldBidder_guid);
116 // old bidder exist
117 if(oldBidder || oldBidder_accId)
119 std::ostringstream msgAuctionOutbiddedSubject;
120 msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED;
122 if (oldBidder)
123 oldBidder->GetSession()->SendAuctionBidderNotification( auction->GetHouseId(), auction->Id, _player->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
125 WorldSession::SendMailTo(oldBidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
129 //this function sends mail, when auction is cancelled to old bidder
130 void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )
132 uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
133 Player *bidder = objmgr.GetPlayer(bidder_guid);
135 uint32 bidder_accId = 0;
136 if(!bidder)
137 bidder_accId = objmgr.GetPlayerAccountIdByGUID(bidder_guid);
139 // bidder exist
140 if(bidder || bidder_accId)
142 std::ostringstream msgAuctionCancelledSubject;
143 msgAuctionCancelledSubject << auction->item_template << ":0:" << AUCTION_CANCELLED_TO_BIDDER;
145 WorldSession::SendMailTo(bidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), auction->bidder, msgAuctionCancelledSubject.str(), 0, NULL, auction->bid, 0, MAIL_CHECK_MASK_NONE);
149 //this void creates new auction and adds auction to some auctionhouse
150 void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
152 uint64 auctioneer, item;
153 uint32 etime, bid, buyout;
154 recv_data >> auctioneer >> item;
155 recv_data >> bid >> buyout >> etime;
156 Player *pl = GetPlayer();
158 if (!item || !bid || !etime)
159 return; //check for cheaters
161 Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
162 if (!pCreature)
164 sLog.outDebug( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) );
165 return;
168 AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction());
169 if(!auctionHouseEntry)
171 sLog.outDebug( "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)) );
172 return;
176 // client send time in minutes, convert to common used sec time
177 etime *= MINUTE;
179 // client understand only 3 auction time
180 switch(etime)
182 case 1*MIN_AUCTION_TIME:
183 case 2*MIN_AUCTION_TIME:
184 case 4*MIN_AUCTION_TIME:
185 break;
186 default:
187 return;
190 // remove fake death
191 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
192 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
194 Item *it = pl->GetItemByGuid( item );
195 //do not allow to sell already auctioned items
196 if(auctionmgr.GetAItem(GUID_LOPART(item)))
198 sLog.outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", pl->GetName(), GUID_LOPART(item));
199 SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
200 return;
202 // prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction)
203 if(!it)
205 SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_ITEM_NOT_FOUND);
206 return;
209 if(!it->CanBeTraded())
211 SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
212 return;
215 if (it->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || it->GetUInt32Value(ITEM_FIELD_DURATION))
217 SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
218 return;
221 AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
223 //we have to take deposit :
224 uint32 deposit = auctionmgr.GetAuctionDeposit( auctionHouseEntry, etime, it );
225 if ( pl->GetMoney() < deposit )
227 SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_NOT_ENOUGHT_MONEY);
228 return;
231 if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
233 sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
234 GetPlayerName(),GetAccountId(),it->GetProto()->Name1,it->GetEntry(),it->GetCount());
237 pl->ModifyMoney( -int32(deposit) );
239 uint32 auction_time = uint32(etime * sWorld.getRate(RATE_AUCTION_TIME));
241 AuctionEntry *AH = new AuctionEntry;
242 AH->Id = objmgr.GenerateAuctionID();
243 AH->auctioneer = GUID_LOPART(auctioneer);
244 AH->item_guidlow = GUID_LOPART(item);
245 AH->item_template = it->GetEntry();
246 AH->owner = pl->GetGUIDLow();
247 AH->startbid = bid;
248 AH->bidder = 0;
249 AH->bid = 0;
250 AH->buyout = buyout;
251 AH->expire_time = time(NULL) + auction_time;
252 AH->deposit = deposit;
253 AH->auctionHouseEntry = auctionHouseEntry;
255 sLog.outDetail("selling item %u to auctioneer %u with initial bid %u with buyout %u and with time %u (in sec) in auctionhouse %u", GUID_LOPART(item), GUID_LOPART(auctioneer), bid, buyout, auction_time, AH->GetHouseId());
256 auctionHouse->AddAuction(AH);
258 auctionmgr.AddAItem(it);
259 pl->MoveItemFromInventory( it->GetBagSlot(), it->GetSlot(), true);
261 CharacterDatabase.BeginTransaction();
262 it->DeleteFromInventoryDB();
263 it->SaveToDB(); // recursive and not have transaction guard into self, not in inventiory and can be save standalone
264 AH->SaveToDB();
265 pl->SaveInventoryAndGoldToDB();
266 CharacterDatabase.CommitTransaction();
268 SendAuctionCommandResult(AH->Id, AUCTION_SELL_ITEM, AUCTION_OK);
271 //this function is called when client bids or buys out auction
272 void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
274 uint64 auctioneer;
275 uint32 auctionId;
276 uint32 price;
277 recv_data >> auctioneer;
278 recv_data >> auctionId >> price;
280 if (!auctionId || !price)
281 return; //check for cheaters
283 Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
284 if (!pCreature)
286 sLog.outDebug( "WORLD: HandleAuctionPlaceBid - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) );
287 return;
290 // remove fake death
291 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
292 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
294 AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
296 AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
297 Player *pl = GetPlayer();
299 if( !auction || auction->owner == pl->GetGUIDLow() )
301 //you cannot bid your own auction:
302 SendAuctionCommandResult( 0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR );
303 return;
306 // impossible have online own another character (use this for speedup check in case online owner)
307 Player* auction_owner = objmgr.GetPlayer(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER));
308 if( !auction_owner && objmgr.GetPlayerAccountIdByGUID(MAKE_NEW_GUID(auction->owner, 0, HIGHGUID_PLAYER)) == pl->GetSession()->GetAccountId())
310 //you cannot bid your another character auction:
311 SendAuctionCommandResult( 0, AUCTION_PLACE_BID, CANNOT_BID_YOUR_AUCTION_ERROR );
312 return;
315 // cheating
316 if(price <= auction->bid)
317 return;
319 // price too low for next bid if not buyout
320 if ((price < auction->buyout || auction->buyout == 0) &&
321 price < auction->bid + auction->GetAuctionOutBid())
323 //auction has already higher bid, client tests it!
324 return;
327 if (price > pl->GetMoney())
329 //you don't have enought money!, client tests!
330 //SendAuctionCommandResult(auction->auctionId, AUCTION_PLACE_BID, ???);
331 return;
334 if ((price < auction->buyout) || (auction->buyout == 0))
336 if (auction->bidder > 0)
338 if ( auction->bidder == pl->GetGUIDLow() )
340 pl->ModifyMoney( -int32(price - auction->bid));
342 else
344 // mail to last bidder and return money
345 SendAuctionOutbiddedMail( auction , price );
346 pl->ModifyMoney( -int32(price) );
349 else
351 pl->ModifyMoney( -int32(price) );
353 auction->bidder = pl->GetGUIDLow();
354 auction->bid = price;
355 GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
357 // after this update we should save player's money ...
358 CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
360 SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0 );
362 else
364 //buyout:
365 if (pl->GetGUIDLow() == auction->bidder )
367 pl->ModifyMoney(-int32(auction->buyout - auction->bid));
369 else
371 pl->ModifyMoney(-int32(auction->buyout));
372 if ( auction->bidder ) //buyout for bidded auction ..
374 SendAuctionOutbiddedMail( auction, auction->buyout );
377 auction->bidder = pl->GetGUIDLow();
378 auction->bid = auction->buyout;
379 GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout);
381 auctionmgr.SendAuctionSalePendingMail( auction );
382 auctionmgr.SendAuctionSuccessfulMail( auction );
383 auctionmgr.SendAuctionWonMail( auction );
385 SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK);
387 auctionmgr.RemoveAItem(auction->item_guidlow);
388 auctionHouse->RemoveAuction(auction->Id);
389 auction->DeleteFromDB();
391 delete auction;
393 CharacterDatabase.BeginTransaction();
394 pl->SaveInventoryAndGoldToDB();
395 CharacterDatabase.CommitTransaction();
398 //this void is called when auction_owner cancels his auction
399 void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
401 uint64 auctioneer;
402 uint32 auctionId;
403 recv_data >> auctioneer;
404 recv_data >> auctionId;
405 //sLog.outDebug( "Cancel AUCTION AuctionID: %u", auctionId);
407 Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer,UNIT_NPC_FLAG_AUCTIONEER);
408 if (!pCreature)
410 sLog.outDebug( "WORLD: HandleAuctionRemoveItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)) );
411 return;
414 // remove fake death
415 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
416 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
418 AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
420 AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
421 Player *pl = GetPlayer();
423 if (auction && auction->owner == pl->GetGUIDLow())
425 Item *pItem = auctionmgr.GetAItem(auction->item_guidlow);
426 if (pItem)
428 if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
430 uint32 auctionCut = auction->GetAuctionCut();
431 if ( pl->GetMoney() < auctionCut ) //player doesn't have enough money, maybe message needed
432 return;
433 //some auctionBidderNotification would be needed, but don't know that parts..
434 SendAuctionCancelledToBidderMail( auction );
435 pl->ModifyMoney( -int32(auctionCut) );
437 // Return the item by mail
438 std::ostringstream msgAuctionCanceledOwner;
439 msgAuctionCanceledOwner << auction->item_template << ":0:" << AUCTION_CANCELED;
441 MailItemsInfo mi;
442 mi.AddItem(auction->item_guidlow, auction->item_template, pItem);
444 // item will deleted or added to received mail list
445 WorldSession::SendMailTo(pl, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->GetHouseId(), pl->GetGUIDLow(), msgAuctionCanceledOwner.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
447 else
449 sLog.outError("Auction id: %u has non-existed item (item guid : %u)!!!", auction->Id, auction->item_guidlow);
450 SendAuctionCommandResult( 0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR );
451 return;
454 else
456 SendAuctionCommandResult( 0, AUCTION_CANCEL, AUCTION_INTERNAL_ERROR );
457 //this code isn't possible ... maybe there should be assert
458 sLog.outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId );
459 return;
462 //inform player, that auction is removed
463 SendAuctionCommandResult( auction->Id, AUCTION_CANCEL, AUCTION_OK );
464 // Now remove the auction
465 CharacterDatabase.BeginTransaction();
466 auction->DeleteFromDB();
467 pl->SaveInventoryAndGoldToDB();
468 CharacterDatabase.CommitTransaction();
469 auctionmgr.RemoveAItem( auction->item_guidlow );
470 auctionHouse->RemoveAuction( auction->Id );
471 delete auction;
474 //called when player lists his bids
475 void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
477 uint64 guid; //NPC guid
478 uint32 listfrom; //page of auctions
479 uint32 outbiddedCount; //count of outbidded auctions
481 recv_data >> guid;
482 recv_data >> listfrom; // not used in fact (this list not have page control in client)
483 recv_data >> outbiddedCount;
484 if (recv_data.size() != (16 + outbiddedCount * 4 ))
486 sLog.outError("Client sent bad opcode!!! with count: %u and size : %lu (must be: %u)", outbiddedCount, (unsigned long)recv_data.size(),(16 + outbiddedCount * 4 ));
487 outbiddedCount = 0;
490 Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER);
491 if (!pCreature)
493 sLog.outDebug( "WORLD: HandleAuctionListBidderItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
494 return;
497 // remove fake death
498 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
499 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
501 AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
503 WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) );
504 Player *pl = GetPlayer();
505 data << (uint32) 0; //add 0 as count
506 uint32 count = 0;
507 uint32 totalcount = 0;
508 while ( outbiddedCount > 0) //add all data, which client requires
510 --outbiddedCount;
511 uint32 outbiddedAuctionId;
512 recv_data >> outbiddedAuctionId;
513 AuctionEntry * auction = auctionHouse->GetAuction( outbiddedAuctionId );
514 if ( auction && auction->BuildAuctionInfo(data))
516 ++totalcount;
517 ++count;
521 auctionHouse->BuildListBidderItems(data,pl,count,totalcount);
522 data.put<uint32>( 0, count ); // add count to placeholder
523 data << totalcount;
524 data << (uint32)300; //unk 2.3.0
525 SendPacket(&data);
528 //this void sends player info about his auctions
529 void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
531 uint32 listfrom;
532 uint64 guid;
534 recv_data >> guid;
535 recv_data >> listfrom; // not used in fact (this list not have page control in client)
537 Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER);
538 if (!pCreature)
540 sLog.outDebug( "WORLD: HandleAuctionListOwnerItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
541 return;
544 // remove fake death
545 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
546 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
548 AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
550 WorldPacket data( SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4) );
551 data << (uint32) 0; // amount place holder
553 uint32 count = 0;
554 uint32 totalcount = 0;
556 auctionHouse->BuildListOwnerItems(data,_player,count,totalcount);
557 data.put<uint32>(0, count);
558 data << (uint32) totalcount;
559 data << (uint32) 0;
560 SendPacket(&data);
563 //this void is called when player clicks on search button
564 void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
566 std::string searchedname;
567 uint8 levelmin, levelmax, usable;
568 uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
569 uint64 guid;
571 recv_data >> guid;
572 recv_data >> listfrom; // start, used for page control listing by 50 elements
573 recv_data >> searchedname;
575 recv_data >> levelmin >> levelmax;
576 recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory;
577 recv_data >> quality >> usable;
579 recv_data.read_skip(16); // unknown 16 bytes: 00 07 01 00 00 01 05 00 06 00 09 01 08 00 03 00
581 Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_AUCTIONEER);
582 if (!pCreature)
584 sLog.outDebug( "WORLD: HandleAuctionListItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
585 return;
588 // remove fake death
589 if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
590 GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
592 AuctionHouseObject* auctionHouse = auctionmgr.GetAuctionsMap( pCreature->getFaction() );
594 //sLog.outDebug("Auctionhouse search (GUID: %u TypeId: %u)", , list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
595 // GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
597 WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) );
598 uint32 count = 0;
599 uint32 totalcount = 0;
600 data << (uint32) 0;
602 // converting string that we try to find to lower case
603 std::wstring wsearchedname;
604 if(!Utf8toWStr(searchedname,wsearchedname))
605 return;
607 wstrToLower(wsearchedname);
609 auctionHouse->BuildListAuctionItems(data,_player,
610 wsearchedname, listfrom, levelmin, levelmax, usable,
611 auctionSlotID, auctionMainCategory, auctionSubCategory, quality,
612 count,totalcount);
614 data.put<uint32>(0, count);
615 data << (uint32) totalcount;
616 data << (uint32) 300; // unk 2.3.0 const?
617 SendPacket(&data);
620 void WorldSession::HandleAuctionListPendingSales( WorldPacket & recv_data )
622 sLog.outDebug("CMSG_AUCTION_LIST_PENDING_SALES");
624 recv_data.read_skip<uint64>(); // auctioner guid
626 uint32 count = 0;
628 WorldPacket data(SMSG_AUCTION_LIST_PENDING_SALES, 4);
629 data << uint32(count); // count
630 /*for(uint32 i = 0; i < count; ++i)
632 data << ""; // string
633 data << ""; // string
634 data << uint32(0);
635 data << uint32(0);
636 data << float(0);
638 SendPacket(&data);