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
.GetIntDefault("AuctionHouseBot.DEBUG", 0);
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 // Do we have anything to bid? If not, stop here.
507 if(possibleBids
.empty())
512 // Choose random auction from possible auctions
513 uint32 auctionID
= possibleBids
[urand(0, possibleBids
.size() - 1)];
515 // from auctionhousehandler.cpp, creates auction pointer & player pointer
516 AuctionEntry
* auction
= auctionHouse
->GetAuction(auctionID
);
518 // get exact item information
519 Item
*pItem
= auctionmgr
.GetAItem(auction
->item_guidlow
);
522 sLog
.outError("Item doesn't exists, perhaps bought already?");
526 // get item prototype
527 ItemPrototype
const* prototype
= objmgr
.GetItemPrototype(auction
->item_template
);
529 // check which price we have to use, startbid or if it is bidded already
532 sLog
.outError("Auction Number: %u", auction
->Id
);
533 sLog
.outError("Item Template: %u", auction
->item_template
);
534 sLog
.outError("Buy Price: %u", prototype
->BuyPrice
);
535 sLog
.outError("Sell Price: %u", prototype
->SellPrice
);
536 sLog
.outError("Quality: %u", prototype
->Quality
);
541 currentprice
= auction
->bid
;
543 {sLog
.outError("Current Price: %u", auction
->bid
);}
547 currentprice
= auction
->startbid
;
549 {sLog
.outError("Current Price: %u", auction
->startbid
);}
553 // Prepare portion from maximum bid
554 uint32 tmprate2
= urand(0, 100);
555 double tmprate
= static_cast<double>(tmprate2
);
557 {sLog
.outError("tmprate: %f", tmprate
);}
558 double bidrate
= tmprate
/ 100;
560 {sLog
.outError("bidrate: %f", bidrate
);}
561 long double bidMax
= 0;
563 // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
567 switch (prototype
->Quality
)
570 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREY
))
572 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREY
);
576 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_WHITE
))
578 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_WHITE
);
582 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREEN
))
584 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREEN
);
588 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_BLUE
))
590 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_BLUE
);
594 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_PURPLE
))
596 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_PURPLE
);
599 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_ORANGE
))
601 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_ORANGE
);
604 if(currentprice
< prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_YELLOW
))
606 bidMax
= prototype
->SellPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_YELLOW
);
610 // quality is something it shouldn't be, let's get out of here
612 {sLog
.outError("bidMax(fail): %f", bidMax
);}
618 switch (prototype
->Quality
)
621 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREY
))
623 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREY
);
627 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_WHITE
))
629 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_WHITE
);
633 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREEN
))
635 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_GREEN
);
639 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_BLUE
))
641 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_BLUE
);
645 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_PURPLE
))
647 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_PURPLE
);
650 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_ORANGE
))
652 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_ORANGE
);
655 if(currentprice
< prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_YELLOW
))
657 bidMax
= prototype
->BuyPrice
* pItem
->GetCount() * config
->GetBuyerPrice(AHB_YELLOW
);
661 // quality is something it shouldn't be, let's get out of here
663 {sLog
.outError("bidMax(fail): %f", bidMax
);}
673 {sLog
.outError("bidMax(succeed): %f", bidMax
);}
675 // check some special items, and do recalculating to their prices
676 switch (prototype
->Class
)
688 // quality check failed to get bidmax, let's get out of here
693 long double bidvalue
= currentprice
+ ( (bidMax
- currentprice
) * bidrate
);
695 {sLog
.outError("bidvalue: %f", bidvalue
);}
697 bidprice
= static_cast<uint32
>(bidvalue
);
699 {sLog
.outError("bidprice: %u", bidprice
);}
701 // Check our bid is high enough to be valid. If not, correct it to minimum.
702 if((currentprice
+ auction
->GetAuctionOutBid()) > bidprice
)
704 bidprice
= currentprice
+ auction
->GetAuctionOutBid();
706 {sLog
.outError("bidprice(>): %u", bidprice
);}
709 // Check wether we do normal bid, or buyout
710 if ((bidprice
< auction
->buyout
) || (auction
->buyout
== 0))
713 if (auction
->bidder
> 0)
715 if ( auction
->bidder
== AHBplayer
->GetGUIDLow() )
717 //pl->ModifyMoney( -int32(price - auction->bid));
721 // mail to last bidder and return money
722 session
->SendAuctionOutbiddedMail( auction
, bidprice
);
723 //pl->ModifyMoney( -int32(price) );
727 auction
->bidder
= AHBplayer
->GetGUIDLow();
728 auction
->bid
= bidprice
;
730 // Saving auction into database
731 CharacterDatabase
.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction
->bidder
, auction
->bid
, auction
->Id
);
736 if (AHBplayer
->GetGUIDLow() == auction
->bidder
)
738 //pl->ModifyMoney(-int32(auction->buyout - auction->bid));
742 //pl->ModifyMoney(-int32(auction->buyout));
743 if ( auction
->bidder
)
745 session
->SendAuctionOutbiddedMail( auction
, auction
->buyout
);
748 auction
->bidder
= AHBplayer
->GetGUIDLow();
749 auction
->bid
= auction
->buyout
;
751 // Send mails to buyer & seller
752 auctionmgr
.SendAuctionSuccessfulMail( auction
);
753 auctionmgr
.SendAuctionWonMail( auction
);
755 // Remove item from auctionhouse
756 auctionmgr
.RemoveAItem(auction
->item_guidlow
);
758 auctionHouse
->RemoveAuction(auction
->Id
);
759 // Remove from database
760 auction
->DeleteFromDB();
765 ///////////////////////////////////////////////////////////////////////////////
767 ///////////////////////////////////////////////////////////////////////////////
768 void AuctionHouseBot()
770 time_t _newrun
= time(NULL
);
771 if ((!AHBSeller
) && (!AHBBuyer
))
774 WorldSession
_session(AHBplayerAccount
, NULL
, SEC_PLAYER
, true, 0, LOCALE_enUS
);
775 Player
_AHBplayer(&_session
);
776 _AHBplayer
.MinimalLoadFromDB(NULL
, AHBplayerGUID
);
777 ObjectAccessor::Instance().AddObject(&_AHBplayer
);
779 if(!sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION
))
781 addNewAuctions(&_AHBplayer
, &AllianceConfig
);
782 if (((_newrun
- _lastrun_a
) > (AllianceConfig
.GetBiddingInterval() * 60)) && (AllianceConfig
.GetBidsPerInterval() > 0))
784 uint32 bids
= AllianceConfig
.GetBidsPerInterval();
785 for (uint32 count
= 1;count
<= bids
;count
++)
787 addNewAuctionBuyerBotBid(&_AHBplayer
, &AllianceConfig
, &_session
);
788 _lastrun_a
= _newrun
;
791 addNewAuctions(&_AHBplayer
, &HordeConfig
);
792 if (((_newrun
- _lastrun_h
) > (HordeConfig
.GetBiddingInterval() *60)) && (HordeConfig
.GetBidsPerInterval() > 0))
794 uint32 bids
= HordeConfig
.GetBidsPerInterval();
795 for (uint32 count
= 1;count
<= bids
;count
++)
797 addNewAuctionBuyerBotBid(&_AHBplayer
, &HordeConfig
, &_session
);
798 _lastrun_h
= _newrun
;
802 addNewAuctions(&_AHBplayer
, &NeutralConfig
);
803 if (((_newrun
- _lastrun_n
) > (NeutralConfig
.GetBiddingInterval() * 60)) && (NeutralConfig
.GetBidsPerInterval() > 0))
805 uint32 bids
= NeutralConfig
.GetBidsPerInterval();
806 for (uint32 count
= 1;count
<= bids
;count
++)
808 addNewAuctionBuyerBotBid(&_AHBplayer
, &NeutralConfig
, &_session
);
809 _lastrun_n
= _newrun
;
812 ObjectAccessor::Instance().RemoveObject(&_AHBplayer
);
814 ///////////////////////////////////////////////////////////////////////////////
816 ///////////////////////////////////////////////////////////////////////////////
817 void AuctionHouseBotInit()
819 AHBSeller
= sConfig
.GetBoolDefault("AuctionHouseBot.EnableSeller", 0);
820 AHBBuyer
= sConfig
.GetBoolDefault("AuctionHouseBot.EnableBuyer", 0);
821 No_Bind
= sConfig
.GetBoolDefault("AuctionHouseBot.No_Bind", 1);
822 Bind_When_Picked_Up
= sConfig
.GetBoolDefault("AuctionHouseBot.Bind_When_Picked_Up", 0);
823 Bind_When_Equipped
= sConfig
.GetBoolDefault("AuctionHouseBot.Bind_When_Equipped", 1);
824 Bind_When_Use
= sConfig
.GetBoolDefault("AuctionHouseBot.Bind_When_Use", 1);
825 Bind_Quest_Item
= sConfig
.GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", 0);
827 if(!sWorld
.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION
))
829 AuctionHouseBotLoadValues(&AllianceConfig
);
830 AuctionHouseBotLoadValues(&HordeConfig
);
832 AuctionHouseBotLoadValues(&NeutralConfig
);
836 Vendor_Items
= sConfig
.GetBoolDefault("AuctionHouseBot.VendorItems", 0);
837 Loot_Items
= sConfig
.GetBoolDefault("AuctionHouseBot.LootItems", 1);
838 Other_Items
= sConfig
.GetBoolDefault("AuctionHouseBot.OtherItems", 0);
840 QueryResult
* results
= (QueryResult
*) NULL
;
841 char npcQuery
[] = "SELECT distinct `item` FROM `npc_vendor`";
842 results
= WorldDatabase
.PQuery(npcQuery
);
847 Field
* fields
= results
->Fetch();
848 npcItems
.push_back(fields
[0].GetUInt32());
850 } while (results
->NextRow());
856 sLog
.outString("AuctionHouseBot: \"%s\" failed", npcQuery
);
859 char lootQuery
[] = "SELECT `item` FROM `creature_loot_template` UNION "
860 "SELECT `item` FROM `disenchant_loot_template` UNION "
861 "SELECT `item` FROM `fishing_loot_template` UNION "
862 "SELECT `item` FROM `gameobject_loot_template` UNION "
863 "SELECT `item` FROM `item_loot_template` UNION "
864 "SELECT `item` FROM `pickpocketing_loot_template` UNION "
865 "SELECT `item` FROM `prospecting_loot_template` UNION "
866 "SELECT `item` FROM `skinning_loot_template`";
868 results
= WorldDatabase
.PQuery(lootQuery
);
873 Field
* fields
= results
->Fetch();
874 lootItems
.push_back(fields
[0].GetUInt32());
876 } while (results
->NextRow());
882 sLog
.outString("AuctionHouseBot: \"%s\" failed", lootQuery
);
885 for (uint32 itemID
= 0; itemID
< sItemStorage
.MaxEntry
; itemID
++)
887 ItemPrototype
const* prototype
= objmgr
.GetItemPrototype(itemID
);
889 if (prototype
== NULL
)
892 switch (prototype
->Bonding
)
899 if (!Bind_When_Picked_Up
)
903 if (!Bind_When_Equipped
)
911 if (!Bind_Quest_Item
)
922 if (prototype
->SellPrice
== 0)
926 if (prototype
->BuyPrice
== 0)
934 if ((prototype
->Quality
< 0) || (prototype
->Quality
> 6))
937 if (Vendor_Items
== 0)
939 bool isVendorItem
= false;
941 for (unsigned int i
= 0; (i
< npcItems
.size()) && (!isVendorItem
); i
++)
943 if (itemID
== npcItems
[i
])
953 bool isLootItem
= false;
955 for (unsigned int i
= 0; (i
< lootItems
.size()) && (!isLootItem
); i
++)
957 if (itemID
== lootItems
[i
])
965 if (Other_Items
== 0)
967 bool isVendorItem
= false;
968 bool isLootItem
= false;
970 for (unsigned int i
= 0; (i
< npcItems
.size()) && (!isVendorItem
); i
++)
972 if (itemID
== npcItems
[i
])
975 for (unsigned int i
= 0; (i
< lootItems
.size()) && (!isLootItem
); i
++)
977 if (itemID
== lootItems
[i
])
980 if ((!isLootItem
) && (!isVendorItem
))
984 switch (prototype
->Quality
)
987 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
988 greyTradeGoodsBin
.push_back(itemID
);
990 greyItemsBin
.push_back(itemID
);
994 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
995 whiteTradeGoodsBin
.push_back(itemID
);
997 whiteItemsBin
.push_back(itemID
);
1001 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
1002 greenTradeGoodsBin
.push_back(itemID
);
1004 greenItemsBin
.push_back(itemID
);
1008 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
1009 blueTradeGoodsBin
.push_back(itemID
);
1011 blueItemsBin
.push_back(itemID
);
1015 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
1016 purpleTradeGoodsBin
.push_back(itemID
);
1018 purpleItemsBin
.push_back(itemID
);
1022 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
1023 orangeTradeGoodsBin
.push_back(itemID
);
1025 orangeItemsBin
.push_back(itemID
);
1029 if (prototype
->Class
== ITEM_CLASS_TRADE_GOODS
)
1030 yellowTradeGoodsBin
.push_back(itemID
);
1032 yellowItemsBin
.push_back(itemID
);
1038 (greyTradeGoodsBin
.size() == 0) &&
1039 (whiteTradeGoodsBin
.size() == 0) &&
1040 (greenTradeGoodsBin
.size() == 0) &&
1041 (blueTradeGoodsBin
.size() == 0) &&
1042 (purpleTradeGoodsBin
.size() == 0) &&
1043 (orangeTradeGoodsBin
.size() == 0) &&
1044 (yellowTradeGoodsBin
.size() == 0) &&
1045 (greyItemsBin
.size() == 0) &&
1046 (whiteItemsBin
.size() == 0) &&
1047 (greenItemsBin
.size() == 0) &&
1048 (blueItemsBin
.size() == 0) &&
1049 (purpleItemsBin
.size() == 0) &&
1050 (orangeItemsBin
.size() == 0) &&
1051 (yellowItemsBin
.size() == 0)
1054 sLog
.outString("AuctionHouseBot: No items");
1058 sLog
.outString("AuctionHouseBot:");
1059 sLog
.outString("loaded %d grey trade goods", greyTradeGoodsBin
.size());
1060 sLog
.outString("loaded %d white trade goods", whiteTradeGoodsBin
.size());
1061 sLog
.outString("loaded %d green trade goods", greenTradeGoodsBin
.size());
1062 sLog
.outString("loaded %d blue trade goods", blueTradeGoodsBin
.size());
1063 sLog
.outString("loaded %d purple trade goods", purpleTradeGoodsBin
.size());
1064 sLog
.outString("loaded %d orange trade goods", orangeTradeGoodsBin
.size());
1065 sLog
.outString("loaded %d yellow trade goods", yellowTradeGoodsBin
.size());
1066 sLog
.outString("loaded %d grey items", greyItemsBin
.size());
1067 sLog
.outString("loaded %d white items", whiteItemsBin
.size());
1068 sLog
.outString("loaded %d green items", greenItemsBin
.size());
1069 sLog
.outString("loaded %d blue items", blueItemsBin
.size());
1070 sLog
.outString("loaded %d purple items", purpleItemsBin
.size());
1071 sLog
.outString("loaded %d orange items", orangeItemsBin
.size());
1072 sLog
.outString("loaded %d yellow items", yellowItemsBin
.size());
1074 sLog
.outString("AuctionHouseBot by Paradox (original by ChrisK) has been loaded.");
1075 sLog
.outString("AuctionHouseBot now includes AHBuyer by Kerbe and Paradox");
1078 void AuctionHouseBotCommands(uint32 command
, uint32 ahMapID
, uint32 col
, char* args
)
1084 config
= &AllianceConfig
;
1087 config
= &HordeConfig
;
1090 config
= &NeutralConfig
;
1124 AuctionHouseObject
* auctionHouse
= auctionmgr
.GetAuctionsMap(config
->GetAHFID());
1126 AuctionHouseObject::AuctionEntryMap::iterator itr
;
1127 itr
= auctionHouse
->GetAuctionsBegin();
1129 while (itr
!= auctionHouse
->GetAuctionsEnd())
1131 if (itr
->second
->owner
== AHBplayerGUID
)
1132 itr
->second
->expire_time
= sWorld
.GetGameTime();
1139 char * param1
= strtok(args
, " ");
1140 uint32 minItems
= (uint32
) strtoul(param1
, NULL
, 0);
1141 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems
, ahMapID
);
1142 config
->SetMinItems(minItems
);
1146 char * param1
= strtok(args
, " ");
1147 uint32 maxItems
= (uint32
) strtoul(param1
, NULL
, 0);
1148 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems
, ahMapID
);
1149 config
->SetMaxItems(maxItems
);
1153 char * param1
= strtok(args
, " ");
1154 uint32 minTime
= (uint32
) strtoul(param1
, NULL
, 0);
1155 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET mintime = '%u' WHERE auctionhouse = '%u'", minTime
, ahMapID
);
1156 config
->SetMinTime(minTime
);
1160 char * param1
= strtok(args
, " ");
1161 uint32 maxTime
= (uint32
) strtoul(param1
, NULL
, 0);
1162 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxtime = '%u' WHERE auctionhouse = '%u'", maxTime
, ahMapID
);
1163 config
->SetMaxTime(maxTime
);
1165 case 5: //percentages
1167 char * param1
= strtok(args
, " ");
1168 char * param2
= strtok(NULL
, " ");
1169 char * param3
= strtok(NULL
, " ");
1170 char * param4
= strtok(NULL
, " ");
1171 char * param5
= strtok(NULL
, " ");
1172 char * param6
= strtok(NULL
, " ");
1173 char * param7
= strtok(NULL
, " ");
1174 char * param8
= strtok(NULL
, " ");
1175 char * param9
= strtok(NULL
, " ");
1176 char * param10
= strtok(NULL
, " ");
1177 char * param11
= strtok(NULL
, " ");
1178 char * param12
= strtok(NULL
, " ");
1179 char * param13
= strtok(NULL
, " ");
1180 char * param14
= strtok(NULL
, " ");
1181 uint32 greytg
= (uint32
) strtoul(param1
, NULL
, 0);
1182 uint32 whitetg
= (uint32
) strtoul(param2
, NULL
, 0);
1183 uint32 greentg
= (uint32
) strtoul(param3
, NULL
, 0);
1184 uint32 bluetg
= (uint32
) strtoul(param4
, NULL
, 0);
1185 uint32 purpletg
= (uint32
) strtoul(param5
, NULL
, 0);
1186 uint32 orangetg
= (uint32
) strtoul(param6
, NULL
, 0);
1187 uint32 yellowtg
= (uint32
) strtoul(param7
, NULL
, 0);
1188 uint32 greyi
= (uint32
) strtoul(param8
, NULL
, 0);
1189 uint32 whitei
= (uint32
) strtoul(param9
, NULL
, 0);
1190 uint32 greeni
= (uint32
) strtoul(param10
, NULL
, 0);
1191 uint32 bluei
= (uint32
) strtoul(param11
, NULL
, 0);
1192 uint32 purplei
= (uint32
) strtoul(param12
, NULL
, 0);
1193 uint32 orangei
= (uint32
) strtoul(param13
, NULL
, 0);
1194 uint32 yellowi
= (uint32
) strtoul(param14
, NULL
, 0);
1196 CharacterDatabase
.BeginTransaction();
1197 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg
, ahMapID
);
1198 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg
, ahMapID
);
1199 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", greentg
, ahMapID
);
1200 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", bluetg
, ahMapID
);
1201 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", purpletg
, ahMapID
);
1202 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentorangetradegoods = '%u' WHERE auctionhouse = '%u'", orangetg
, ahMapID
);
1203 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentyellowtradegoods = '%u' WHERE auctionhouse = '%u'", yellowtg
, ahMapID
);
1204 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentgreyitems = '%u' WHERE auctionhouse = '%u'", greyi
, ahMapID
);
1205 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", whitei
, ahMapID
);
1206 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", greeni
, ahMapID
);
1207 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bluei
, ahMapID
);
1208 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", purplei
, ahMapID
);
1209 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentorangeitems = '%u' WHERE auctionhouse = '%u'", orangei
, ahMapID
);
1210 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET percentyellowitems = '%u' WHERE auctionhouse = '%u'", yellowi
, ahMapID
);
1211 CharacterDatabase
.CommitTransaction();
1212 config
->SetPercentages(greytg
, whitetg
, greentg
, bluetg
, purpletg
, orangetg
, yellowtg
, greyi
, whitei
, greeni
, bluei
, purplei
, orangei
, yellowi
);
1214 case 6: //min prices
1216 char * param1
= strtok(args
, " ");
1217 uint32 minPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1218 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET minprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), minPrice
, ahMapID
);
1219 config
->SetMinPrice(col
, minPrice
);
1221 case 7: //max prices
1223 char * param1
= strtok(args
, " ");
1224 uint32 maxPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1225 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), maxPrice
, ahMapID
);
1226 config
->SetMaxPrice(col
, maxPrice
);
1228 case 8: //min bid price
1230 char * param1
= strtok(args
, " ");
1231 uint32 minBidPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1232 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET minbidprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), minBidPrice
, ahMapID
);
1233 config
->SetMinBidPrice(col
, minBidPrice
);
1235 case 9: //max bid price
1237 char * param1
= strtok(args
, " ");
1238 uint32 maxBidPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1239 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxbidprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), maxBidPrice
, ahMapID
);
1240 config
->SetMaxBidPrice(col
, maxBidPrice
);
1242 case 10: //max stacks
1244 char * param1
= strtok(args
, " ");
1245 uint32 maxStack
= (uint32
) strtoul(param1
, NULL
, 0);
1246 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET maxstack%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), maxStack
, ahMapID
);
1247 config
->SetMaxStack(col
, maxStack
);
1249 case 11: //buyer bid prices
1251 char * param1
= strtok(args
, " ");
1252 uint32 buyerPrice
= (uint32
) strtoul(param1
, NULL
, 0);
1253 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET buyerprice%s = '%u' WHERE auctionhouse = '%u'",color
.c_str(), buyerPrice
, ahMapID
);
1254 config
->SetBuyerPrice(col
, buyerPrice
);
1256 case 12: //buyer bidding interval
1258 char * param1
= strtok(args
, " ");
1259 uint32 bidInterval
= (uint32
) strtoul(param1
, NULL
, 0);
1260 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET buyerbiddinginterval = '%u' WHERE auctionhouse = '%u'", bidInterval
, ahMapID
);
1261 config
->SetBiddingInterval(bidInterval
);
1263 case 13: //buyer bids per interval
1265 char * param1
= strtok(args
, " ");
1266 uint32 bidsPerInterval
= (uint32
) strtoul(param1
, NULL
, 0);
1267 CharacterDatabase
.PExecute("UPDATE auctionhousebot SET buyerbidsperinterval = '%u' WHERE auctionhouse = '%u'", bidsPerInterval
, ahMapID
);
1268 config
->SetBidsPerInterval(bidsPerInterval
);
1274 void AuctionHouseBotLoadValues(AHBConfig
*config
)
1278 //load min and max items
1279 config
->SetMinItems(CharacterDatabase
.PQuery("SELECT minitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1280 config
->SetMaxItems(CharacterDatabase
.PQuery("SELECT maxitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1282 {sLog
.outError("minItems = %u", config
->GetMinItems());
1283 sLog
.outError("maxItems = %u", config
->GetMaxItems());}
1284 //load min and max auction times
1285 config
->SetMinTime(CharacterDatabase
.PQuery("SELECT mintime FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1286 config
->SetMaxTime(CharacterDatabase
.PQuery("SELECT maxtime FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1288 {sLog
.outError("minTime = %u", config
->GetMinTime());
1289 sLog
.outError("maxTime = %u", config
->GetMaxTime());}
1291 uint32 greytg
= CharacterDatabase
.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1292 uint32 whitetg
= CharacterDatabase
.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1293 uint32 greentg
= CharacterDatabase
.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1294 uint32 bluetg
= CharacterDatabase
.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1295 uint32 purpletg
= CharacterDatabase
.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1296 uint32 orangetg
= CharacterDatabase
.PQuery("SELECT percentorangetradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1297 uint32 yellowtg
= CharacterDatabase
.PQuery("SELECT percentyellowtradegoods FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1298 uint32 greyi
= CharacterDatabase
.PQuery("SELECT percentgreyitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1299 uint32 whitei
= CharacterDatabase
.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1300 uint32 greeni
= CharacterDatabase
.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1301 uint32 bluei
= CharacterDatabase
.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1302 uint32 purplei
= CharacterDatabase
.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1303 uint32 orangei
= CharacterDatabase
.PQuery("SELECT percentorangeitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1304 uint32 yellowi
= CharacterDatabase
.PQuery("SELECT percentyellowitems FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32();
1305 config
->SetPercentages(greytg
, whitetg
, greentg
, bluetg
, purpletg
, orangetg
, yellowtg
, greyi
, whitei
, greeni
, bluei
, purplei
, orangei
, yellowi
);
1308 sLog
.outError("percentGreyTradeGoods = %u", config
->GetPercentages(AHB_GREY_TG
));
1309 sLog
.outError("percentWhiteTradeGoods = %u", config
->GetPercentages(AHB_WHITE_TG
));
1310 sLog
.outError("percentGreenTradeGoods = %u", config
->GetPercentages(AHB_GREEN_TG
));
1311 sLog
.outError("percentBlueTradeGoods = %u", config
->GetPercentages(AHB_BLUE_TG
));
1312 sLog
.outError("percentPurpleTradeGoods = %u", config
->GetPercentages(AHB_PURPLE_TG
));
1313 sLog
.outError("percentOrangeTradeGoods = %u", config
->GetPercentages(AHB_ORANGE_TG
));
1314 sLog
.outError("percentYellowTradeGoods = %u", config
->GetPercentages(AHB_YELLOW_TG
));
1315 sLog
.outError("percentGreyItems = %u", config
->GetPercentages(AHB_GREY_I
));
1316 sLog
.outError("percentWhiteItems = %u", config
->GetPercentages(AHB_WHITE_I
));
1317 sLog
.outError("percentGreenItems = %u", config
->GetPercentages(AHB_GREEN_I
));
1318 sLog
.outError("percentBlueItems = %u", config
->GetPercentages(AHB_BLUE_I
));
1319 sLog
.outError("percentPurpleItems = %u", config
->GetPercentages(AHB_PURPLE_I
));
1320 sLog
.outError("percentOrangeItems = %u", config
->GetPercentages(AHB_ORANGE_I
));
1321 sLog
.outError("percentYellowItems = %u", config
->GetPercentages(AHB_YELLOW_I
));
1323 //load min and max prices
1324 config
->SetMinPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT minpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1325 config
->SetMaxPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT maxpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1327 {sLog
.outError("minPriceGrey = %u", config
->GetMinPrice(AHB_GREY
));
1328 sLog
.outError("maxPriceGrey = %u", config
->GetMaxPrice(AHB_GREY
));}
1329 config
->SetMinPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT minpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1330 config
->SetMaxPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT maxpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1332 {sLog
.outError("minPriceWhite = %u", config
->GetMinPrice(AHB_WHITE
));
1333 sLog
.outError("maxPriceWhite = %u", config
->GetMaxPrice(AHB_WHITE
));}
1334 config
->SetMinPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT minpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1335 config
->SetMaxPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT maxpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1337 {sLog
.outError("minPriceGreen = %u", config
->GetMinPrice(AHB_GREEN
));
1338 sLog
.outError("maxPriceGreen = %u", config
->GetMaxPrice(AHB_GREEN
));}
1339 config
->SetMinPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT minpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1340 config
->SetMaxPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT maxpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1342 {sLog
.outError("minPriceBlue = %u", config
->GetMinPrice(AHB_BLUE
));
1343 sLog
.outError("maxPriceBlue = %u", config
->GetMaxPrice(AHB_BLUE
));}
1344 config
->SetMinPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT minpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1345 config
->SetMaxPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT maxpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1347 {sLog
.outError("minPricePurple = %u", config
->GetMinPrice(AHB_PURPLE
));
1348 sLog
.outError("maxPricePurple = %u", config
->GetMaxPrice(AHB_PURPLE
));}
1349 config
->SetMinPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT minpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1350 config
->SetMaxPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT maxpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1352 {sLog
.outError("minPriceOrange = %u", config
->GetMinPrice(AHB_ORANGE
));
1353 sLog
.outError("maxPriceOrange = %u", config
->GetMaxPrice(AHB_ORANGE
));}
1354 config
->SetMinPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT minpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1355 config
->SetMaxPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT maxpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1357 {sLog
.outError("minPriceYellow = %u", config
->GetMinPrice(AHB_YELLOW
));
1358 sLog
.outError("maxPriceYellow = %u", config
->GetMaxPrice(AHB_YELLOW
));}
1359 //load min and max bid prices
1360 config
->SetMinBidPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT minbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1362 {sLog
.outError(",minBidPriceGrey = %u", config
->GetMinBidPrice(AHB_GREY
));}
1363 config
->SetMaxBidPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT maxbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1365 {sLog
.outError("maxBidPriceGrey = %u", config
->GetMaxBidPrice(AHB_GREY
));}
1366 config
->SetMinBidPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT minbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1368 {sLog
.outError(",minBidPriceWhite = %u", config
->GetMinBidPrice(AHB_WHITE
));}
1369 config
->SetMaxBidPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT maxbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1371 {sLog
.outError("maxBidPriceWhite = %u", config
->GetMaxBidPrice(AHB_WHITE
));}
1372 config
->SetMinBidPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT minbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1374 {sLog
.outError("minBidPriceGreen = %u", config
->GetMinBidPrice(AHB_GREEN
));}
1375 config
->SetMaxBidPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT maxbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1377 {sLog
.outError("maxBidPriceGreen = %u", config
->GetMaxBidPrice(AHB_GREEN
));}
1378 config
->SetMinBidPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT minbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1380 {sLog
.outError("minBidPriceBlue = %u", config
->GetMinBidPrice(AHB_BLUE
));}
1381 config
->SetMaxBidPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT maxbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1383 {sLog
.outError("maxBidPriceBlue = %u", config
->GetMinBidPrice(AHB_BLUE
));}
1384 config
->SetMinBidPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT minbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1386 {sLog
.outError("minBidPricePurple = %u", config
->GetMinBidPrice(AHB_PURPLE
));}
1387 config
->SetMaxBidPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT maxbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1389 {sLog
.outError("maxBidPricePurple = %u", config
->GetMaxBidPrice(AHB_PURPLE
));}
1390 config
->SetMinBidPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT minbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1392 {sLog
.outError("minBidPriceOrange = %u", config
->GetMinBidPrice(AHB_ORANGE
));}
1393 config
->SetMaxBidPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT maxbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1395 {sLog
.outError("maxBidPriceOrange = %u", config
->GetMaxBidPrice(AHB_ORANGE
));}
1396 config
->SetMinBidPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT minbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1398 {sLog
.outError("minBidPriceYellow = %u", config
->GetMinBidPrice(AHB_YELLOW
));}
1399 config
->SetMaxBidPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT maxbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1401 {sLog
.outError("maxBidPriceYellow = %u", config
->GetMaxBidPrice(AHB_YELLOW
));}
1403 config
->SetMaxStack(AHB_GREY
, CharacterDatabase
.PQuery("SELECT maxstackgrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1405 {sLog
.outError("maxStackGrey = %u", config
->GetMaxStack(AHB_GREY
));}
1406 config
->SetMaxStack(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT maxstackwhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1408 {sLog
.outError("maxStackWhite = %u", config
->GetMaxStack(AHB_WHITE
));}
1409 config
->SetMaxStack(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT maxstackgreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1411 {sLog
.outError("maxStackGreen = %u", config
->GetMaxStack(AHB_GREEN
));}
1412 config
->SetMaxStack(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT maxstackblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1414 {sLog
.outError("maxStackBlue = %u", config
->GetMaxStack(AHB_BLUE
));}
1415 config
->SetMaxStack(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT maxstackpurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1417 {sLog
.outError("maxStackPurple = %u", config
->GetMaxStack(AHB_PURPLE
));}
1418 config
->SetMaxStack(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT maxstackorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1420 {sLog
.outError("maxStackOrange = %u", config
->GetMaxStack(AHB_ORANGE
));}
1421 config
->SetMaxStack(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT maxstackyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1423 {sLog
.outError("maxStackYellow = %u", config
->GetMaxStack(AHB_YELLOW
));}
1427 //load buyer bid prices
1428 config
->SetBuyerPrice(AHB_GREY
, CharacterDatabase
.PQuery("SELECT buyerpricegrey FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1429 config
->SetBuyerPrice(AHB_WHITE
, CharacterDatabase
.PQuery("SELECT buyerpricewhite FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1430 config
->SetBuyerPrice(AHB_GREEN
, CharacterDatabase
.PQuery("SELECT buyerpricegreen FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1431 config
->SetBuyerPrice(AHB_BLUE
, CharacterDatabase
.PQuery("SELECT buyerpriceblue FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1432 config
->SetBuyerPrice(AHB_PURPLE
, CharacterDatabase
.PQuery("SELECT buyerpricepurple FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1433 config
->SetBuyerPrice(AHB_ORANGE
, CharacterDatabase
.PQuery("SELECT buyerpriceorange FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1434 config
->SetBuyerPrice(AHB_YELLOW
, CharacterDatabase
.PQuery("SELECT buyerpriceyellow FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1437 sLog
.outError("buyerPriceGrey = %u", config
->GetBuyerPrice(AHB_GREY
));
1438 sLog
.outError("buyerPriceWhite = %u", config
->GetBuyerPrice(AHB_WHITE
));
1439 sLog
.outError("buyerPriceGreen = %u", config
->GetBuyerPrice(AHB_GREEN
));
1440 sLog
.outError("buyerPriceBlue = %u", config
->GetBuyerPrice(AHB_BLUE
));
1441 sLog
.outError("buyerPricePurple = %u", config
->GetBuyerPrice(AHB_PURPLE
));
1442 sLog
.outError("buyerPriceOrange = %u", config
->GetBuyerPrice(AHB_ORANGE
));
1443 sLog
.outError("buyerPriceYellow = %u", config
->GetBuyerPrice(AHB_YELLOW
));
1445 //load bidding interval
1446 config
->SetBiddingInterval(CharacterDatabase
.PQuery("SELECT buyerbiddinginterval FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1448 {sLog
.outError("buyerBiddingInterval = %u", config
->GetBiddingInterval());}
1449 //load bids per interval
1450 config
->SetBidsPerInterval(CharacterDatabase
.PQuery("SELECT buyerbidsperinterval FROM auctionhousebot WHERE auctionhouse = %u",config
->GetAHID())->Fetch()->GetUInt32());
1452 {sLog
.outError("buyerBidsPerInterval = %u", config
->GetBidsPerInterval());}