1 #include "AuctionHouseBot.h"
3 #include "Config/ConfigEnv.h"
4 #include "Database/DatabaseEnv.h"
8 #include "AuctionHouseMgr.h"
11 #include "WorldSession.h"
18 static bool debug_Out
= sConfig
.GetBoolDefault("AuctionHouseBot.DEBUG", false);
20 static vector
<uint32
> npcItems
;
21 static vector
<uint32
> lootItems
;
22 static vector
<uint32
> greyTradeGoodsBin
;
23 static vector
<uint32
> whiteTradeGoodsBin
;
24 static vector
<uint32
> greenTradeGoodsBin
;
25 static vector
<uint32
> blueTradeGoodsBin
;
26 static vector
<uint32
> purpleTradeGoodsBin
;
27 static vector
<uint32
> orangeTradeGoodsBin
;
28 static vector
<uint32
> yellowTradeGoodsBin
;
29 static vector
<uint32
> greyItemsBin
;
30 static vector
<uint32
> whiteItemsBin
;
31 static vector
<uint32
> greenItemsBin
;
32 static vector
<uint32
> blueItemsBin
;
33 static vector
<uint32
> purpleItemsBin
;
34 static vector
<uint32
> orangeItemsBin
;
35 static vector
<uint32
> yellowItemsBin
;
37 static bool AHBSeller
= 0;
38 static bool AHBBuyer
= 0;
40 static bool Vendor_Items
= 0;
41 static bool Loot_Items
= 0;
42 static bool Other_Items
= 0;
44 static bool No_Bind
= 0;
45 static bool Bind_When_Picked_Up
= 0;
46 static bool Bind_When_Equipped
= 0;
47 static bool Bind_When_Use
= 0;
48 static bool Bind_Quest_Item
= 0;
50 static AHBConfig AllianceConfig
= AHBConfig(2);
51 static AHBConfig HordeConfig
= AHBConfig(6);
52 static AHBConfig NeutralConfig
= AHBConfig(7);
57 ///////////////////////////////////////////////////////////////////////////////
59 ///////////////////////////////////////////////////////////////////////////////
60 static inline uint32
minValue(uint32 a
, uint32 b
)
62 return a
<= b
? a
: b
;
65 ///////////////////////////////////////////////////////////////////////////////
67 ///////////////////////////////////////////////////////////////////////////////
68 static void addNewAuctions(Player
*AHBplayer
, AHBConfig
*config
)
72 AuctionHouseEntry
const* ahEntry
= auctionmgr
.GetAuctionHouseEntry(config
->GetAHFID());
73 AuctionHouseObject
* auctionHouse
= auctionmgr
.GetAuctionsMap(config
->GetAHFID());
75 uint32 minItems
= config
->GetMinItems();
76 uint32 maxItems
= config
->GetMaxItems();
77 uint32 auctions
= auctionHouse
->Getcount();
78 uint32 AuctioneerGUID
= 0;
79 switch (config
->GetAHID()){
81 AuctioneerGUID
= 79707; //Human in stormwind.
83 AuctioneerGUID
= 4656; //orc in Orgrimmar
85 AuctioneerGUID
= 23442; //goblin in GZ
87 AuctioneerGUID
= 23442; //default to neutral 7
90 if (auctions
>= minItems
)
92 if (auctions
<= maxItems
)
94 if ((maxItems
- auctions
) > ItemsPerCycle
)
95 items
= ItemsPerCycle
;
97 items
= (maxItems
- auctions
);
99 uint32 greyTGcount
= config
->GetPercents(AHB_GREY_TG
);
100 uint32 whiteTGcount
= config
->GetPercents(AHB_WHITE_TG
);
101 uint32 greenTGcount
= config
->GetPercents(AHB_GREEN_TG
);
102 uint32 blueTGcount
= config
->GetPercents(AHB_BLUE_TG
);
103 uint32 purpleTGcount
= config
->GetPercents(AHB_PURPLE_TG
);
104 uint32 orangeTGcount
= config
->GetPercents(AHB_ORANGE_TG
);
105 uint32 yellowTGcount
= config
->GetPercents(AHB_YELLOW_TG
);
106 uint32 greyIcount
= config
->GetPercents(AHB_GREY_I
);
107 uint32 whiteIcount
= config
->GetPercents(AHB_WHITE_I
);
108 uint32 greenIcount
= config
->GetPercents(AHB_GREEN_I
);
109 uint32 blueIcount
= config
->GetPercents(AHB_BLUE_I
);
110 uint32 purpleIcount
= config
->GetPercents(AHB_PURPLE_I
);
111 uint32 orangeIcount
= config
->GetPercents(AHB_ORANGE_I
);
112 uint32 yellowIcount
= config
->GetPercents(AHB_YELLOW_I
);
113 uint32 total
= greyTGcount
+ whiteTGcount
+ greenTGcount
+ blueTGcount
114 + purpleTGcount
+ orangeTGcount
+ yellowTGcount
115 + whiteIcount
+ greenIcount
+ blueIcount
+ purpleIcount
116 + orangeIcount
+ yellowIcount
;
118 uint32 greyTGoods
= 0;
119 uint32 whiteTGoods
= 0;
120 uint32 greenTGoods
= 0;
121 uint32 blueTGoods
= 0;
122 uint32 purpleTGoods
= 0;
123 uint32 orangeTGoods
= 0;
124 uint32 yellowTGoods
= 0;
126 uint32 greyItems
= 0;
127 uint32 whiteItems
= 0;
128 uint32 greenItems
= 0;
129 uint32 blueItems
= 0;
130 uint32 purpleItems
= 0;
131 uint32 orangeItems
= 0;
132 uint32 yellowItems
= 0;
134 for (AuctionHouseObject::AuctionEntryMap::iterator itr
= auctionHouse
->GetAuctionsBegin();itr
!= auctionHouse
->GetAuctionsEnd();++itr
)
136 AuctionEntry
*Aentry
= itr
->second
;
137 Item
*item
= auctionmgr
.GetAItem(Aentry
->item_guidlow
);
140 ItemPrototype
const *prototype
= item
->GetProto();
143 switch (prototype
->Quality
)
146 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
153 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
160 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
167 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
174 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
181 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
188 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
197 // only insert a few at a time, so as not to peg the processor
198 for (uint32 cnt
= 1;cnt
<= items
;cnt
++)
203 uint32 choice
= urand(0, 13);
208 if ((greyItemsBin
.size() > 0) && (greyItems
< greyIcount
))
210 itemID
= greyItemsBin
[urand(0, greyItemsBin
.size() - 1)];
217 if ((whiteItemsBin
.size() > 0) && (whiteItems
< whiteIcount
))
219 itemID
= whiteItemsBin
[urand(0, whiteItemsBin
.size() - 1)];
226 if ((greenItemsBin
.size() > 0) && (greenItems
< greenIcount
))
228 itemID
= greenItemsBin
[urand(0, greenItemsBin
.size() - 1)];
235 if ((blueItemsBin
.size() > 0) && (blueItems
< blueIcount
))
237 itemID
= blueItemsBin
[urand(0, blueItemsBin
.size() - 1)];
244 if ((purpleItemsBin
.size() > 0) && (purpleItems
< purpleIcount
))
246 itemID
= purpleItemsBin
[urand(0, purpleItemsBin
.size() - 1)];
253 if ((orangeItemsBin
.size() > 0) && (orangeItems
< orangeIcount
))
255 itemID
= orangeItemsBin
[urand(0, orangeItemsBin
.size() - 1)];
262 if ((yellowItemsBin
.size() > 0) && (yellowItems
< yellowIcount
))
264 itemID
= yellowItemsBin
[urand(0, yellowItemsBin
.size() - 1)];
271 if ((greyTradeGoodsBin
.size() > 0) && (greyTGoods
< greyTGcount
))
273 itemID
= whiteTradeGoodsBin
[urand(0, whiteTradeGoodsBin
.size() - 1)];
280 if ((whiteTradeGoodsBin
.size() > 0) && (whiteTGoods
< whiteTGcount
))
282 itemID
= whiteTradeGoodsBin
[urand(0, whiteTradeGoodsBin
.size() - 1)];
289 if ((greenTradeGoodsBin
.size() > 0) && (greenTGoods
< greenTGcount
))
291 itemID
= greenTradeGoodsBin
[urand(0, greenTradeGoodsBin
.size() - 1)];
298 if ((blueTradeGoodsBin
.size() > 0) && (blueTGoods
< blueTGcount
))
300 itemID
= blueTradeGoodsBin
[urand(0, blueTradeGoodsBin
.size() - 1)];
307 if ((purpleTradeGoodsBin
.size() > 0) && (purpleTGoods
< purpleTGcount
))
309 itemID
= purpleTradeGoodsBin
[urand(0, purpleTradeGoodsBin
.size() - 1)];
316 if ((orangeTradeGoodsBin
.size() > 0) && (orangeTGoods
< orangeTGcount
))
318 itemID
= orangeTradeGoodsBin
[urand(0, orangeTradeGoodsBin
.size() - 1)];
325 if ((yellowTradeGoodsBin
.size() > 0) && (yellowTGoods
< yellowTGcount
))
327 itemID
= yellowTradeGoodsBin
[urand(0, yellowTradeGoodsBin
.size() - 1)];
339 ItemPrototype
const* prototype
= objmgr
.GetItemPrototype(itemID
);
340 if (prototype
== NULL
)
342 sLog
.outString("AuctionHouseBot: Huh?!?! prototype == NULL");
346 Item
* item
= Item::CreateItem(itemID
, 1, AHBplayer
);
347 item
->AddToUpdateQueueOf(AHBplayer
);
350 sLog
.outString("AuctionHouseBot: Item::CreateItem() returned NULL");
354 uint32 randomPropertyId
= Item::GenerateItemRandomPropertyId(itemID
);
355 if (randomPropertyId
!= 0)
356 item
->SetItemRandomProperties(randomPropertyId
);
360 uint32 stackCount
= urand(1, item
->GetMaxStackCount());
365 buyoutPrice
= prototype
->SellPrice
* item
->GetCount();
368 buyoutPrice
= prototype
->BuyPrice
* item
->GetCount();
375 switch (prototype
->Quality
)
378 if (config
->GetMaxStack(AHB_GREY
) != 0)
380 stackCount
= urand(1, minValue(item
->GetMaxStackCount(), config
->GetMaxStack(AHB_GREY
)));
382 buyoutPrice
*= urand(config
->GetMinPrice(AHB_GREY
), config
->GetMaxPrice(AHB_GREY
)) * stackCount
;
384 bidPrice
= buyoutPrice
* urand(config
->GetMinBidPrice(AHB_GREY
), config
->GetMaxBidPrice(AHB_GREY
));
389 if (config
->GetMaxStack(AHB_WHITE
) != 0)
391 stackCount
= urand(1, minValue(item
->GetMaxStackCount(), config
->GetMaxStack(AHB_WHITE
)));
393 buyoutPrice
*= urand(config
->GetMinPrice(AHB_WHITE
), config
->GetMaxPrice(AHB_WHITE
)) * stackCount
;
395 bidPrice
= buyoutPrice
* urand(config
->GetMinBidPrice(AHB_WHITE
), config
->GetMaxBidPrice(AHB_WHITE
));
400 if (config
->GetMaxStack(AHB_GREEN
) != 0)
402 stackCount
= urand(1, minValue(item
->GetMaxStackCount(), config
->GetMaxStack(AHB_GREEN
)));
404 buyoutPrice
*= urand(config
->GetMinPrice(AHB_GREEN
), config
->GetMaxPrice(AHB_GREEN
)) * stackCount
;
406 bidPrice
= buyoutPrice
* urand(config
->GetMinBidPrice(AHB_GREEN
), config
->GetMaxBidPrice(AHB_GREEN
));
411 if (config
->GetMaxStack(AHB_BLUE
) != 0)
413 stackCount
= urand(1, minValue(item
->GetMaxStackCount(), config
->GetMaxStack(AHB_BLUE
)));
415 buyoutPrice
*= urand(config
->GetMinPrice(AHB_BLUE
), config
->GetMaxPrice(AHB_BLUE
)) * stackCount
;
417 bidPrice
= buyoutPrice
* urand(config
->GetMinBidPrice(AHB_BLUE
), config
->GetMaxBidPrice(AHB_BLUE
));
422 if (config
->GetMaxStack(AHB_PURPLE
) != 0)
424 stackCount
= urand(1, minValue(item
->GetMaxStackCount(), config
->GetMaxStack(AHB_PURPLE
)));
426 buyoutPrice
*= urand(config
->GetMinPrice(AHB_PURPLE
), config
->GetMaxPrice(AHB_PURPLE
)) * stackCount
;
428 bidPrice
= buyoutPrice
* urand(config
->GetMinBidPrice(AHB_PURPLE
), config
->GetMaxBidPrice(AHB_PURPLE
));
432 if (config
->GetMaxStack(AHB_ORANGE
) != 0)
434 stackCount
= urand(1, minValue(item
->GetMaxStackCount(), config
->GetMaxStack(AHB_ORANGE
)));
436 buyoutPrice
*= urand(config
->GetMinPrice(AHB_ORANGE
), config
->GetMaxPrice(AHB_ORANGE
)) * stackCount
;
438 bidPrice
= buyoutPrice
* urand(config
->GetMinBidPrice(AHB_ORANGE
), config
->GetMaxBidPrice(AHB_ORANGE
));
442 if (config
->GetMaxStack(AHB_YELLOW
) != 0)
444 stackCount
= urand(1, minValue(item
->GetMaxStackCount(), config
->GetMaxStack(AHB_YELLOW
)));
446 buyoutPrice
*= urand(config
->GetMinPrice(AHB_YELLOW
), config
->GetMaxPrice(AHB_YELLOW
)) * stackCount
;
448 bidPrice
= buyoutPrice
* urand(config
->GetMinBidPrice(AHB_YELLOW
), config
->GetMaxBidPrice(AHB_YELLOW
));
453 item
->SetCount(stackCount
);
455 AuctionEntry
* auctionEntry
= new AuctionEntry
;
456 auctionEntry
->Id
= objmgr
.GenerateAuctionID();
457 auctionEntry
->auctioneer
= AuctioneerGUID
;
458 auctionEntry
->item_guidlow
= item
->GetGUIDLow();
459 auctionEntry
->item_template
= item
->GetEntry();
460 auctionEntry
->owner
= AHBplayer
->GetGUIDLow();
461 auctionEntry
->startbid
= bidPrice
;
462 auctionEntry
->buyout
= buyoutPrice
;
463 auctionEntry
->bidder
= 0;
464 auctionEntry
->bid
= 0;
465 auctionEntry
->deposit
= 0;
466 auctionEntry
->expire_time
= (time_t) (urand(config
->GetMinTime(), config
->GetMaxTime()) * 60 * 60 + time(NULL
));
467 auctionEntry
->auctionHouseEntry
= ahEntry
;
469 item
->RemoveFromUpdateQueueOf(AHBplayer
);
470 auctionmgr
.AddAItem(item
);
471 auctionHouse
->AddAuction(auctionEntry
);
472 auctionEntry
->SaveToDB();
476 static void addNewAuctionBuyerBotBid(Player
*AHBplayer
, AHBConfig
*config
, WorldSession
*session
)
481 // Fetches content of selected AH
482 AuctionHouseObject
* auctionHouse
= auctionmgr
.GetAuctionsMap(config
->GetAHFID());
483 AuctionHouseObject::AuctionEntryMap::iterator itr
;
485 itr
= auctionHouse
->GetAuctionsBegin();
486 vector
<uint32
> possibleBids
;
488 while (itr
!= auctionHouse
->GetAuctionsEnd())
490 AuctionHouseObject::AuctionEntryMap::iterator tmp
= itr
;
492 // Check if the auction is ours
493 // if it is, we skip this iteration.
494 if(tmp
->second
->owner
== AHBplayerGUID
)
498 // Check that we haven't bidded in this auction already.
499 if(tmp
->second
->bidder
!= AHBplayerGUID
)
501 uint32 tmpdata
= tmp
->second
->Id
;
502 possibleBids
.push_back(tmpdata
);
506 uint32 bids
= config
->GetBidsPerInterval();
507 for (uint32 count
= 0; count
< bids
; ++count
)
509 // Do we have anything to bid? If not, stop here.
510 if(possibleBids
.empty())
513 // Choose random auction from possible auctions
514 uint32 vectorPos
= urand(0, possibleBids
.size() - 1);
515 vector
<uint32
>::iterator iter
= possibleBids
.begin();
516 advance(iter
, vectorPos
);
517 // from auctionhousehandler.cpp, creates auction pointer & player pointer
518 AuctionEntry
* auction
= auctionHouse
->GetAuction(*iter
);
519 // Erase the auction from the vector to prevent bidding on item in next itteration.
520 possibleBids
.erase(iter
);
522 // get exact item information
523 Item
*pItem
= auctionmgr
.GetAItem(auction
->item_guidlow
);
526 sLog
.outError("Item doesn't exists, perhaps bought already?");
530 // get item prototype
531 ItemPrototype
const* prototype
= objmgr
.GetItemPrototype(auction
->item_template
);
533 // check which price we have to use, startbid or if it is bidded already
536 sLog
.outError("Auction Number: %u", auction
->Id
);
537 sLog
.outError("Item Template: %u", auction
->item_template
);
538 sLog
.outError("Buy Price: %u", prototype
->BuyPrice
);
539 sLog
.outError("Sell Price: %u", prototype
->SellPrice
);
540 sLog
.outError("Quality: %u", prototype
->Quality
);
546 currentprice
= auction
->bid
;
548 {sLog
.outError("Current Price: %u", auction
->bid
);}
552 currentprice
= auction
->startbid
;
554 {sLog
.outError("Current Price: %u", auction
->startbid
);}
557 // Prepare portion from maximum bid
558 uint32 tmprate2
= urand(0, 100);
559 double tmprate
= static_cast<double>(tmprate2
);
560 double bidrate
= tmprate
/ 100;
561 long double bidMax
= 0;
564 sLog
.outError("tmprate: %f", tmprate
);
565 sLog
.outError("bidrate: %f", bidrate
);
568 // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
573 switch (prototype
->Quality
)
576 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREY
))
577 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREY
);
580 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_WHITE
))
581 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_WHITE
);
584 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREEN
))
585 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREEN
);
588 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_BLUE
))
589 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_BLUE
);
592 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_PURPLE
))
593 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_PURPLE
);
595 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_ORANGE
))
596 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_ORANGE
);
598 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_YELLOW
))
599 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_YELLOW
);
602 // quality is something it shouldn't be, let's get out of here
604 sLog
.outError("bidMax(fail): %f", bidMax
);
611 switch (prototype
->Quality
)
614 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREY
))
615 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREY
);
618 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_WHITE
))
619 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_WHITE
);
622 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREEN
))
623 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREEN
);
626 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_BLUE
))
627 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_BLUE
);
630 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_PURPLE
))
631 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_PURPLE
);
633 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_ORANGE
))
634 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_ORANGE
);
636 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_YELLOW
))
637 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_YELLOW
);
640 // quality is something it shouldn't be, let's get out of here
642 sLog
.outError("bidMax(fail): %f", bidMax
);
653 sLog
.outError("bidMax(succeed): %f", bidMax
);
655 // check some special items, and do recalculating to their prices
656 switch (prototype
->Class
)
668 // quality check failed to get bidmax, let's get out of here
673 long double bidvalue
= currentprice
+ ( (bidMax
- currentprice
) * bidrate
);
675 uint32 bidprice
= static_cast<uint32
>(bidvalue
);
678 sLog
.outError("bidprice: %u", bidprice
);
679 sLog
.outError("bidvalue: %f", bidvalue
);
682 // Check our bid is high enough to be valid. If not, correct it to minimum.
683 if((currentprice
+ auction
->GetAuctionOutBid()) > bidprice
)
685 bidprice
= currentprice
+ auction
->GetAuctionOutBid();
687 sLog
.outError("bidprice(>): %u", bidprice
);
690 // Check wether we do normal bid, or buyout
691 if ((bidprice
< auction
->buyout
) || (auction
->buyout
== 0))
694 if (auction
->bidder
> 0)
696 if ( auction
->bidder
== AHBplayer
->GetGUIDLow() )
698 //pl->ModifyMoney( -int32(price - auction->bid));
702 // mail to last bidder and return money
703 session
->SendAuctionOutbiddedMail( auction
, bidprice
);
704 //pl->ModifyMoney( -int32(price) );
708 auction
->bidder
= AHBplayer
->GetGUIDLow();
709 auction
->bid
= bidprice
;
711 // Saving auction into database
712 CharacterDatabase
.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction
->bidder
, auction
->bid
, auction
->Id
);
717 if (AHBplayer
->GetGUIDLow() == auction
->bidder
)
719 //pl->ModifyMoney(-int32(auction->buyout - auction->bid));
723 //pl->ModifyMoney(-int32(auction->buyout));
724 if ( auction
->bidder
)
726 session
->SendAuctionOutbiddedMail( auction
, auction
->buyout
);
729 auction
->bidder
= AHBplayer
->GetGUIDLow();
730 auction
->bid
= auction
->buyout
;
732 // Send mails to buyer & seller
733 auctionmgr
.SendAuctionSuccessfulMail( auction
);
734 auctionmgr
.SendAuctionWonMail( auction
);
736 // Remove item from auctionhouse
737 auctionmgr
.RemoveAItem(auction
->item_guidlow
);
739 auctionHouse
->RemoveAuction(auction
->Id
);
740 // Remove from database
741 auction
->DeleteFromDB();
746 ///////////////////////////////////////////////////////////////////////////////
748 ///////////////////////////////////////////////////////////////////////////////
749 void AuctionHouseBot()
751 time_t _newrun
= time(NULL
);
752 if ((!AHBSeller
) && (!AHBBuyer
))
755 WorldSession
_session(AHBplayerAccount
, NULL
, SEC_PLAYER
, true, 0, LOCALE_enUS
);
756 Player
_AHBplayer(&_session
);
757 _AHBplayer
.MinimalLoadFromDB(NULL
, AHBplayerGUID
);
758 ObjectAccessor::Instance().AddObject(&_AHBplayer
);
760 if(!sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION
))
762 addNewAuctions(&_AHBplayer
, &AllianceConfig
);
763 if (((_newrun
- _lastrun_a
) > (AllianceConfig
.GetBiddingInterval() * 60)) && (AllianceConfig
.GetBidsPerInterval() > 0))
765 addNewAuctionBuyerBotBid(&_AHBplayer
, &AllianceConfig
, &_session
);
766 _lastrun_a
= _newrun
;
768 addNewAuctions(&_AHBplayer
, &HordeConfig
);
769 if (((_newrun
- _lastrun_h
) > (HordeConfig
.GetBiddingInterval() *60)) && (HordeConfig
.GetBidsPerInterval() > 0))
771 addNewAuctionBuyerBotBid(&_AHBplayer
, &HordeConfig
, &_session
);
772 _lastrun_h
= _newrun
;
775 addNewAuctions(&_AHBplayer
, &NeutralConfig
);
776 if (((_newrun
- _lastrun_n
) > (NeutralConfig
.GetBiddingInterval() * 60)) && (NeutralConfig
.GetBidsPerInterval() > 0))
778 addNewAuctionBuyerBotBid(&_AHBplayer
, &NeutralConfig
, &_session
);
779 _lastrun_n
= _newrun
;
781 ObjectAccessor::Instance().RemoveObject(&_AHBplayer
);
783 ///////////////////////////////////////////////////////////////////////////////
785 ///////////////////////////////////////////////////////////////////////////////
786 void AuctionHouseBotInit()
788 AHBSeller
= sConfig
.GetBoolDefault("AuctionHouseBot.EnableSeller", false);
789 AHBBuyer
= sConfig
.GetBoolDefault("AuctionHouseBot.EnableBuyer", false);
790 No_Bind
= sConfig
.GetBoolDefault("AuctionHouseBot.No_Bind", true);
791 Bind_When_Picked_Up
= sConfig
.GetBoolDefault("AuctionHouseBot.Bind_When_Picked_Up", false);
792 Bind_When_Equipped
= sConfig
.GetBoolDefault("AuctionHouseBot.Bind_When_Equipped", true);
793 Bind_When_Use
= sConfig
.GetBoolDefault("AuctionHouseBot.Bind_When_Use", true);
794 Bind_Quest_Item
= sConfig
.GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", false);
796 if(!sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION
))
798 AuctionHouseBotLoadValues(&AllianceConfig
);
799 AuctionHouseBotLoadValues(&HordeConfig
);
801 AuctionHouseBotLoadValues(&NeutralConfig
);
805 Vendor_Items
= sConfig
.GetBoolDefault("AuctionHouseBot.VendorItems", false);
806 Loot_Items
= sConfig
.GetBoolDefault("AuctionHouseBot.LootItems", true);
807 Other_Items
= sConfig
.GetBoolDefault("AuctionHouseBot.OtherItems", false);
809 QueryResult
* results
= (QueryResult
*) NULL
;
810 char npcQuery
[] = "SELECT distinct `item` FROM `npc_vendor`";
811 results
= WorldDatabase
.PQuery(npcQuery
);
816 Field
* fields
= results
->Fetch();
817 npcItems
.push_back(fields
[0].GetUInt32());
819 } while (results
->NextRow());
825 sLog
.outString("AuctionHouseBot: \"%s\" failed", npcQuery
);
828 char lootQuery
[] = "SELECT `item` FROM `creature_loot_template` UNION "
829 "SELECT `item` FROM `disenchant_loot_template` UNION "
830 "SELECT `item` FROM `fishing_loot_template` UNION "
831 "SELECT `item` FROM `gameobject_loot_template` UNION "
832 "SELECT `item` FROM `item_loot_template` UNION "
833 "SELECT `item` FROM `pickpocketing_loot_template` UNION "
834 "SELECT `item` FROM `prospecting_loot_template` UNION "
835 "SELECT `item` FROM `skinning_loot_template`";
837 results
= WorldDatabase
.PQuery(lootQuery
);
842 Field
* fields
= results
->Fetch();
843 lootItems
.push_back(fields
[0].GetUInt32());
845 } while (results
->NextRow());
851 sLog
.outString("AuctionHouseBot: \"%s\" failed", lootQuery
);
854 for (uint32 itemID
= 0; itemID
< sItemStorage
.MaxEntry
; itemID
++)
856 ItemPrototype
const* prototype
= objmgr
.GetItemPrototype(itemID
);
858 if (prototype
== NULL
)
861 switch (prototype
->Bonding
)
868 if (!Bind_When_Picked_Up
)
872 if (!Bind_When_Equipped
)
880 if (!Bind_Quest_Item
)
891 if (prototype
->SellPrice
== 0)
895 if (prototype
->BuyPrice
== 0)
903 if ((prototype
->Quality
< 0) || (prototype
->Quality
> 6))
906 if (Vendor_Items
== 0)
908 bool isVendorItem
= false;
910 for (unsigned int i
= 0; (i
< npcItems
.size()) && (!isVendorItem
); i
++)
912 if (itemID
== npcItems
[i
])
922 bool isLootItem
= false;
924 for (unsigned int i
= 0; (i
< lootItems
.size()) && (!isLootItem
); i
++)
926 if (itemID
== lootItems
[i
])
934 if (Other_Items
== 0)
936 bool isVendorItem
= false;
937 bool isLootItem
= false;
939 for (unsigned int i
= 0; (i
< npcItems
.size()) && (!isVendorItem
); i
++)
941 if (itemID
== npcItems
[i
])
944 for (unsigned int i
= 0; (i
< lootItems
.size()) && (!isLootItem
); i
++)
946 if (itemID
== lootItems
[i
])
949 if ((!isLootItem
) && (!isVendorItem
))
953 switch (prototype
->Quality
)
956 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
957 greyTradeGoodsBin
.push_back(itemID
);
959 greyItemsBin
.push_back(itemID
);
963 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
964 whiteTradeGoodsBin
.push_back(itemID
);
966 whiteItemsBin
.push_back(itemID
);
970 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
971 greenTradeGoodsBin
.push_back(itemID
);
973 greenItemsBin
.push_back(itemID
);
977 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
978 blueTradeGoodsBin
.push_back(itemID
);
980 blueItemsBin
.push_back(itemID
);
984 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
985 purpleTradeGoodsBin
.push_back(itemID
);
987 purpleItemsBin
.push_back(itemID
);
991 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
992 orangeTradeGoodsBin
.push_back(itemID
);
994 orangeItemsBin
.push_back(itemID
);
998 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
999 yellowTradeGoodsBin
.push_back(itemID
);
1001 yellowItemsBin
.push_back(itemID
);
1007 (greyTradeGoodsBin
.size() == 0) &&
1008 (whiteTradeGoodsBin
.size() == 0) &&
1009 (greenTradeGoodsBin
.size() == 0) &&
1010 (blueTradeGoodsBin
.size() == 0) &&
1011 (purpleTradeGoodsBin
.size() == 0) &&
1012 (orangeTradeGoodsBin
.size() == 0) &&
1013 (yellowTradeGoodsBin
.size() == 0) &&
1014 (greyItemsBin
.size() == 0) &&
1015 (whiteItemsBin
.size() == 0) &&
1016 (greenItemsBin
.size() == 0) &&
1017 (blueItemsBin
.size() == 0) &&
1018 (purpleItemsBin
.size() == 0) &&
1019 (orangeItemsBin
.size() == 0) &&
1020 (yellowItemsBin
.size() == 0)
1023 sLog
.outString("AuctionHouseBot: No items");
1027 sLog
.outString("AuctionHouseBot:");
1028 sLog
.outString("loaded %u grey trade goods", greyTradeGoodsBin
.size());
1029 sLog
.outString("loaded %u white trade goods", whiteTradeGoodsBin
.size());
1030 sLog
.outString("loaded %u green trade goods", greenTradeGoodsBin
.size());
1031 sLog
.outString("loaded %u blue trade goods", blueTradeGoodsBin
.size());
1032 sLog
.outString("loaded %u purple trade goods", purpleTradeGoodsBin
.size());
1033 sLog
.outString("loaded %u orange trade goods", orangeTradeGoodsBin
.size());
1034 sLog
.outString("loaded %u yellow trade goods", yellowTradeGoodsBin
.size());
1035 sLog
.outString("loaded %u grey items", greyItemsBin
.size());
1036 sLog
.outString("loaded %u white items", whiteItemsBin
.size());
1037 sLog
.outString("loaded %u green items", greenItemsBin
.size());
1038 sLog
.outString("loaded %u blue items", blueItemsBin
.size());
1039 sLog
.outString("loaded %u purple items", purpleItemsBin
.size());
1040 sLog
.outString("loaded %u orange items", orangeItemsBin
.size());
1041 sLog
.outString("loaded %u yellow items", yellowItemsBin
.size());
1043 sLog
.outString("AuctionHouseBot by Paradox (original by ChrisK) has been loaded.");
1044 sLog
.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox");
1047 void AuctionHouseBotCommands(uint32 command
, uint32 ahMapID
, uint32 col
, char* args
)
1053 config
= &AllianceConfig
;
1056 config
= &HordeConfig
;
1059 config
= &NeutralConfig
;
1093 AuctionHouseObject
* auctionHouse
= auctionmgr
.GetAuctionsMap(config
->GetAHFID());
1095 AuctionHouseObject::AuctionEntryMap::iterator itr
;
1096 itr
= auctionHouse
->GetAuctionsBegin();
1098 while (itr
!= auctionHouse
->GetAuctionsEnd())
1100 if (itr
->second
->owner
== AHBplayerGUID
)
1101 itr
->second
->expire_time
= sWorld
.GetGameTime();
1108 char * param1
= strtok(args
, " ");
1109 uint32 minItems
= (uint32
) strtoul(param1
, NULL
, 0);
1110 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems
, ahMapID
);
1111 config
->SetMinItems(minItems
);
1115 char * param1
= strtok(args
, " ");
1116 uint32 maxItems
= (uint32
) strtoul(param1
, NULL
, 0);
1117 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems
, ahMapID
);
1118 config
->SetMaxItems(maxItems
);
1122 char * param1
= strtok(args
, " ");
1123 uint32 minTime
= (uint32
) strtoul(param1
, NULL
, 0);
1124 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET mintime = '%u' WHERE auctionhouse = '%u'", minTime
, ahMapID
);
1125 config
->SetMinTime(minTime
);
1129 char * param1
= strtok(args
, " ");
1130 uint32 maxTime
= (uint32
) strtoul(param1
, NULL
, 0);
1131 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxtime = '%u' WHERE auctionhouse = '%u'", maxTime
, ahMapID
);
1132 config
->SetMaxTime(maxTime
);
1134 case 5: //percentages
1136 char * param1
= strtok(args
, " ");
1137 char * param2
= strtok(NULL
, " ");
1138 char * param3
= strtok(NULL
, " ");
1139 char * param4
= strtok(NULL
, " ");
1140 char * param5
= strtok(NULL
, " ");
1141 char * param6
= strtok(NULL
, " ");
1142 char * param7
= strtok(NULL
, " ");
1143 char * param8
= strtok(NULL
, " ");
1144 char * param9
= strtok(NULL
, " ");
1145 char * param10
= strtok(NULL
, " ");
1146 char * param11
= strtok(NULL
, " ");
1147 char * param12
= strtok(NULL
, " ");
1148 char * param13
= strtok(NULL
, " ");
1149 char * param14
= strtok(NULL
, " ");
1150 uint32 greytg
= (uint32
) strtoul(param1
, NULL
, 0);
1151 uint32 whitetg
= (uint32
) strtoul(param2
, NULL
, 0);
1152 uint32 greentg
= (uint32
) strtoul(param3
, NULL
, 0);
1153 uint32 bluetg
= (uint32
) strtoul(param4
, NULL
, 0);
1154 uint32 purpletg
= (uint32
) strtoul(param5
, NULL
, 0);
1155 uint32 orangetg
= (uint32
) strtoul(param6
, NULL
, 0);
1156 uint32 yellowtg
= (uint32
) strtoul(param7
, NULL
, 0);
1157 uint32 greyi
= (uint32
) strtoul(param8
, NULL
, 0);
1158 uint32 whitei
= (uint32
) strtoul(param9
, NULL
, 0);
1159 uint32 greeni
= (uint32
) strtoul(param10
, NULL
, 0);
1160 uint32 bluei
= (uint32
) strtoul(param11
, NULL
, 0);
1161 uint32 purplei
= (uint32
) strtoul(param12
, NULL
, 0);
1162 uint32 orangei
= (uint32
) strtoul(param13
, NULL
, 0);
1163 uint32 yellowi
= (uint32
) strtoul(param14
, NULL
, 0);
1165 CharacterDatabase
.BeginTransaction();
1166 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg
, ahMapID
);
1167 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg
, ahMapID
);
1168 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", greentg
, ahMapID
);
1169 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", bluetg
, ahMapID
);
1170 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", purpletg
, ahMapID
);
1171 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentorangetradegoods = '%u' WHERE auctionhouse = '%u'", orangetg
, ahMapID
);
1172 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentyellowtradegoods = '%u' WHERE auctionhouse = '%u'", yellowtg
, ahMapID
);
1173 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentgreyitems = '%u' WHERE auctionhouse = '%u'", greyi
, ahMapID
);
1174 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", whitei
, ahMapID
);
1175 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", greeni
, ahMapID
);
1176 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bluei
, ahMapID
);
1177 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", purplei
, ahMapID
);
1178 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentorangeitems = '%u' WHERE auctionhouse = '%u'", orangei
, ahMapID
);
1179 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentyellowitems = '%u' WHERE auctionhouse = '%u'", yellowi
, ahMapID
);
1180 CharacterDatabase
.CommitTransaction();
1181 config
->SetPercentages(greytg
, whitetg
, greentg
, bluetg
, purpletg
, orangetg
, yellowtg
, greyi
, whitei
, greeni
, bluei
, purplei
, orangei
, yellowi
);
1183 case 6: //min prices
1185 char * param1
= strtok(args
, " ");
1186 uint32 minPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1187 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET minprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), minPrice
, ahMapID
);
1188 config
->SetMinPrice(col
, minPrice
);
1190 case 7: //max prices
1192 char * param1
= strtok(args
, " ");
1193 uint32 maxPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1194 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), maxPrice
, ahMapID
);
1195 config
->SetMaxPrice(col
, maxPrice
);
1197 case 8: //min bid price
1199 char * param1
= strtok(args
, " ");
1200 uint32 minBidPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1201 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET minbidprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), minBidPrice
, ahMapID
);
1202 config
->SetMinBidPrice(col
, minBidPrice
);
1204 case 9: //max bid price
1206 char * param1
= strtok(args
, " ");
1207 uint32 maxBidPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1208 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxbidprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), maxBidPrice
, ahMapID
);
1209 config
->SetMaxBidPrice(col
, maxBidPrice
);
1211 case 10: //max stacks
1213 char * param1
= strtok(args
, " ");
1214 uint32 maxStack
= (uint32
) strtoul(param1
, NULL
, 0);
1215 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxstack%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), maxStack
, ahMapID
);
1216 config
->SetMaxStack(col
, maxStack
);
1218 case 11: //buyer bid prices
1220 char * param1
= strtok(args
, " ");
1221 uint32 buyerPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1222 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET buyerprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), buyerPrice
, ahMapID
);
1223 config
->SetBuyerPrice(col
, buyerPrice
);
1225 case 12: //buyer bidding interval
1227 char * param1
= strtok(args
, " ");
1228 uint32 bidInterval
= (uint32
) strtoul(param1
, NULL
, 0);
1229 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET buyerbiddinginterval = '%u' WHERE auctionhouse = '%u'", bidInterval
, ahMapID
);
1230 config
->SetBiddingInterval(bidInterval
);
1232 case 13: //buyer bids per interval
1234 char * param1
= strtok(args
, " ");
1235 uint32 bidsPerInterval
= (uint32
) strtoul(param1
, NULL
, 0);
1236 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET buyerbidsperinterval = '%u' WHERE auctionhouse = '%u'", bidsPerInterval
, ahMapID
);
1237 config
->SetBidsPerInterval(bidsPerInterval
);
1243 void AuctionHouseBotLoadValues(AHBConfig
*config
)
1247 //load min and max items
1248 config
->SetMinItems(CharacterDatabase
.PQuery("SELECT minitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1249 config
->SetMaxItems(CharacterDatabase
.PQuery("SELECT maxitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1251 {sLog
.outError("minItems = %u", config
->GetMinItems());
1252 sLog
.outError("maxItems = %u", config
->GetMaxItems());}
1253 //load min and max auction times
1254 config
->SetMinTime(CharacterDatabase
.PQuery("SELECT mintime FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1255 config
->SetMaxTime(CharacterDatabase
.PQuery("SELECT maxtime FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1257 {sLog
.outError("minTime = %u", config
->GetMinTime());
1258 sLog
.outError("maxTime = %u", config
->GetMaxTime());}
1260 uint32 greytg
= CharacterDatabase
.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1261 uint32 whitetg
= CharacterDatabase
.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1262 uint32 greentg
= CharacterDatabase
.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1263 uint32 bluetg
= CharacterDatabase
.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1264 uint32 purpletg
= CharacterDatabase
.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1265 uint32 orangetg
= CharacterDatabase
.PQuery("SELECT percentorangetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1266 uint32 yellowtg
= CharacterDatabase
.PQuery("SELECT percentyellowtradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1267 uint32 greyi
= CharacterDatabase
.PQuery("SELECT percentgreyitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1268 uint32 whitei
= CharacterDatabase
.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1269 uint32 greeni
= CharacterDatabase
.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1270 uint32 bluei
= CharacterDatabase
.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1271 uint32 purplei
= CharacterDatabase
.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1272 uint32 orangei
= CharacterDatabase
.PQuery("SELECT percentorangeitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1273 uint32 yellowi
= CharacterDatabase
.PQuery("SELECT percentyellowitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1274 config
->SetPercentages(greytg
, whitetg
, greentg
, bluetg
, purpletg
, orangetg
, yellowtg
, greyi
, whitei
, greeni
, bluei
, purplei
, orangei
, yellowi
);
1277 sLog
.outError("percentGreyTradeGoods = %u", config
->GetPercentages(AHB_GREY_TG
));
1278 sLog
.outError("percentWhiteTradeGoods = %u", config
->GetPercentages(AHB_WHITE_TG
));
1279 sLog
.outError("percentGreenTradeGoods = %u", config
->GetPercentages(AHB_GREEN_TG
));
1280 sLog
.outError("percentBlueTradeGoods = %u", config
->GetPercentages(AHB_BLUE_TG
));
1281 sLog
.outError("percentPurpleTradeGoods = %u", config
->GetPercentages(AHB_PURPLE_TG
));
1282 sLog
.outError("percentOrangeTradeGoods = %u", config
->GetPercentages(AHB_ORANGE_TG
));
1283 sLog
.outError("percentYellowTradeGoods = %u", config
->GetPercentages(AHB_YELLOW_TG
));
1284 sLog
.outError("percentGreyItems = %u", config
->GetPercentages(AHB_GREY_I
));
1285 sLog
.outError("percentWhiteItems = %u", config
->GetPercentages(AHB_WHITE_I
));
1286 sLog
.outError("percentGreenItems = %u", config
->GetPercentages(AHB_GREEN_I
));
1287 sLog
.outError("percentBlueItems = %u", config
->GetPercentages(AHB_BLUE_I
));
1288 sLog
.outError("percentPurpleItems = %u", config
->GetPercentages(AHB_PURPLE_I
));
1289 sLog
.outError("percentOrangeItems = %u", config
->GetPercentages(AHB_ORANGE_I
));
1290 sLog
.outError("percentYellowItems = %u", config
->GetPercentages(AHB_YELLOW_I
));
1292 //load min and max prices
1293 config
->SetMinPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT minpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1294 config
->SetMaxPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT maxpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1296 {sLog
.outError("minPriceGrey = %u", config
->GetMinPrice(AHB_GREY
));
1297 sLog
.outError("maxPriceGrey = %u", config
->GetMaxPrice(AHB_GREY
));}
1298 config
->SetMinPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT minpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1299 config
->SetMaxPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT maxpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1301 {sLog
.outError("minPriceWhite = %u", config
->GetMinPrice(AHB_WHITE
));
1302 sLog
.outError("maxPriceWhite = %u", config
->GetMaxPrice(AHB_WHITE
));}
1303 config
->SetMinPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT minpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1304 config
->SetMaxPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT maxpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1306 {sLog
.outError("minPriceGreen = %u", config
->GetMinPrice(AHB_GREEN
));
1307 sLog
.outError("maxPriceGreen = %u", config
->GetMaxPrice(AHB_GREEN
));}
1308 config
->SetMinPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT minpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1309 config
->SetMaxPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT maxpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1311 {sLog
.outError("minPriceBlue = %u", config
->GetMinPrice(AHB_BLUE
));
1312 sLog
.outError("maxPriceBlue = %u", config
->GetMaxPrice(AHB_BLUE
));}
1313 config
->SetMinPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT minpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1314 config
->SetMaxPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT maxpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1316 {sLog
.outError("minPricePurple = %u", config
->GetMinPrice(AHB_PURPLE
));
1317 sLog
.outError("maxPricePurple = %u", config
->GetMaxPrice(AHB_PURPLE
));}
1318 config
->SetMinPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT minpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1319 config
->SetMaxPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT maxpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1321 {sLog
.outError("minPriceOrange = %u", config
->GetMinPrice(AHB_ORANGE
));
1322 sLog
.outError("maxPriceOrange = %u", config
->GetMaxPrice(AHB_ORANGE
));}
1323 config
->SetMinPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT minpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1324 config
->SetMaxPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT maxpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1326 {sLog
.outError("minPriceYellow = %u", config
->GetMinPrice(AHB_YELLOW
));
1327 sLog
.outError("maxPriceYellow = %u", config
->GetMaxPrice(AHB_YELLOW
));}
1328 //load min and max bid prices
1329 config
->SetMinBidPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT minbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1331 {sLog
.outError(",minBidPriceGrey = %u", config
->GetMinBidPrice(AHB_GREY
));}
1332 config
->SetMaxBidPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT maxbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1334 {sLog
.outError("maxBidPriceGrey = %u", config
->GetMaxBidPrice(AHB_GREY
));}
1335 config
->SetMinBidPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT minbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1337 {sLog
.outError(",minBidPriceWhite = %u", config
->GetMinBidPrice(AHB_WHITE
));}
1338 config
->SetMaxBidPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT maxbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1340 {sLog
.outError("maxBidPriceWhite = %u", config
->GetMaxBidPrice(AHB_WHITE
));}
1341 config
->SetMinBidPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT minbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1343 {sLog
.outError("minBidPriceGreen = %u", config
->GetMinBidPrice(AHB_GREEN
));}
1344 config
->SetMaxBidPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT maxbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1346 {sLog
.outError("maxBidPriceGreen = %u", config
->GetMaxBidPrice(AHB_GREEN
));}
1347 config
->SetMinBidPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT minbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1349 {sLog
.outError("minBidPriceBlue = %u", config
->GetMinBidPrice(AHB_BLUE
));}
1350 config
->SetMaxBidPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT maxbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1352 {sLog
.outError("maxBidPriceBlue = %u", config
->GetMinBidPrice(AHB_BLUE
));}
1353 config
->SetMinBidPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT minbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1355 {sLog
.outError("minBidPricePurple = %u", config
->GetMinBidPrice(AHB_PURPLE
));}
1356 config
->SetMaxBidPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT maxbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1358 {sLog
.outError("maxBidPricePurple = %u", config
->GetMaxBidPrice(AHB_PURPLE
));}
1359 config
->SetMinBidPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT minbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1361 {sLog
.outError("minBidPriceOrange = %u", config
->GetMinBidPrice(AHB_ORANGE
));}
1362 config
->SetMaxBidPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT maxbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1364 {sLog
.outError("maxBidPriceOrange = %u", config
->GetMaxBidPrice(AHB_ORANGE
));}
1365 config
->SetMinBidPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT minbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1367 {sLog
.outError("minBidPriceYellow = %u", config
->GetMinBidPrice(AHB_YELLOW
));}
1368 config
->SetMaxBidPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT maxbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1370 {sLog
.outError("maxBidPriceYellow = %u", config
->GetMaxBidPrice(AHB_YELLOW
));}
1372 config
->SetMaxStack(AHB_GREY
, CharacterDatabase
.PQuery("SELECT maxstackgrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1374 {sLog
.outError("maxStackGrey = %u", config
->GetMaxStack(AHB_GREY
));}
1375 config
->SetMaxStack(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT maxstackwhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1377 {sLog
.outError("maxStackWhite = %u", config
->GetMaxStack(AHB_WHITE
));}
1378 config
->SetMaxStack(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT maxstackgreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1380 {sLog
.outError("maxStackGreen = %u", config
->GetMaxStack(AHB_GREEN
));}
1381 config
->SetMaxStack(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT maxstackblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1383 {sLog
.outError("maxStackBlue = %u", config
->GetMaxStack(AHB_BLUE
));}
1384 config
->SetMaxStack(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT maxstackpurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1386 {sLog
.outError("maxStackPurple = %u", config
->GetMaxStack(AHB_PURPLE
));}
1387 config
->SetMaxStack(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT maxstackorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1389 {sLog
.outError("maxStackOrange = %u", config
->GetMaxStack(AHB_ORANGE
));}
1390 config
->SetMaxStack(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT maxstackyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1392 {sLog
.outError("maxStackYellow = %u", config
->GetMaxStack(AHB_YELLOW
));}
1396 //load buyer bid prices
1397 config
->SetBuyerPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT buyerpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1398 config
->SetBuyerPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT buyerpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1399 config
->SetBuyerPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT buyerpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1400 config
->SetBuyerPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT buyerpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1401 config
->SetBuyerPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT buyerpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1402 config
->SetBuyerPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT buyerpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1403 config
->SetBuyerPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT buyerpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1406 sLog
.outError("buyerPriceGrey = %u", config
->GetBuyerPrice(AHB_GREY
));
1407 sLog
.outError("buyerPriceWhite = %u", config
->GetBuyerPrice(AHB_WHITE
));
1408 sLog
.outError("buyerPriceGreen = %u", config
->GetBuyerPrice(AHB_GREEN
));
1409 sLog
.outError("buyerPriceBlue = %u", config
->GetBuyerPrice(AHB_BLUE
));
1410 sLog
.outError("buyerPricePurple = %u", config
->GetBuyerPrice(AHB_PURPLE
));
1411 sLog
.outError("buyerPriceOrange = %u", config
->GetBuyerPrice(AHB_ORANGE
));
1412 sLog
.outError("buyerPriceYellow = %u", config
->GetBuyerPrice(AHB_YELLOW
));
1414 //load bidding interval
1415 config
->SetBiddingInterval(CharacterDatabase
.PQuery("SELECT buyerbiddinginterval FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1417 {sLog
.outError("buyerBiddingInterval = %u", config
->GetBiddingInterval());}
1418 //load bids per interval
1419 config
->SetBidsPerInterval(CharacterDatabase
.PQuery("SELECT buyerbidsperinterval FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1421 {sLog
.outError("buyerBidsPerInterval = %u", config
->GetBidsPerInterval());}