OregonCore  revision 3611e8a-git
Your Favourite TBC server
AuctionHouseBot.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "ObjectMgr.h"
19 #include "AuctionHouseMgr.h"
20 #include "AuctionHouseBot.h"
21 #include <vector>
22 
24 
25 using namespace std;
26 vector<uint32> npcItems;
27 vector<uint32> lootItems;
28 vector<uint32> greyTradeGoodsBin;
29 vector<uint32> whiteTradeGoodsBin;
30 vector<uint32> greenTradeGoodsBin;
31 vector<uint32> blueTradeGoodsBin;
32 vector<uint32> purpleTradeGoodsBin;
33 vector<uint32> orangeTradeGoodsBin;
34 vector<uint32> yellowTradeGoodsBin;
35 vector<uint32> greyItemsBin;
36 vector<uint32> whiteItemsBin;
37 vector<uint32> greenItemsBin;
38 vector<uint32> blueItemsBin;
39 vector<uint32> purpleItemsBin;
40 vector<uint32> orangeItemsBin;
41 vector<uint32> yellowItemsBin;
42 
44 {
45  debug_Out = false;
46  debug_Out_Filters = false;
47  AHBSeller = false;
48  AHBBuyer = false;
49 
50  BuyMethod = false;
51  SellMethod = false;
52 
53  AHBplayerAccount = 0;
54  AHBplayerGUID = 0;
55  ItemsPerCycle = 0;
56 
57  //Begin Filters
58 
59  Vendor_Items = false;
60  Loot_Items = false;
61  Other_Items = false;
62  Vendor_TGs = false;
63  Loot_TGs = false;
64  Other_TGs = false;
65 
66  No_Bind = false;
67  Bind_When_Picked_Up = false;
68  Bind_When_Equipped = false;
69  Bind_When_Use = false;
70  Bind_Quest_Item = false;
71 
72  DisableBeta_PTR_Unused = false;
73  DisablePermEnchant = false;
74  DisableGems = false;
75  DisableMoney = false;
76  DisableMoneyLoot = false;
77  DisableLootable = false;
78  DisableKeys = false;
79  DisableDuration = false;
80  DisableBOP_Or_Quest_NoReqLevel = false;
81 
82  DisableWarriorItems = false;
83  DisablePaladinItems = false;
84  DisableHunterItems = false;
85  DisableRogueItems = false;
86  DisablePriestItems = false;
87  DisableDKItems = false;
88  DisableShamanItems = false;
89  DisableMageItems = false;
90  DisableWarlockItems = false;
91  DisableUnusedClassItems = false;
92  DisableDruidItems = false;
93 
94  DisableItemsBelowLevel = 0;
95  DisableItemsAboveLevel = 0;
96  DisableTGsBelowLevel = 0;
97  DisableTGsAboveLevel = 0;
98  DisableItemsBelowGUID = 0;
99  DisableItemsAboveGUID = 0;
100  DisableTGsBelowGUID = 0;
101  DisableTGsAboveGUID = 0;
102  DisableItemsBelowReqLevel = 0;
103  DisableItemsAboveReqLevel = 0;
104  DisableTGsBelowReqLevel = 0;
105  DisableTGsAboveReqLevel = 0;
106  DisableItemsBelowReqSkillRank = 0;
107  DisableItemsAboveReqSkillRank = 0;
108  DisableTGsBelowReqSkillRank = 0;
109  DisableTGsAboveReqSkillRank = 0;
110 
111  //End Filters
112 
113  _lastrun_a = time(NULL);
114  _lastrun_h = time(NULL);
115  _lastrun_n = time(NULL);
116 
117  AllianceConfig = AHBConfig(2);
118  HordeConfig = AHBConfig(6);
119  NeutralConfig = AHBConfig(7);
120 }
121 
123 {
124 }
125 
127 {
128  if (!AHBSeller)
129  {
130  if (debug_Out) sLog.outError("AHSeller: Disabled");
131  return;
132  }
133 
134  uint32 minItems = config->GetMinItems();
135  uint32 maxItems = config->GetMaxItems();
136 
137  if (maxItems == 0)
138  {
139  //if (debug_Out) sLog.outString("AHSeller: Auctions disabled");
140  return;
141  }
142 
143  AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAHFID());
144  if (!ahEntry)
145  return;
146 
147  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
148  if (!auctionHouse)
149  return;
150 
151  uint32 auctions = auctionHouse->Getcount();
152 
153  if (auctions >= minItems)
154  {
155  //if (debug_Out) sLog.outString("AHSeller: Auctions above minimum");
156  return;
157  }
158 
159  if (auctions >= maxItems)
160  {
161  //if (debug_Out) sLog.outString("AHSeller: Auctions at or above maximum");
162  return;
163  }
164 
165  uint32 items = 0;
166  if ((maxItems - auctions) >= ItemsPerCycle)
167  items = ItemsPerCycle;
168  else
169  items = (maxItems - auctions);
170 
171  if (debug_Out) sLog.outString("AHSeller: Adding %u Auctions", items);
172 
173  uint32 AuctioneerGUID = 0;
174 
175  switch (config->GetAHID())
176  {
177  case 2:
178  AuctioneerGUID = 79707; //Human in stormwind.
179  break;
180  case 6:
181  AuctioneerGUID = 4656; //orc in Orgrimmar
182  break;
183  case 7:
184  AuctioneerGUID = 23442; //goblin in GZ
185  break;
186  default:
187  if (debug_Out) sLog.outError("AHSeller: GetAHID() - Default switch reached");
188  AuctioneerGUID = 23442; //default to neutral 7
189  break;
190  }
191 
192  if (debug_Out) sLog.outString("AHSeller: Current Auctineer GUID is %u", AuctioneerGUID);
193 
194  uint32 greyTGcount = config->GetPercents(AHB_GREY_TG);
195  uint32 whiteTGcount = config->GetPercents(AHB_WHITE_TG);
196  uint32 greenTGcount = config->GetPercents(AHB_GREEN_TG);
197  uint32 blueTGcount = config->GetPercents(AHB_BLUE_TG);
198  uint32 purpleTGcount = config->GetPercents(AHB_PURPLE_TG);
199  uint32 orangeTGcount = config->GetPercents(AHB_ORANGE_TG);
200  uint32 yellowTGcount = config->GetPercents(AHB_YELLOW_TG);
201  uint32 greyIcount = config->GetPercents(AHB_GREY_I);
202  uint32 whiteIcount = config->GetPercents(AHB_WHITE_I);
203  uint32 greenIcount = config->GetPercents(AHB_GREEN_I);
204  uint32 blueIcount = config->GetPercents(AHB_BLUE_I);
205  uint32 purpleIcount = config->GetPercents(AHB_PURPLE_I);
206  uint32 orangeIcount = config->GetPercents(AHB_ORANGE_I);
207  uint32 yellowIcount = config->GetPercents(AHB_YELLOW_I);
208  /* uint32 total = greyTGcount + whiteTGcount + greenTGcount + blueTGcount
209  + purpleTGcount + orangeTGcount + yellowTGcount
210  + whiteIcount + greenIcount + blueIcount + purpleIcount
211  + orangeIcount + yellowIcount;
212  */
213  uint32 greyTGoods = config->GetItemCounts(AHB_GREY_TG);
214  uint32 whiteTGoods = config->GetItemCounts(AHB_WHITE_TG);
215  uint32 greenTGoods = config->GetItemCounts(AHB_GREEN_TG);
216  uint32 blueTGoods = config->GetItemCounts(AHB_BLUE_TG);
217  uint32 purpleTGoods = config->GetItemCounts(AHB_PURPLE_TG);
218  uint32 orangeTGoods = config->GetItemCounts(AHB_ORANGE_TG);
219  uint32 yellowTGoods = config->GetItemCounts(AHB_YELLOW_TG);
220 
221  uint32 greyItems = config->GetItemCounts(AHB_GREY_I);
222  uint32 whiteItems = config->GetItemCounts(AHB_WHITE_I);
223  uint32 greenItems = config->GetItemCounts(AHB_GREEN_I);
224  uint32 blueItems = config->GetItemCounts(AHB_BLUE_I);
225  uint32 purpleItems = config->GetItemCounts(AHB_PURPLE_I);
226  uint32 orangeItems = config->GetItemCounts(AHB_ORANGE_I);
227  uint32 yellowItems = config->GetItemCounts(AHB_YELLOW_I);
228  if (debug_Out) sLog.outString("AHSeller: %u items", items);
229 
230  // only insert a few at a time, so as not to peg the processor
231  for (uint32 cnt = 1; cnt <= items; cnt++)
232  {
233  if (debug_Out)
234  sLog.outString("AHSeller: %u count", cnt);
235  uint32 itemID = 0;
236  uint32 itemColor = 99;
237  uint32 loopbreaker = 0;
238  while (itemID == 0 && loopbreaker <= 50)
239  {
240  ++loopbreaker;
241  uint32 choice = urand(0, 13);
242  itemColor = choice;
243  switch (choice)
244  {
245  case 0:
246  {
247  if ((greyItemsBin.size() > 0) && (greyItems < greyIcount))
248  itemID = greyItemsBin[urand(0, greyItemsBin.size() - 1)];
249  else continue;
250  break;
251  }
252  case 1:
253  {
254  if ((whiteItemsBin.size() > 0) && (whiteItems < whiteIcount))
255  itemID = whiteItemsBin[urand(0, whiteItemsBin.size() - 1)];
256  else continue;
257  break;
258  }
259  case 2:
260  {
261  if ((greenItemsBin.size() > 0) && (greenItems < greenIcount))
262  itemID = greenItemsBin[urand(0, greenItemsBin.size() - 1)];
263  else continue;
264  break;
265  }
266  case 3:
267  {
268  if ((blueItemsBin.size() > 0) && (blueItems < blueIcount))
269  itemID = blueItemsBin[urand(0, blueItemsBin.size() - 1)];
270  else continue;
271  break;
272  }
273  case 4:
274  {
275  if ((purpleItemsBin.size() > 0) && (purpleItems < purpleIcount))
276  itemID = purpleItemsBin[urand(0, purpleItemsBin.size() - 1)];
277  else continue;
278  break;
279  }
280  case 5:
281  {
282  if ((orangeItemsBin.size() > 0) && (orangeItems < orangeIcount))
283  itemID = orangeItemsBin[urand(0, orangeItemsBin.size() - 1)];
284  else continue;
285  break;
286  }
287  case 6:
288  {
289  if ((yellowItemsBin.size() > 0) && (yellowItems < yellowIcount))
290  itemID = yellowItemsBin[urand(0, yellowItemsBin.size() - 1)];
291  else continue;
292  break;
293  }
294  case 7:
295  {
296  if ((greyTradeGoodsBin.size() > 0) && (greyTGoods < greyTGcount))
297  itemID = greyTradeGoodsBin[urand(0, greyTradeGoodsBin.size() - 1)];
298  else continue;
299  break;
300  }
301  case 8:
302  {
303  if ((whiteTradeGoodsBin.size() > 0) && (whiteTGoods < whiteTGcount))
304  itemID = whiteTradeGoodsBin[urand(0, whiteTradeGoodsBin.size() - 1)];
305  else continue;
306  break;
307  }
308  case 9:
309  {
310  if ((greenTradeGoodsBin.size() > 0) && (greenTGoods < greenTGcount))
311  itemID = greenTradeGoodsBin[urand(0, greenTradeGoodsBin.size() - 1)];
312  else continue;
313  break;
314  }
315  case 10:
316  {
317  if ((blueTradeGoodsBin.size() > 0) && (blueTGoods < blueTGcount))
318  itemID = blueTradeGoodsBin[urand(0, blueTradeGoodsBin.size() - 1)];
319  else continue;
320  break;
321  }
322  case 11:
323  {
324  if ((purpleTradeGoodsBin.size() > 0) && (purpleTGoods < purpleTGcount))
325  itemID = purpleTradeGoodsBin[urand(0, purpleTradeGoodsBin.size() - 1)];
326  else continue;
327  break;
328  }
329  case 12:
330  {
331  if ((orangeTradeGoodsBin.size() > 0) && (orangeTGoods < orangeTGcount))
332  itemID = orangeTradeGoodsBin[urand(0, orangeTradeGoodsBin.size() - 1)];
333  else continue;
334  break;
335  }
336  case 13:
337  {
338  if ((yellowTradeGoodsBin.size() > 0) && (yellowTGoods < yellowTGcount))
339  itemID = yellowTradeGoodsBin[urand(0, yellowTradeGoodsBin.size() - 1)];
340  else continue;
341  break;
342  }
343  default:
344  {
345  if (debug_Out) sLog.outError("AHSeller: itemID Switch - Default Reached");
346  break;
347  }
348  }
349 
350  if (itemID == 0)
351  {
352  if (debug_Out) sLog.outError("AHSeller: Item::CreateItem() - ItemID is 0");
353  continue;
354  }
355 
356  if (config->IsIgnoringItem(itemID))
357  continue;
358 
359  ItemTemplate const* prototype = sObjectMgr.GetItemTemplate(itemID);
360  if (prototype == NULL)
361  {
362  if (debug_Out) sLog.outError("AHSeller: Huh?!?! prototype == NULL");
363  continue;
364  }
365 
366  Item* item = Item::CreateItem(itemID, 1, AHBplayer);
367  if (item == NULL)
368  {
369  if (debug_Out) sLog.outError("AHSeller: Item::CreateItem() returned NULL");
370  break;
371  }
372  item->AddToUpdateQueueOf(AHBplayer);
373 
374  uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID);
375  if (randomPropertyId != 0)
376  item->SetItemRandomProperties(randomPropertyId);
377 
378  uint64 buyoutPrice = 0;
379  uint64 bidPrice = 0;
380  uint32 stackCount = 1;
381 
382  if (SellMethod == 0)
383  buyoutPrice = prototype->SellPrice;
384  else
385  buyoutPrice = prototype->BuyPrice;
386 
387  if (prototype->Quality <= AHB_MAX_QUALITY)
388  {
389  if (config->GetMaxStack(prototype->Quality) > 1 && item->GetMaxStackCount() > 1)
390  stackCount = urand(1, minValue(item->GetMaxStackCount(), config->GetMaxStack(prototype->Quality)));
391  else if (config->GetMaxStack(prototype->Quality) == 0 && item->GetMaxStackCount() > 1)
392  stackCount = urand(1, item->GetMaxStackCount());
393  else
394  stackCount = 1;
395  buyoutPrice *= urand(config->GetMinPrice(prototype->Quality), config->GetMaxPrice(prototype->Quality));
396  buyoutPrice /= 100;
397  bidPrice = buyoutPrice * urand(config->GetMinBidPrice(prototype->Quality), config->GetMaxBidPrice(prototype->Quality));
398  bidPrice /= 100;
399  }
400  else
401  {
402  // quality is something it shouldn't be, let's get out of here
403  if (debug_Out) sLog.outError("AHBuyer: Quality %u not Supported", prototype->Quality);
404  item->RemoveFromUpdateQueueOf(AHBplayer);
405  continue;
406  }
407 
408  uint32 etime = urand(1, 3);
409  switch (etime)
410  {
411  case 1:
412  etime = 43200;
413  break;
414  case 2:
415  etime = 86400;
416  break;
417  case 3:
418  etime = 172800;
419  break;
420  default:
421  etime = 86400;
422  break;
423  }
424  item->SetCount(stackCount);
425 
426  uint32 dep = sAuctionMgr->GetAuctionDeposit(ahEntry, etime, item);
427 
428  AuctionEntry* auctionEntry = new AuctionEntry;
429  auctionEntry->Id = sObjectMgr.GenerateAuctionID();
430  auctionEntry->auctioneer = AuctioneerGUID;
431  auctionEntry->item_guidlow = item->GetGUIDLow();
432  auctionEntry->item_template = item->GetEntry();
433  auctionEntry->owner = AHBplayer->GetGUIDLow();
434  auctionEntry->startbid = bidPrice * stackCount;
435  auctionEntry->buyout = buyoutPrice * stackCount;
436  auctionEntry->bidder = 0;
437  auctionEntry->bid = 0;
438  auctionEntry->deposit = dep;
439  auctionEntry->expire_time = (time_t) etime + time(NULL);
440  auctionEntry->auctionHouseEntry = ahEntry;
441  item->SaveToDB();
442  item->RemoveFromUpdateQueueOf(AHBplayer);
443  sAuctionMgr->AddAItem(item);
444  auctionHouse->AddAuction(auctionEntry);
445  auctionEntry->SaveToDB();
446 
447  switch (itemColor)
448  {
449  case 0:
450  ++greyItems;
451  break;
452  case 1:
453  ++whiteItems;
454  break;
455  case 2:
456  ++greenItems;
457  break;
458  case 3:
459  ++blueItems;
460  break;
461  case 4:
462  ++purpleItems;
463  break;
464  case 5:
465  ++orangeItems;
466  break;
467  case 6:
468  ++yellowItems;
469  break;
470  case 7:
471  ++greyTGoods;
472  break;
473  case 8:
474  ++whiteTGoods;
475  break;
476  case 9:
477  ++greenTGoods;
478  break;
479  case 10:
480  ++blueTGoods;
481  break;
482  case 11:
483  ++purpleTGoods;
484  break;
485  case 12:
486  ++orangeTGoods;
487  break;
488  case 13:
489  ++yellowTGoods;
490  break;
491  default:
492  break;
493  }
494  }
495  }
496 }
498 {
499  if (!AHBBuyer)
500  {
501  if (debug_Out) sLog.outError("AHBuyer: Disabled");
502  return;
503  }
504 
505  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE itemowner<>%u AND buyguid<>%u", AHBplayerGUID, AHBplayerGUID);
506 
507  if (!result)
508  return;
509 
510  if (result->GetRowCount() == 0)
511  return;
512 
513  // Fetches content of selected AH
514  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
515  vector<uint32> possibleBids;
516 
517  do
518  {
519  uint32 tmpdata = result->Fetch()->GetUInt32();
520  possibleBids.push_back(tmpdata);
521  }
522  while (result->NextRow());
523 
524  for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count)
525  {
526  // Do we have anything to bid? If not, stop here.
527  if (possibleBids.empty())
528  {
529  //if (debug_Out) sLog.outString("AHBuyer: I have no items to bid on.");
530  count = config->GetBidsPerInterval();
531  continue;
532  }
533 
534  // Choose random auction from possible auctions
535  uint32 vectorPos = urand(0, possibleBids.size() - 1);
536  vector<uint32>::iterator iter = possibleBids.begin();
537  advance(iter, vectorPos);
538 
539  // from auctionhousehandler.cpp, creates auction pointer & player pointer
540  AuctionEntry* auction = auctionHouse->GetAuction(*iter);
541 
542  // Erase the auction from the vector to prevent bidding on item in next iteration.
543  possibleBids.erase(iter);
544 
545  if (!auction)
546  continue;
547 
548  // get exact item information
549  Item* pItem = sAuctionMgr->GetAItem(auction->item_guidlow);
550  if (!pItem)
551  {
552  if (debug_Out) sLog.outError("AHBuyer: Item %u doesn't exist, perhaps bought already?", auction->item_guidlow);
553  continue;
554  }
555 
556  // get item prototype
557  ItemTemplate const* prototype = sObjectMgr.GetItemTemplate(auction->item_template);
558 
559  // check which price we have to use, startbid or if it is bidded already
560  uint32 currentprice;
561  if (auction->bid)
562  currentprice = auction->bid;
563  else
564  currentprice = auction->startbid;
565 
566  // Prepare portion from maximum bid
567  double bidrate = static_cast<double>(urand(1, 100)) / 100;
568  long double bidMax = 0;
569 
570  // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality
571  if (BuyMethod == 0)
572  {
573  if ((prototype->Quality <= AHB_MAX_QUALITY))
574  {
575  if (currentprice < prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality))
576  bidMax = prototype->SellPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality);
577  }
578  else
579  {
580  // quality is something it shouldn't be, let's get out of here
581  if (debug_Out) sLog.outError("AHBuyer: Quality %u not Supported", prototype->Quality);
582  continue;
583  }
584  }
585  else
586  {
587  if ((prototype->Quality <= AHB_MAX_QUALITY))
588  {
589  if (currentprice < prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality))
590  bidMax = prototype->BuyPrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality);
591  }
592  else
593  {
594  // quality is something it shouldn't be, let's get out of here
595  if (debug_Out) sLog.outError("AHBuyer: Quality %u not Supported", prototype->Quality);
596  continue;
597  }
598  }
599 
600  // check some special items, and do recalculating to their prices
601  switch (prototype->Class)
602  {
603  // ammo
604  case 6:
605  bidMax = 0;
606  break;
607  default:
608  break;
609  }
610 
611  if (bidMax == 0)
612  {
613  // quality check failed to get bidmax, let's get out of here
614  continue;
615  }
616 
617  // Calculate our bid
618  long double bidvalue = currentprice + ((bidMax - currentprice) * bidrate);
619  // Convert to uint32
620  uint32 bidprice = static_cast<uint32>(bidvalue);
621 
622  // Check our bid is high enough to be valid. If not, correct it to minimum.
623  if ((currentprice + auction->GetAuctionOutBid()) > bidprice)
624  bidprice = currentprice + auction->GetAuctionOutBid();
625 
626  if (debug_Out)
627  {
628  sLog.outString("-------------------------------------------------");
629  sLog.outString("AHBuyer: Info for Auction #%u:", auction->Id);
630  sLog.outString("AHBuyer: AuctionHouse: %u", auction->GetHouseId());
631  sLog.outString("AHBuyer: Auctioneer: %u", auction->auctioneer);
632  sLog.outString("AHBuyer: Owner: %u", auction->owner);
633  sLog.outString("AHBuyer: Bidder: %u", auction->bidder);
634  sLog.outString("AHBuyer: Starting Bid: %u", auction->startbid);
635  sLog.outString("AHBuyer: Current Bid: %u", currentprice);
636  sLog.outString("AHBuyer: Buyout: %u", auction->buyout);
637  sLog.outString("AHBuyer: Deposit: %u", auction->deposit);
638  sLog.outString("AHBuyer: Expire Time: %u", uint32(auction->expire_time));
639  sLog.outString("AHBuyer: Bid Rate: %f", bidrate);
640  sLog.outString("AHBuyer: Bid Max: %Lf", bidMax);
641  sLog.outString("AHBuyer: Bid Value: %Lf", bidvalue);
642  sLog.outString("AHBuyer: Bid Price: %u", bidprice);
643  sLog.outString("AHBuyer: Item GUID: %u", auction->item_guidlow);
644  sLog.outString("AHBuyer: Item Template: %u", auction->item_template);
645  sLog.outString("AHBuyer: Item Info:");
646  sLog.outString("AHBuyer: Item ID: %u", prototype->ItemId);
647  sLog.outString("AHBuyer: Buy Price: %u", prototype->BuyPrice);
648  sLog.outString("AHBuyer: Sell Price: %u", prototype->SellPrice);
649  sLog.outString("AHBuyer: Bonding: %u", prototype->Bonding);
650  sLog.outString("AHBuyer: Quality: %u", prototype->Quality);
651  sLog.outString("AHBuyer: Item Level: %u", prototype->ItemLevel);
652  sLog.outString("AHBuyer: Ammo Type: %u", prototype->AmmoType);
653  sLog.outString("-------------------------------------------------");
654  }
655 
656  // Check whether we do normal bid, or buyout
657  if ((bidprice < auction->buyout) || (auction->buyout == 0))
658  {
659 
660  if (auction->bidder > 0)
661  {
662  if (auction->bidder == AHBplayer->GetGUIDLow())
663  {
664  //pl->ModifyMoney(-int32(price - auction->bid));
665  }
666  else
667  {
668  // mail to last bidder and return money
669  session->SendAuctionOutbiddedMail(auction , bidprice);
670  //pl->ModifyMoney(-int32(price));
671  }
672  }
673 
674  auction->bidder = AHBplayer->GetGUIDLow();
675  auction->bid = bidprice;
676 
677  // Saving auction into database
678  CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
679  }
680  else
681  {
682  //buyout
683  if ((auction->bidder) && (AHBplayer->GetGUIDLow() != auction->bidder))
684  session->SendAuctionOutbiddedMail(auction, auction->buyout);
685  auction->bidder = AHBplayer->GetGUIDLow();
686  auction->bid = auction->buyout;
687 
688  // Send mails to buyer & seller
689  sAuctionMgr->SendAuctionSalePendingMail(auction);
690  sAuctionMgr->SendAuctionSuccessfulMail(auction);
691  sAuctionMgr->SendAuctionWonMail(auction);
692  auction->DeleteFromDB();
693  uint32 item_template = auction->item_template;
694  sAuctionMgr->RemoveAItem(auction->item_guidlow);
695  auctionHouse->RemoveAuction(auction, item_template);
696  }
697  }
698 }
699 
701 {
702  time_t _newrun = time(NULL);
703  if ((!AHBSeller) && (!AHBBuyer))
704  return;
705 
706  WorldSession _session(AHBplayerAccount, NULL, SEC_PLAYER, true, 0, LOCALE_enUS);
707  Player _AHBplayer(&_session);
708  _AHBplayer.Initialize(AHBplayerGUID);
709  ObjectAccessor::Instance().AddObject(&_AHBplayer);
710 
711  // Add New Bids
713  {
714  addNewAuctions(&_AHBplayer, &AllianceConfig);
715  if (((_newrun - _lastrun_a) >= (AllianceConfig.GetBiddingInterval() * MINUTE)) && (AllianceConfig.GetBidsPerInterval() > 0))
716  {
717  //if (debug_Out) sLog.outString("AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_a));
718  //if (debug_Out) sLog.outString("AHBuyer: Bidding on Alliance Auctions");
719  addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig, &_session);
720  _lastrun_a = _newrun;
721  }
722 
723  addNewAuctions(&_AHBplayer, &HordeConfig);
724  if (((_newrun - _lastrun_h) >= (HordeConfig.GetBiddingInterval() * MINUTE)) && (HordeConfig.GetBidsPerInterval() > 0))
725  {
726  //if (debug_Out) sLog.outString("AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_h));
727  //if (debug_Out) sLog.outString("AHBuyer: Bidding on Horde Auctions");
728  addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig, &_session);
729  _lastrun_h = _newrun;
730  }
731  }
732 
733  addNewAuctions(&_AHBplayer, &NeutralConfig);
734  if (((_newrun - _lastrun_n) >= (NeutralConfig.GetBiddingInterval() * MINUTE)) && (NeutralConfig.GetBidsPerInterval() > 0))
735  {
736  //if (debug_Out) sLog.outString("AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_n));
737  //if (debug_Out) sLog.outString("AHBuyer: Bidding on Neutral Auctions");
738  addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session);
739  _lastrun_n = _newrun;
740  }
741  ObjectAccessor::Instance().RemoveObject(&_AHBplayer);
742 }
743 
745 {
746  debug_Out = sConfig.GetBoolDefault("AuctionHouseBot.DEBUG", false);
747  debug_Out_Filters = sConfig.GetBoolDefault("AuctionHouseBot.DEBUG_FILTERS", false);
748 
749  AHBSeller = sConfig.GetBoolDefault("AuctionHouseBot.EnableSeller", false);
750  AHBBuyer = sConfig.GetBoolDefault("AuctionHouseBot.EnableBuyer", false);
751  SellMethod = sConfig.GetBoolDefault("AuctionHouseBot.UseBuyPriceForSeller", false);
752  BuyMethod = sConfig.GetBoolDefault("AuctionHouseBot.UseBuyPriceForBuyer", false);
753 
754  AHBplayerAccount = sConfig.GetIntDefault("AuctionHouseBot.Account", 0);
755  AHBplayerGUID = sConfig.GetIntDefault("AuctionHouseBot.GUID", 0);
756  ItemsPerCycle = sConfig.GetIntDefault("AuctionHouseBot.ItemsPerCycle", 200);
757 
758  //Begin Filters
759 
760  Vendor_Items = sConfig.GetBoolDefault("AuctionHouseBot.VendorItems", false);
761  Loot_Items = sConfig.GetBoolDefault("AuctionHouseBot.LootItems", true);
762  Other_Items = sConfig.GetBoolDefault("AuctionHouseBot.OtherItems", false);
763  Vendor_TGs = sConfig.GetBoolDefault("AuctionHouseBot.VendorTradeGoods", false);
764  Loot_TGs = sConfig.GetBoolDefault("AuctionHouseBot.LootTradeGoods", true);
765  Other_TGs = sConfig.GetBoolDefault("AuctionHouseBot.OtherTradeGoods", false);
766 
767  No_Bind = sConfig.GetBoolDefault("AuctionHouseBot.No_Bind", true);
768  Bind_When_Picked_Up = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Picked_Up", false);
769  Bind_When_Equipped = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Equipped", true);
770  Bind_When_Use = sConfig.GetBoolDefault("AuctionHouseBot.Bind_When_Use", true);
771  Bind_Quest_Item = sConfig.GetBoolDefault("AuctionHouseBot.Bind_Quest_Item", false);
772 
773  DisableBeta_PTR_Unused = sConfig.GetBoolDefault("AuctionHouseBot.DisableBeta_PTR_Unused", false);
774  DisablePermEnchant = sConfig.GetBoolDefault("AuctionHouseBot.DisablePermEnchant", false);
775  DisableGems = sConfig.GetBoolDefault("AuctionHouseBot.DisableGems", false);
776  DisableMoney = sConfig.GetBoolDefault("AuctionHouseBot.DisableMoney", false);
777  DisableMoneyLoot = sConfig.GetBoolDefault("AuctionHouseBot.DisableMoneyLoot", false);
778  DisableLootable = sConfig.GetBoolDefault("AuctionHouseBot.DisableLootable", false);
779  DisableKeys = sConfig.GetBoolDefault("AuctionHouseBot.DisableKeys", false);
780  DisableDuration = sConfig.GetBoolDefault("AuctionHouseBot.DisableDuration", false);
781  DisableBOP_Or_Quest_NoReqLevel = sConfig.GetBoolDefault("AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel", false);
782 
783  DisableWarriorItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableWarriorItems", false);
784  DisablePaladinItems = sConfig.GetBoolDefault("AuctionHouseBot.DisablePaladinItems", false);
785  DisableHunterItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableHunterItems", false);
786  DisableRogueItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableRogueItems", false);
787  DisablePriestItems = sConfig.GetBoolDefault("AuctionHouseBot.DisablePriestItems", false);
788  DisableDKItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableDKItems", false);
789  DisableShamanItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableShamanItems", false);
790  DisableMageItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableMageItems", false);
791  DisableWarlockItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableWarlockItems", false);
792  DisableUnusedClassItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableUnusedClassItems", false);
793  DisableDruidItems = sConfig.GetBoolDefault("AuctionHouseBot.DisableDruidItems", false);
794 
795  DisableItemsBelowLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsBelowLevel", 0);
796  DisableItemsAboveLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsAboveLevel", 0);
797  DisableTGsBelowLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsBelowLevel", 0);
798  DisableTGsAboveLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsAboveLevel", 0);
799  DisableItemsBelowGUID = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsBelowGUID", 0);
800  DisableItemsAboveGUID = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsAboveGUID", 0);
801  DisableTGsBelowGUID = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsBelowGUID", 0);
802  DisableTGsAboveGUID = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsAboveGUID", 0);
803  DisableItemsBelowReqLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsBelowReqLevel", 0);
804  DisableItemsAboveReqLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsAboveReqLevel", 0);
805  DisableTGsBelowReqLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsBelowReqLevel", 0);
806  DisableTGsAboveReqLevel = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsAboveReqLevel", 0);
807  DisableItemsBelowReqSkillRank = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsBelowReqSkillRank", 0);
808  DisableItemsAboveReqSkillRank = sConfig.GetIntDefault("AuctionHouseBot.DisableItemsAboveReqSkillRank", 0);
809  DisableTGsBelowReqSkillRank = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsBelowReqSkillRank", 0);
810  DisableTGsAboveReqSkillRank = sConfig.GetIntDefault("AuctionHouseBot.DisableTGsAboveReqSkillRank", 0);
811 
812  //End Filters
814  {
815  LoadValues(&AllianceConfig);
816  LoadValues(&HordeConfig);
817  }
818  LoadValues(&NeutralConfig);
819 
820  //
821  // check if the AHBot account/GUID in the config actually exists
822  //
823 
824  if ((AHBplayerAccount != 0) || (AHBplayerGUID != 0))
825  {
826  QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT 1 FROM characters WHERE account = %u AND guid = %u", AHBplayerAccount, AHBplayerGUID);
827  if (!result)
828  {
829  sLog.outError("AuctionHouseBot: The account/GUID-information set for your AHBot is incorrect (account: %u guid: %u)", AHBplayerAccount, AHBplayerGUID);
830  return;
831  }
832  }
833 
834  if (AHBSeller)
835  {
837  char npcQuery[] = "SELECT distinct item FROM npc_vendor";
838  results = WorldDatabase.Query(npcQuery);
839  if (results)
840  {
841  do
842  {
843  Field* fields = results->Fetch();
844  npcItems.push_back(fields[0].GetUInt32());
845 
846  }
847  while (results->NextRow());
848  }
849  else
850  {
851  if (debug_Out) sLog.outString("AuctionHouseBot: \"%s\" failed", npcQuery);
852  }
853 
854  char lootQuery[] = "SELECT item FROM creature_loot_template UNION "
855  "SELECT item FROM reference_loot_template UNION "
856  "SELECT item FROM disenchant_loot_template UNION "
857  "SELECT item FROM fishing_loot_template UNION "
858  "SELECT item FROM gameobject_loot_template UNION "
859  "SELECT item FROM item_loot_template UNION "
860  "SELECT item FROM pickpocketing_loot_template UNION "
861  "SELECT item FROM prospecting_loot_template UNION "
862  "SELECT item FROM skinning_loot_template";
863 
864  results = WorldDatabase.Query(lootQuery);
865  if (results)
866  {
867  do
868  {
869  Field* fields = results->Fetch();
870  lootItems.push_back(fields[0].GetUInt32());
871 
872  }
873  while (results->NextRow());
874  }
875  else
876  {
877  if (debug_Out) sLog.outString("AuctionHouseBot: \"%s\" failed", lootQuery);
878  }
879 
880  for (uint32 itemID = 0; itemID < sItemStorage.MaxEntry; itemID++)
881  {
882  ItemTemplate const* prototype = sObjectMgr.GetItemTemplate(itemID);
883 
884  if (prototype == NULL)
885  continue;
886 
887  switch (prototype->Bonding)
888  {
889  case NO_BIND:
890  if (!No_Bind)
891  continue;
892  break;
893  case BIND_WHEN_PICKED_UP:
894  if (!Bind_When_Picked_Up)
895  continue;
896  break;
897  case BIND_WHEN_EQUIPED:
898  if (!Bind_When_Equipped)
899  continue;
900  break;
901  case BIND_WHEN_USE:
902  if (!Bind_When_Use)
903  continue;
904  break;
905  case BIND_QUEST_ITEM:
906  if (!Bind_Quest_Item)
907  continue;
908  break;
909  default:
910  continue;
911  break;
912  }
913 
914  if (SellMethod == 0)
915  {
916  if (prototype->SellPrice == 0)
917  continue;
918  }
919  else
920  {
921  if (prototype->BuyPrice == 0)
922  continue;
923  }
924 
925  if (prototype->Quality > 6)
926  continue;
927 
928  if ((Vendor_Items == 0) && !(prototype->Class == ITEM_CLASS_TRADE_GOODS))
929  {
930  bool isVendorItem = false;
931 
932  for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
933  {
934  if (itemID == npcItems[i])
935  isVendorItem = true;
936  }
937 
938  if (isVendorItem)
939  continue;
940  }
941 
942  if ((Vendor_TGs == 0) && (prototype->Class == ITEM_CLASS_TRADE_GOODS))
943  {
944  bool isVendorTG = false;
945 
946  for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorTG); i++)
947  {
948  if (itemID == npcItems[i])
949  isVendorTG = true;
950  }
951 
952  if (isVendorTG)
953  continue;
954  }
955 
956  if ((Loot_Items == 0) && !(prototype->Class == ITEM_CLASS_TRADE_GOODS))
957  {
958  bool isLootItem = false;
959 
960  for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
961  {
962  if (itemID == lootItems[i])
963  isLootItem = true;
964  }
965 
966  if (isLootItem)
967  continue;
968  }
969 
970  if ((Loot_TGs == 0) && (prototype->Class == ITEM_CLASS_TRADE_GOODS))
971  {
972  bool isLootTG = false;
973 
974  for (unsigned int i = 0; (i < lootItems.size()) && (!isLootTG); i++)
975  {
976  if (itemID == lootItems[i])
977  isLootTG = true;
978  }
979 
980  if (isLootTG)
981  continue;
982  }
983 
984  if ((Other_Items == 0) && !(prototype->Class == ITEM_CLASS_TRADE_GOODS))
985  {
986  bool isVendorItem = false;
987  bool isLootItem = false;
988 
989  for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)
990  {
991  if (itemID == npcItems[i])
992  isVendorItem = true;
993  }
994  for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)
995  {
996  if (itemID == lootItems[i])
997  isLootItem = true;
998  }
999  if ((!isLootItem) && (!isVendorItem))
1000  continue;
1001  }
1002 
1003  if ((Other_TGs == 0) && (prototype->Class == ITEM_CLASS_TRADE_GOODS))
1004  {
1005  bool isVendorTG = false;
1006  bool isLootTG = false;
1007 
1008  for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorTG); i++)
1009  {
1010  if (itemID == npcItems[i])
1011  isVendorTG = true;
1012  }
1013  for (unsigned int i = 0; (i < lootItems.size()) && (!isLootTG); i++)
1014  {
1015  if (itemID == lootItems[i])
1016  isLootTG = true;
1017  }
1018  if ((!isLootTG) && (!isVendorTG))
1019  continue;
1020  }
1021 
1022  //@todoMake list of items and create a vector
1023  // Disable PTR/Beta/Unused items
1024  if ((DisableBeta_PTR_Unused) && ((prototype->ItemId == 21878) || (prototype->ItemId == 27774) || (prototype->ItemId == 27811) || (prototype->ItemId == 28117) || (prototype->ItemId == 28112)))
1025  {
1026  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (PTR/Beta/Unused Item)", prototype->ItemId);
1027  continue;
1028  }
1029 
1030  // Disable permanent enchants items
1031  if ((DisablePermEnchant) && (prototype->Class == ITEM_CLASS_PERMANENT))
1032  {
1033  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Permanent Enchant Item)", prototype->ItemId);
1034  continue;
1035  }
1036  // Disable gems
1037  if ((DisableGems) && (prototype->Class == ITEM_CLASS_GEM))
1038  {
1039  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Gem)", prototype->ItemId);
1040  continue;
1041  }
1042 
1043  // Disable money
1044  if ((DisableMoney) && (prototype->Class == ITEM_CLASS_MONEY))
1045  {
1046  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Money)", prototype->ItemId);
1047  continue;
1048  }
1049 
1050  // Disable moneyloot
1051  if ((DisableMoneyLoot) && (prototype->MinMoneyLoot > 0))
1052  {
1053  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (MoneyLoot)", prototype->ItemId);
1054  continue;
1055  }
1056 
1057  // Disable lootable items
1058  if ((DisableLootable) && (prototype->Flags & 4))
1059  {
1060  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Lootable Item)", prototype->ItemId);
1061  continue;
1062  }
1063 
1064  // Disable Keys
1065  if ((DisableKeys) && (prototype->Class == ITEM_CLASS_KEY))
1066  {
1067  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Quest Item)", prototype->ItemId);
1068  continue;
1069  }
1070 
1071  // Disable items with duration
1072  if ((DisableDuration) && (prototype->Duration > 0))
1073  {
1074  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Has a Duration)", prototype->ItemId);
1075  continue;
1076  }
1077 
1078  // Disable items which are BOP or Quest Items and have a required level lower than the item level
1079  if ((DisableBOP_Or_Quest_NoReqLevel) && ((prototype->Bonding == BIND_WHEN_PICKED_UP || prototype->Bonding == BIND_QUEST_ITEM) && (prototype->RequiredLevel < prototype->ItemLevel)))
1080  {
1081  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (BOP or BQI and Required Level is less than Item Level)", prototype->ItemId);
1082  continue;
1083  }
1084 
1085  // Disable items specifically for Warrior
1086  if ((DisableWarriorItems) && (prototype->AllowableClass == 1))
1087  {
1088  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Warrior Item)", prototype->ItemId);
1089  continue;
1090  }
1091 
1092  // Disable items specifically for Paladin
1093  if ((DisablePaladinItems) && (prototype->AllowableClass == 2))
1094  {
1095  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Paladin Item)", prototype->ItemId);
1096  continue;
1097  }
1098 
1099  // Disable items specifically for Hunter
1100  if ((DisableHunterItems) && (prototype->AllowableClass == 4))
1101  {
1102  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Hunter Item)", prototype->ItemId);
1103  continue;
1104  }
1105 
1106  // Disable items specifically for Rogue
1107  if ((DisableRogueItems) && (prototype->AllowableClass == 8))
1108  {
1109  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Rogue Item)", prototype->ItemId);
1110  continue;
1111  }
1112 
1113  // Disable items specifically for Priest
1114  if ((DisablePriestItems) && (prototype->AllowableClass == 16))
1115  {
1116  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Priest Item)", prototype->ItemId);
1117  continue;
1118  }
1119 
1120  // Disable items specifically for DK
1121  if ((DisableDKItems) && (prototype->AllowableClass == 32))
1122  {
1123  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (DK Item)", prototype->ItemId);
1124  continue;
1125  }
1126 
1127  // Disable items specifically for Shaman
1128  if ((DisableShamanItems) && (prototype->AllowableClass == 64))
1129  {
1130  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Shaman Item)", prototype->ItemId);
1131  continue;
1132  }
1133 
1134  // Disable items specifically for Mage
1135  if ((DisableMageItems) && (prototype->AllowableClass == 128))
1136  {
1137  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Mage Item)", prototype->ItemId);
1138  continue;
1139  }
1140 
1141  // Disable items specifically for Warlock
1142  if ((DisableWarlockItems) && (prototype->AllowableClass == 256))
1143  {
1144  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Warlock Item)", prototype->ItemId);
1145  continue;
1146  }
1147 
1148  // Disable items specifically for Unused Class
1149  if ((DisableUnusedClassItems) && (prototype->AllowableClass == 512))
1150  {
1151  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Unused Item)", prototype->ItemId);
1152  continue;
1153  }
1154 
1155  // Disable items specifically for Druid
1156  if ((DisableDruidItems) && (prototype->AllowableClass == 1024))
1157  {
1158  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Druid Item)", prototype->ItemId);
1159  continue;
1160  }
1161 
1162  // Disable Items below level X
1163  if ((DisableItemsBelowLevel) && (prototype->Class != ITEM_CLASS_TRADE_GOODS) && (prototype->ItemLevel < DisableItemsBelowLevel))
1164  {
1165  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Item Level = %u)", prototype->ItemId, prototype->ItemLevel);
1166  continue;
1167  }
1168 
1169  // Disable Items above level X
1170  if ((DisableItemsAboveLevel) && (prototype->Class != ITEM_CLASS_TRADE_GOODS) && (prototype->ItemLevel > DisableItemsAboveLevel))
1171  {
1172  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Item Level = %u)", prototype->ItemId, prototype->ItemLevel);
1173  continue;
1174  }
1175 
1176  // Disable Trade Goods below level X
1177  if ((DisableTGsBelowLevel) && (prototype->Class == ITEM_CLASS_TRADE_GOODS) && (prototype->ItemLevel < DisableTGsBelowLevel))
1178  {
1179  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Trade Good %u disabled (Trade Good Level = %u)", prototype->ItemId, prototype->ItemLevel);
1180  continue;
1181  }
1182 
1183  // Disable Trade Goods above level X
1184  if ((DisableTGsAboveLevel) && (prototype->Class == ITEM_CLASS_TRADE_GOODS) && (prototype->ItemLevel > DisableTGsAboveLevel))
1185  {
1186  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Trade Good %u disabled (Trade Good Level = %u)", prototype->ItemId, prototype->ItemLevel);
1187  continue;
1188  }
1189 
1190  // Disable Items below GUID X
1191  if ((DisableItemsBelowGUID) && (prototype->Class != ITEM_CLASS_TRADE_GOODS) && (prototype->ItemId < DisableItemsBelowGUID))
1192  {
1193  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Item Level = %u)", prototype->ItemId, prototype->ItemLevel);
1194  continue;
1195  }
1196 
1197  // Disable Items above GUID X
1198  if ((DisableItemsAboveGUID) && (prototype->Class != ITEM_CLASS_TRADE_GOODS) && (prototype->ItemId > DisableItemsAboveGUID))
1199  {
1200  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Item Level = %u)", prototype->ItemId, prototype->ItemLevel);
1201  continue;
1202  }
1203 
1204  // Disable Trade Goods below GUID X
1205  if ((DisableTGsBelowGUID) && (prototype->Class == ITEM_CLASS_TRADE_GOODS) && (prototype->ItemId < DisableTGsBelowGUID))
1206  {
1207  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Trade Good Level = %u)", prototype->ItemId, prototype->ItemLevel);
1208  continue;
1209  }
1210 
1211  // Disable Trade Goods above GUID X
1212  if ((DisableTGsAboveGUID) && (prototype->Class == ITEM_CLASS_TRADE_GOODS) && (prototype->ItemId > DisableTGsAboveGUID))
1213  {
1214  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (Trade Good Level = %u)", prototype->ItemId, prototype->ItemLevel);
1215  continue;
1216  }
1217 
1218  // Disable Items for level lower than X
1219  if ((DisableItemsBelowReqLevel) && (prototype->RequiredLevel < DisableItemsBelowReqLevel))
1220  {
1221  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredLevel = %u)", prototype->ItemId, prototype->RequiredLevel);
1222  continue;
1223  }
1224 
1225  // Disable Items for level higher than X
1226  if ((DisableItemsAboveReqLevel) && (prototype->RequiredLevel > DisableItemsAboveReqLevel))
1227  {
1228  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredLevel = %u)", prototype->ItemId, prototype->RequiredLevel);
1229  continue;
1230  }
1231 
1232  // Disable Trade Goods for level lower than X
1233  if ((DisableTGsBelowReqLevel) && (prototype->RequiredLevel < DisableTGsBelowReqLevel))
1234  {
1235  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Trade Good %u disabled (RequiredLevel = %u)", prototype->ItemId, prototype->RequiredLevel);
1236  continue;
1237  }
1238 
1239  // Disable Trade Goods for level higher than X
1240  if ((DisableTGsAboveReqLevel) && (prototype->RequiredLevel > DisableTGsAboveReqLevel))
1241  {
1242  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Trade Good %u disabled (RequiredLevel = %u)", prototype->ItemId, prototype->RequiredLevel);
1243  continue;
1244  }
1245 
1246  // Disable Items that require skill lower than X
1247  if ((DisableItemsBelowReqSkillRank) && (prototype->RequiredSkillRank < DisableItemsBelowReqSkillRank))
1248  {
1249  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", prototype->ItemId, prototype->RequiredSkillRank);
1250  continue;
1251  }
1252 
1253  // Disable Items that require skill higher than X
1254  if ((DisableItemsAboveReqSkillRank) && (prototype->RequiredSkillRank > DisableItemsAboveReqSkillRank))
1255  {
1256  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", prototype->ItemId, prototype->RequiredSkillRank);
1257  continue;
1258  }
1259 
1260  // Disable Trade Goods that require skill lower than X
1261  if ((DisableTGsBelowReqSkillRank) && (prototype->RequiredSkillRank < DisableTGsBelowReqSkillRank))
1262  {
1263  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", prototype->ItemId, prototype->RequiredSkillRank);
1264  continue;
1265  }
1266 
1267  // Disable Trade Goods that require skill higher than X
1268  if ((DisableTGsAboveReqSkillRank) && (prototype->RequiredSkillRank > DisableTGsAboveReqSkillRank))
1269  {
1270  if (debug_Out_Filters) sLog.outString("AuctionHouseBot: Item %u disabled (RequiredSkillRank = %u)", prototype->ItemId, prototype->RequiredSkillRank);
1271  continue;
1272  }
1273 
1274  switch (prototype->Quality)
1275  {
1276  case AHB_GREY:
1277  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1278  greyTradeGoodsBin.push_back(itemID);
1279  else
1280  greyItemsBin.push_back(itemID);
1281  break;
1282 
1283  case AHB_WHITE:
1284  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1285  whiteTradeGoodsBin.push_back(itemID);
1286  else
1287  whiteItemsBin.push_back(itemID);
1288  break;
1289 
1290  case AHB_GREEN:
1291  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1292  greenTradeGoodsBin.push_back(itemID);
1293  else
1294  greenItemsBin.push_back(itemID);
1295  break;
1296 
1297  case AHB_BLUE:
1298  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1299  blueTradeGoodsBin.push_back(itemID);
1300  else
1301  blueItemsBin.push_back(itemID);
1302  break;
1303 
1304  case AHB_PURPLE:
1305  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1306  purpleTradeGoodsBin.push_back(itemID);
1307  else
1308  purpleItemsBin.push_back(itemID);
1309  break;
1310 
1311  case AHB_ORANGE:
1312  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1313  orangeTradeGoodsBin.push_back(itemID);
1314  else
1315  orangeItemsBin.push_back(itemID);
1316  break;
1317 
1318  case AHB_YELLOW:
1319  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1320  yellowTradeGoodsBin.push_back(itemID);
1321  else
1322  yellowItemsBin.push_back(itemID);
1323  break;
1324  }
1325  }
1326 
1327  if ((greyTradeGoodsBin.size() == 0) &&
1328  (whiteTradeGoodsBin.size() == 0) &&
1329  (greenTradeGoodsBin.size() == 0) &&
1330  (blueTradeGoodsBin.size() == 0) &&
1331  (purpleTradeGoodsBin.size() == 0) &&
1332  (orangeTradeGoodsBin.size() == 0) &&
1333  (yellowTradeGoodsBin.size() == 0) &&
1334  (greyItemsBin.size() == 0) &&
1335  (whiteItemsBin.size() == 0) &&
1336  (greenItemsBin.size() == 0) &&
1337  (blueItemsBin.size() == 0) &&
1338  (purpleItemsBin.size() == 0) &&
1339  (orangeItemsBin.size() == 0) &&
1340  (yellowItemsBin.size() == 0))
1341  {
1342  sLog.outError("AuctionHouseBot: No items");
1343  AHBSeller = 0;
1344  }
1345 
1346  sLog.outString("AuctionHouseBot:");
1347  sLog.outString("loaded " UI64FMTD " grey trade goods", greyTradeGoodsBin.size());
1348  sLog.outString("loaded " UI64FMTD " white trade goods", whiteTradeGoodsBin.size());
1349  sLog.outString("loaded " UI64FMTD " green trade goods", greenTradeGoodsBin.size());
1350  sLog.outString("loaded " UI64FMTD " blue trade goods", blueTradeGoodsBin.size());
1351  sLog.outString("loaded " UI64FMTD " purple trade goods", purpleTradeGoodsBin.size());
1352  sLog.outString("loaded " UI64FMTD " orange trade goods", orangeTradeGoodsBin.size());
1353  sLog.outString("loaded " UI64FMTD " yellow trade goods", yellowTradeGoodsBin.size());
1354  sLog.outString("loaded " UI64FMTD " grey items", greyItemsBin.size());
1355  sLog.outString("loaded " UI64FMTD " white items", whiteItemsBin.size());
1356  sLog.outString("loaded " UI64FMTD " green items", greenItemsBin.size());
1357  sLog.outString("loaded " UI64FMTD " blue items", blueItemsBin.size());
1358  sLog.outString("loaded " UI64FMTD " purple items", purpleItemsBin.size());
1359  sLog.outString("loaded " UI64FMTD " orange items", orangeItemsBin.size());
1360  sLog.outString("loaded " UI64FMTD " yellow items", yellowItemsBin.size());
1361  }
1362  sLog.outString("AuctionHouseBot and AuctionHouseBuyer have been loaded.");
1363 }
1364 
1366 {
1367  // from auctionhousehandler.cpp, creates auction pointer & player pointer
1368 
1369  // get exact item information
1370  Item* pItem = sAuctionMgr->GetAItem(ah->item_guidlow);
1371  if (!pItem)
1372  {
1373  if (debug_Out) sLog.outError("AHBot: Item %u doesn't exist, perhaps bought already?", ah->item_guidlow);
1374  return;
1375  }
1376 
1377  // get item prototype
1378  ItemTemplate const* prototype = sObjectMgr.GetItemTemplate(ah->item_template);
1379 
1380  AHBConfig* config;
1381 
1382  FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseFaction());
1383  if (!u_entry)
1384  {
1385  if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
1386  config = &NeutralConfig;
1387  }
1388  else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
1389  {
1390  if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Alliance", ah->GetHouseFaction());
1391  config = &AllianceConfig;
1392  }
1393  else if (u_entry->ourMask & FACTION_MASK_HORDE)
1394  {
1395  if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Horde", ah->GetHouseFaction());
1396  config = &HordeConfig;
1397  }
1398  else
1399  {
1400  if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
1401  config = &NeutralConfig;
1402  }
1403 
1404  config->IncItemCounts(prototype->Class, prototype->Quality);
1405 }
1406 
1408 {
1409  // get item prototype
1410  ItemTemplate const* prototype = sObjectMgr.GetItemTemplate(item_template);
1411 
1412  AHBConfig* config;
1413 
1414  FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(ah->GetHouseFaction());
1415  if (!u_entry)
1416  {
1417  if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
1418  config = &NeutralConfig;
1419  }
1420  else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
1421  {
1422  if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Alliance", ah->GetHouseFaction());
1423  config = &AllianceConfig;
1424  }
1425  else if (u_entry->ourMask & FACTION_MASK_HORDE)
1426  {
1427  if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Horde", ah->GetHouseFaction());
1428  config = &HordeConfig;
1429  }
1430  else
1431  {
1432  if (debug_Out) sLog.outError("AHBot: %u returned as House Faction. Neutral", ah->GetHouseFaction());
1433  config = &NeutralConfig;
1434  }
1435 
1436  config->DecItemCounts(prototype->Class, prototype->Quality);
1437 }
1438 
1439 void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args)
1440 {
1441  AHBConfig* config = NULL;
1442  switch (ahMapID)
1443  {
1444  case 2:
1445  config = &AllianceConfig;
1446  break;
1447  case 6:
1448  config = &HordeConfig;
1449  break;
1450  case 7:
1451  config = &NeutralConfig;
1452  break;
1453  }
1454  std::string color;
1455  switch (col)
1456  {
1457  case AHB_GREY:
1458  color = "grey";
1459  break;
1460  case AHB_WHITE:
1461  color = "white";
1462  break;
1463  case AHB_GREEN:
1464  color = "green";
1465  break;
1466  case AHB_BLUE:
1467  color = "blue";
1468  break;
1469  case AHB_PURPLE:
1470  color = "purple";
1471  break;
1472  case AHB_ORANGE:
1473  color = "orange";
1474  break;
1475  case AHB_YELLOW:
1476  color = "yellow";
1477  break;
1478  default:
1479  break;
1480  }
1481  switch (command)
1482  {
1483  case 0: //ahexpire
1484  {
1485  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
1486 
1487  AuctionHouseObject::AuctionEntryMap::iterator itr;
1488  itr = auctionHouse->GetAuctionsBegin();
1489 
1490  while (itr != auctionHouse->GetAuctionsEnd())
1491  {
1492  if (itr->second->owner == AHBplayerGUID)
1493  {
1494  itr->second->expire_time = sWorld.GetGameTime();
1495  uint32 id = itr->second->Id;
1496  uint32 expire_time = itr->second->expire_time;
1497  CharacterDatabase.PExecute("UPDATE auctionhouse SET time = '%u' WHERE id = '%u'", expire_time, id);
1498  }
1499  ++itr;
1500  }
1501  }
1502  break;
1503  case 1: //min items
1504  {
1505  char* param1 = strtok(args, " ");
1506  uint32 minItems = (uint32) strtoul(param1, NULL, 0);
1507  CharacterDatabase.PExecute("UPDATE auctionhousebot SET minitems = '%u' WHERE auctionhouse = '%u'", minItems, ahMapID);
1508  config->SetMinItems(minItems);
1509  }
1510  break;
1511  case 2: //max items
1512  {
1513  char* param1 = strtok(args, " ");
1514  uint32 maxItems = (uint32) strtoul(param1, NULL, 0);
1515  CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxitems = '%u' WHERE auctionhouse = '%u'", maxItems, ahMapID);
1516  config->SetMaxItems(maxItems);
1517  config->CalculatePercents();
1518  }
1519  break;
1520  case 3: //min time Deprecated (Place holder for future commands)
1521  break;
1522  case 4: //max time Deprecated (Place holder for future commands)
1523  break;
1524  case 5: //percentages
1525  {
1526  char* param1 = strtok(args, " ");
1527  char* param2 = strtok(NULL, " ");
1528  char* param3 = strtok(NULL, " ");
1529  char* param4 = strtok(NULL, " ");
1530  char* param5 = strtok(NULL, " ");
1531  char* param6 = strtok(NULL, " ");
1532  char* param7 = strtok(NULL, " ");
1533  char* param8 = strtok(NULL, " ");
1534  char* param9 = strtok(NULL, " ");
1535  char* param10 = strtok(NULL, " ");
1536  char* param11 = strtok(NULL, " ");
1537  char* param12 = strtok(NULL, " ");
1538  char* param13 = strtok(NULL, " ");
1539  char* param14 = strtok(NULL, " ");
1540  uint32 greytg = (uint32) strtoul(param1, NULL, 0);
1541  uint32 whitetg = (uint32) strtoul(param2, NULL, 0);
1542  uint32 greentg = (uint32) strtoul(param3, NULL, 0);
1543  uint32 bluetg = (uint32) strtoul(param4, NULL, 0);
1544  uint32 purpletg = (uint32) strtoul(param5, NULL, 0);
1545  uint32 orangetg = (uint32) strtoul(param6, NULL, 0);
1546  uint32 yellowtg = (uint32) strtoul(param7, NULL, 0);
1547  uint32 greyi = (uint32) strtoul(param8, NULL, 0);
1548  uint32 whitei = (uint32) strtoul(param9, NULL, 0);
1549  uint32 greeni = (uint32) strtoul(param10, NULL, 0);
1550  uint32 bluei = (uint32) strtoul(param11, NULL, 0);
1551  uint32 purplei = (uint32) strtoul(param12, NULL, 0);
1552  uint32 orangei = (uint32) strtoul(param13, NULL, 0);
1553  uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
1554 
1556  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreytradegoods = '%u' WHERE auctionhouse = '%u'", greytg, ahMapID);
1557  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhitetradegoods = '%u' WHERE auctionhouse = '%u'", whitetg, ahMapID);
1558  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreentradegoods = '%u' WHERE auctionhouse = '%u'", greentg, ahMapID);
1559  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentbluetradegoods = '%u' WHERE auctionhouse = '%u'", bluetg, ahMapID);
1560  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpletradegoods = '%u' WHERE auctionhouse = '%u'", purpletg, ahMapID);
1561  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangetradegoods = '%u' WHERE auctionhouse = '%u'", orangetg, ahMapID);
1562  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowtradegoods = '%u' WHERE auctionhouse = '%u'", yellowtg, ahMapID);
1563  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreyitems = '%u' WHERE auctionhouse = '%u'", greyi, ahMapID);
1564  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentwhiteitems = '%u' WHERE auctionhouse = '%u'", whitei, ahMapID);
1565  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentgreenitems = '%u' WHERE auctionhouse = '%u'", greeni, ahMapID);
1566  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentblueitems = '%u' WHERE auctionhouse = '%u'", bluei, ahMapID);
1567  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentpurpleitems = '%u' WHERE auctionhouse = '%u'", purplei, ahMapID);
1568  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentorangeitems = '%u' WHERE auctionhouse = '%u'", orangei, ahMapID);
1569  CharacterDatabase.PExecute("UPDATE auctionhousebot SET percentyellowitems = '%u' WHERE auctionhouse = '%u'", yellowi, ahMapID);
1571  config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
1572  }
1573  break;
1574  case 6: //min prices
1575  {
1576  char* param1 = strtok(args, " ");
1577  uint32 minPrice = (uint32) strtoul(param1, NULL, 0);
1578  CharacterDatabase.PExecute("UPDATE auctionhousebot SET minprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), minPrice, ahMapID);
1579  config->SetMinPrice(col, minPrice);
1580  }
1581  break;
1582  case 7: //max prices
1583  {
1584  char* param1 = strtok(args, " ");
1585  uint32 maxPrice = (uint32) strtoul(param1, NULL, 0);
1586  CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), maxPrice, ahMapID);
1587  config->SetMaxPrice(col, maxPrice);
1588  }
1589  break;
1590  case 8: //min bid price
1591  {
1592  char* param1 = strtok(args, " ");
1593  uint32 minBidPrice = (uint32) strtoul(param1, NULL, 0);
1594  CharacterDatabase.PExecute("UPDATE auctionhousebot SET minbidprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), minBidPrice, ahMapID);
1595  config->SetMinBidPrice(col, minBidPrice);
1596  }
1597  break;
1598  case 9: //max bid price
1599  {
1600  char* param1 = strtok(args, " ");
1601  uint32 maxBidPrice = (uint32) strtoul(param1, NULL, 0);
1602  CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxbidprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), maxBidPrice, ahMapID);
1603  config->SetMaxBidPrice(col, maxBidPrice);
1604  }
1605  break;
1606  case 10: //max stacks
1607  {
1608  char* param1 = strtok(args, " ");
1609  uint32 maxStack = (uint32) strtoul(param1, NULL, 0);
1610  CharacterDatabase.PExecute("UPDATE auctionhousebot SET maxstack%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), maxStack, ahMapID);
1611  config->SetMaxStack(col, maxStack);
1612  }
1613  break;
1614  case 11: //buyer bid prices
1615  {
1616  char* param1 = strtok(args, " ");
1617  uint32 buyerPrice = (uint32) strtoul(param1, NULL, 0);
1618  CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerprice%s = '%u' WHERE auctionhouse = '%u'", color.c_str(), buyerPrice, ahMapID);
1619  config->SetBuyerPrice(col, buyerPrice);
1620  }
1621  break;
1622  case 12: //buyer bidding interval
1623  {
1624  char* param1 = strtok(args, " ");
1625  uint32 bidInterval = (uint32) strtoul(param1, NULL, 0);
1626  CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerbiddinginterval = '%u' WHERE auctionhouse = '%u'", bidInterval, ahMapID);
1627  config->SetBiddingInterval(bidInterval);
1628  }
1629  break;
1630  case 13: //buyer bids per interval
1631  {
1632  char* param1 = strtok(args, " ");
1633  uint32 bidsPerInterval = (uint32) strtoul(param1, NULL, 0);
1634  CharacterDatabase.PExecute("UPDATE auctionhousebot SET buyerbidsperinterval = '%u' WHERE auctionhouse = '%u'", bidsPerInterval, ahMapID);
1635  config->SetBidsPerInterval(bidsPerInterval);
1636  }
1637  break;
1638  default:
1639  break;
1640  }
1641 }
1642 
1644 {
1645  if (debug_Out) sLog.outString("Start Settings for %s Auctionhouses:", CharacterDatabase.PQuery("SELECT name FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetString());
1646  if (AHBSeller)
1647  {
1648  //load min and max items
1649  config->SetMinItems(CharacterDatabase.PQuery("SELECT minitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1650  config->SetMaxItems(CharacterDatabase.PQuery("SELECT maxitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1651  //load percentages
1652  uint32 greytg = CharacterDatabase.PQuery("SELECT percentgreytradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1653  uint32 whitetg = CharacterDatabase.PQuery("SELECT percentwhitetradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1654  uint32 greentg = CharacterDatabase.PQuery("SELECT percentgreentradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1655  uint32 bluetg = CharacterDatabase.PQuery("SELECT percentbluetradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1656  uint32 purpletg = CharacterDatabase.PQuery("SELECT percentpurpletradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1657  uint32 orangetg = CharacterDatabase.PQuery("SELECT percentorangetradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1658  uint32 yellowtg = CharacterDatabase.PQuery("SELECT percentyellowtradegoods FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1659  uint32 greyi = CharacterDatabase.PQuery("SELECT percentgreyitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1660  uint32 whitei = CharacterDatabase.PQuery("SELECT percentwhiteitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1661  uint32 greeni = CharacterDatabase.PQuery("SELECT percentgreenitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1662  uint32 bluei = CharacterDatabase.PQuery("SELECT percentblueitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1663  uint32 purplei = CharacterDatabase.PQuery("SELECT percentpurpleitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1664  uint32 orangei = CharacterDatabase.PQuery("SELECT percentorangeitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1665  uint32 yellowi = CharacterDatabase.PQuery("SELECT percentyellowitems FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32();
1666  std::string XcludeItemsIds;
1667  if (QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT exludeItemsIds FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID()))
1668  XcludeItemsIds = result->Fetch()[0].GetCppString();
1669  config->SetPercentages(greytg, whitetg, greentg, bluetg, purpletg, orangetg, yellowtg, greyi, whitei, greeni, bluei, purplei, orangei, yellowi);
1670  //load min and max prices
1671  config->SetMinPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1672  config->SetMaxPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1673  config->SetMinPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1674  config->SetMaxPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1675  config->SetMinPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT minpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1676  config->SetMaxPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1677  config->SetMinPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT minpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1678  config->SetMaxPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1679  config->SetMinPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT minpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1680  config->SetMaxPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1681  config->SetMinPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1682  config->SetMaxPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1683  config->SetMinPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1684  config->SetMaxPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1685  //load min and max bid prices
1686  config->SetMinBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT minbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1687  config->SetMaxBidPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT maxbidpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1688  config->SetMinBidPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT minbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1689  config->SetMaxBidPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxbidpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1690  config->SetMinBidPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT minbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1691  config->SetMaxBidPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxbidpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1692  config->SetMinBidPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT minbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1693  config->SetMaxBidPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxbidpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1694  config->SetMinBidPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT minbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1695  config->SetMaxBidPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxbidpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1696  config->SetMinBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT minbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1697  config->SetMaxBidPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxbidpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1698  config->SetMinBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT minbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1699  config->SetMaxBidPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxbidpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1700  //load max stacks
1701  config->SetMaxStack(AHB_GREY, CharacterDatabase.PQuery("SELECT maxstackgrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1702  config->SetMaxStack(AHB_WHITE, CharacterDatabase.PQuery("SELECT maxstackwhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1703  config->SetMaxStack(AHB_GREEN, CharacterDatabase.PQuery("SELECT maxstackgreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1704  config->SetMaxStack(AHB_BLUE, CharacterDatabase.PQuery("SELECT maxstackblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1705  config->SetMaxStack(AHB_PURPLE, CharacterDatabase.PQuery("SELECT maxstackpurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1706  config->SetMaxStack(AHB_ORANGE, CharacterDatabase.PQuery("SELECT maxstackorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1707  config->SetMaxStack(AHB_YELLOW, CharacterDatabase.PQuery("SELECT maxstackyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1708  // ignore these items
1709  config->IgnoreItemsIds(XcludeItemsIds);
1710 
1711  if (debug_Out)
1712  {
1713  sLog.outString("minItems = %u", config->GetMinItems());
1714  sLog.outString("maxItems = %u", config->GetMaxItems());
1715  sLog.outString("percentGreyTradeGoods = %u", config->GetPercentages(AHB_GREY_TG));
1716  sLog.outString("percentWhiteTradeGoods = %u", config->GetPercentages(AHB_WHITE_TG));
1717  sLog.outString("percentGreenTradeGoods = %u", config->GetPercentages(AHB_GREEN_TG));
1718  sLog.outString("percentBlueTradeGoods = %u", config->GetPercentages(AHB_BLUE_TG));
1719  sLog.outString("percentPurpleTradeGoods = %u", config->GetPercentages(AHB_PURPLE_TG));
1720  sLog.outString("percentOrangeTradeGoods = %u", config->GetPercentages(AHB_ORANGE_TG));
1721  sLog.outString("percentYellowTradeGoods = %u", config->GetPercentages(AHB_YELLOW_TG));
1722  sLog.outString("percentGreyItems = %u", config->GetPercentages(AHB_GREY_I));
1723  sLog.outString("percentWhiteItems = %u", config->GetPercentages(AHB_WHITE_I));
1724  sLog.outString("percentGreenItems = %u", config->GetPercentages(AHB_GREEN_I));
1725  sLog.outString("percentBlueItems = %u", config->GetPercentages(AHB_BLUE_I));
1726  sLog.outString("percentPurpleItems = %u", config->GetPercentages(AHB_PURPLE_I));
1727  sLog.outString("percentOrangeItems = %u", config->GetPercentages(AHB_ORANGE_I));
1728  sLog.outString("percentYellowItems = %u", config->GetPercentages(AHB_YELLOW_I));
1729  sLog.outString("minPriceGrey = %u", config->GetMinPrice(AHB_GREY));
1730  sLog.outString("maxPriceGrey = %u", config->GetMaxPrice(AHB_GREY));
1731  sLog.outString("minPriceWhite = %u", config->GetMinPrice(AHB_WHITE));
1732  sLog.outString("maxPriceWhite = %u", config->GetMaxPrice(AHB_WHITE));
1733  sLog.outString("minPriceGreen = %u", config->GetMinPrice(AHB_GREEN));
1734  sLog.outString("maxPriceGreen = %u", config->GetMaxPrice(AHB_GREEN));
1735  sLog.outString("minPriceBlue = %u", config->GetMinPrice(AHB_BLUE));
1736  sLog.outString("maxPriceBlue = %u", config->GetMaxPrice(AHB_BLUE));
1737  sLog.outString("minPricePurple = %u", config->GetMinPrice(AHB_PURPLE));
1738  sLog.outString("maxPricePurple = %u", config->GetMaxPrice(AHB_PURPLE));
1739  sLog.outString("minPriceOrange = %u", config->GetMinPrice(AHB_ORANGE));
1740  sLog.outString("maxPriceOrange = %u", config->GetMaxPrice(AHB_ORANGE));
1741  sLog.outString("minPriceYellow = %u", config->GetMinPrice(AHB_YELLOW));
1742  sLog.outString("maxPriceYellow = %u", config->GetMaxPrice(AHB_YELLOW));
1743  sLog.outString("minBidPriceGrey = %u", config->GetMinBidPrice(AHB_GREY));
1744  sLog.outString("maxBidPriceGrey = %u", config->GetMaxBidPrice(AHB_GREY));
1745  sLog.outString("minBidPriceWhite = %u", config->GetMinBidPrice(AHB_WHITE));
1746  sLog.outString("maxBidPriceWhite = %u", config->GetMaxBidPrice(AHB_WHITE));
1747  sLog.outString("minBidPriceGreen = %u", config->GetMinBidPrice(AHB_GREEN));
1748  sLog.outString("maxBidPriceGreen = %u", config->GetMaxBidPrice(AHB_GREEN));
1749  sLog.outString("minBidPriceBlue = %u", config->GetMinBidPrice(AHB_BLUE));
1750  sLog.outString("maxBidPriceBlue = %u", config->GetMinBidPrice(AHB_BLUE));
1751  sLog.outString("minBidPricePurple = %u", config->GetMinBidPrice(AHB_PURPLE));
1752  sLog.outString("maxBidPricePurple = %u", config->GetMaxBidPrice(AHB_PURPLE));
1753  sLog.outString("minBidPriceOrange = %u", config->GetMinBidPrice(AHB_ORANGE));
1754  sLog.outString("maxBidPriceOrange = %u", config->GetMaxBidPrice(AHB_ORANGE));
1755  sLog.outString("minBidPriceYellow = %u", config->GetMinBidPrice(AHB_YELLOW));
1756  sLog.outString("maxBidPriceYellow = %u", config->GetMaxBidPrice(AHB_YELLOW));
1757  sLog.outString("maxStackGrey = %u", config->GetMaxStack(AHB_GREY));
1758  sLog.outString("maxStackWhite = %u", config->GetMaxStack(AHB_WHITE));
1759  sLog.outString("maxStackGreen = %u", config->GetMaxStack(AHB_GREEN));
1760  sLog.outString("maxStackBlue = %u", config->GetMaxStack(AHB_BLUE));
1761  sLog.outString("maxStackPurple = %u", config->GetMaxStack(AHB_PURPLE));
1762  sLog.outString("maxStackOrange = %u", config->GetMaxStack(AHB_ORANGE));
1763  sLog.outString("maxStackYellow = %u", config->GetMaxStack(AHB_YELLOW));
1764  sLog.outString("exludeItems = %s", XcludeItemsIds.c_str());
1765  }
1766  //AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAHFID());
1767  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
1768 
1769  config->ResetItemCounts();
1770  uint32 auctions = auctionHouse->Getcount();
1771 
1772  if (auctions)
1773  {
1774  for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
1775  {
1776  AuctionEntry* Aentry = itr->second;
1777  Item* item = sAuctionMgr->GetAItem(Aentry->item_guidlow);
1778  if (item)
1779  {
1780  ItemTemplate const* prototype = item->GetProto();
1781  if (prototype)
1782  {
1783  switch (prototype->Quality)
1784  {
1785  case 0:
1786  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1787  config->IncItemCounts(AHB_GREY_TG);
1788  else
1789  config->IncItemCounts(AHB_GREY_I);
1790  break;
1791  case 1:
1792  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1793  config->IncItemCounts(AHB_WHITE_TG);
1794  else
1795  config->IncItemCounts(AHB_WHITE_I);
1796  break;
1797  case 2:
1798  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1799  config->IncItemCounts(AHB_GREEN_TG);
1800  else
1801  config->IncItemCounts(AHB_GREEN_I);
1802  break;
1803  case 3:
1804  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1805  config->IncItemCounts(AHB_BLUE_TG);
1806  else
1807  config->IncItemCounts(AHB_BLUE_I);
1808  break;
1809  case 4:
1810  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1811  config->IncItemCounts(AHB_PURPLE_TG);
1812  else
1813  config->IncItemCounts(AHB_PURPLE_I);
1814  break;
1815  case 5:
1816  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1817  config->IncItemCounts(AHB_ORANGE_TG);
1818  else
1819  config->IncItemCounts(AHB_ORANGE_I);
1820  break;
1821  case 6:
1822  if (prototype->Class == ITEM_CLASS_TRADE_GOODS)
1823  config->IncItemCounts(AHB_YELLOW_TG);
1824  else
1825  config->IncItemCounts(AHB_YELLOW_I);
1826  break;
1827  }
1828  }
1829  }
1830  }
1831  }
1832  if (debug_Out)
1833  {
1834  sLog.outString("Current Items in %s Auctionhouses:", CharacterDatabase.PQuery("SELECT name FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetString());
1835  sLog.outString("Grey Trade Goods\t%u\tGrey Items\t%u", config->GetItemCounts(AHB_GREY_TG), config->GetItemCounts(AHB_GREY_I));
1836  sLog.outString("White Trade Goods\t%u\tWhite Items\t%u", config->GetItemCounts(AHB_WHITE_TG), config->GetItemCounts(AHB_WHITE_I));
1837  sLog.outString("Green Trade Goods\t%u\tGreen Items\t%u", config->GetItemCounts(AHB_GREEN_TG), config->GetItemCounts(AHB_GREEN_I));
1838  sLog.outString("Blue Trade Goods\t%u\tBlue Items\t%u", config->GetItemCounts(AHB_BLUE_TG), config->GetItemCounts(AHB_BLUE_I));
1839  sLog.outString("Purple Trade Goods\t%u\tPurple Items\t%u", config->GetItemCounts(AHB_PURPLE_TG), config->GetItemCounts(AHB_PURPLE_I));
1840  sLog.outString("Orange Trade Goods\t%u\tOrange Items\t%u", config->GetItemCounts(AHB_ORANGE_TG), config->GetItemCounts(AHB_ORANGE_I));
1841  sLog.outString("Yellow Trade Goods\t%u\tYellow Items\t%u", config->GetItemCounts(AHB_YELLOW_TG), config->GetItemCounts(AHB_YELLOW_I));
1842  }
1843  }
1844  if (AHBBuyer)
1845  {
1846  //load buyer bid prices
1847  config->SetBuyerPrice(AHB_GREY, CharacterDatabase.PQuery("SELECT buyerpricegrey FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1848  config->SetBuyerPrice(AHB_WHITE, CharacterDatabase.PQuery("SELECT buyerpricewhite FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1849  config->SetBuyerPrice(AHB_GREEN, CharacterDatabase.PQuery("SELECT buyerpricegreen FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1850  config->SetBuyerPrice(AHB_BLUE, CharacterDatabase.PQuery("SELECT buyerpriceblue FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1851  config->SetBuyerPrice(AHB_PURPLE, CharacterDatabase.PQuery("SELECT buyerpricepurple FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1852  config->SetBuyerPrice(AHB_ORANGE, CharacterDatabase.PQuery("SELECT buyerpriceorange FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1853  config->SetBuyerPrice(AHB_YELLOW, CharacterDatabase.PQuery("SELECT buyerpriceyellow FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1854  //load bidding interval
1855  config->SetBiddingInterval(CharacterDatabase.PQuery("SELECT buyerbiddinginterval FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1856  //load bids per interval
1857  config->SetBidsPerInterval(CharacterDatabase.PQuery("SELECT buyerbidsperinterval FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetUInt32());
1858  if (debug_Out)
1859  {
1860  sLog.outString("buyerPriceGrey = %u", config->GetBuyerPrice(AHB_GREY));
1861  sLog.outString("buyerPriceWhite = %u", config->GetBuyerPrice(AHB_WHITE));
1862  sLog.outString("buyerPriceGreen = %u", config->GetBuyerPrice(AHB_GREEN));
1863  sLog.outString("buyerPriceBlue = %u", config->GetBuyerPrice(AHB_BLUE));
1864  sLog.outString("buyerPricePurple = %u", config->GetBuyerPrice(AHB_PURPLE));
1865  sLog.outString("buyerPriceOrange = %u", config->GetBuyerPrice(AHB_ORANGE));
1866  sLog.outString("buyerPriceYellow = %u", config->GetBuyerPrice(AHB_YELLOW));
1867  sLog.outString("buyerBiddingInterval = %u", config->GetBiddingInterval());
1868  sLog.outString("buyerBidsPerInterval = %u", config->GetBidsPerInterval());
1869  }
1870  }
1871  if (debug_Out) sLog.outString("End Settings for %s Auctionhouses:", CharacterDatabase.PQuery("SELECT name FROM auctionhousebot WHERE auctionhouse = %u", config->GetAHID())->Fetch()->GetString());
1872 }
1873 
vector< uint32 > npcItems
void SaveToDB() const
uint32 ItemLevel
void Initialize(uint32 guid)
Definition: Player.cpp:14282
void AddAuction(AuctionEntry *ah)
uint32 GetCount() const
Definition: Item.h:251
uint32 RequiredSkillRank
#define AHB_YELLOW_TG
ItemTemplate const * GetProto() const
Definition: Item.cpp:460
uint32 GetBiddingInterval()
uint32 GetBuyerPrice(uint32 color)
#define AHB_ORANGE_TG
#define sConfig
Definition: Config.h:52
vector< uint32 > greenTradeGoodsBin
void addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session)
AuctionEntryMap::iterator GetAuctionsEnd()
#define AHB_PURPLE
uint32 GetMaxItems()
vector< uint32 > greenItemsBin
#define AHB_PURPLE_I
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
uint32 item_guidlow
bool BeginTransaction()
Definition: Database.cpp:533
uint32 SellPrice
void DecrementItemCounts(AuctionEntry *ah, uint32 item_template)
uint32 GetAHFID()
uint32 GetMaxStackCount() const
Definition: Item.h:259
QueryResult_AutoPtr PQuery(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:400
void SetMaxItems(uint32 value)
#define AHB_WHITE_TG
uint32 GetItemCounts(uint32 color)
AuctionEntry * GetAuction(uint32 id) const
Definition: Field.h:24
vector< uint32 > whiteTradeGoodsBin
virtual void SaveToDB()
Definition: Item.cpp:286
void SetMinItems(uint32 value)
void SetPercentages(uint32 greytg, uint32 whitetg, uint32 greentg, uint32 bluetg, uint32 purpletg, uint32 orangetg, uint32 yellowtg, uint32 greyi, uint32 whitei, uint32 greeni, uint32 bluei, uint32 purplei, uint32 orangei, uint32 yellowi)
void SetMinPrice(uint32 color, uint32 value)
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
void AddToUpdateQueueOf(Player *player)
Definition: Item.cpp:688
void SetBuyerPrice(uint32 color, uint32 value)
#define AHB_ORANGE
void AddObject(T *object)
#define sLog
Log class singleton.
Definition: Log.h:187
STL namespace.
void DeleteFromDB() const
QueryResult_AutoPtr Query(const char *sql)
Definition: Database.cpp:383
AuctionEntryMap::iterator GetAuctionsBegin()
void IncItemCounts(uint32 Class, uint32 Quality)
void SetCount(uint32 value)
Definition: Item.h:255
uint32 GetGUIDLow() const
Definition: Object.h:160
vector< uint32 > yellowItemsBin
#define AHB_GREEN
void SetItemRandomProperties(int32 randomPropId)
Definition: Item.cpp:615
#define sObjectMgr
Definition: ObjectMgr.h:1285
bool CommitTransaction()
Definition: Database.cpp:551
AuctionHouseEntry const * auctionHouseEntry
#define AHB_GREEN_I
vector< uint32 > purpleTradeGoodsBin
uint32 GetHouseFaction() const
#define AHB_ORANGE_I
#define AHB_BLUE_TG
Definition: Common.h:179
uint32 GetMinBidPrice(uint32 color)
uint32 GetBidsPerInterval()
void SetBiddingInterval(uint32 value)
void LoadValues(AHBConfig *)
#define UI64FMTD
Definition: Common.h:149
uint32 GetPercentages(uint32 color)
uint32 AllowableClass
static int32 GenerateItemRandomPropertyId(uint32 item_id)
Definition: Item.cpp:569
#define AHB_GREY_TG
#define AHB_WHITE_I
uint32 GetMaxStack(uint32 color)
#define AHB_GREY_I
void IgnoreItemsIds(const std::string &idsString)
void SetMaxStack(uint32 color, uint32 value)
vector< uint32 > blueItemsBin
vector< uint32 > orangeTradeGoodsBin
Definition: Item.h:196
static Item * CreateItem(uint32 item, uint32 count, Player const *player=NULL)
Definition: Item.cpp:936
void IncrementItemCounts(AuctionEntry *ah)
vector< uint32 > greyItemsBin
void ResetItemCounts()
void SetBidsPerInterval(uint32 value)
void DecItemCounts(uint32 Class, uint32 Quality)
#define AHB_MAX_QUALITY
uint32 RequiredLevel
uint32 GetMinPrice(uint32 color)
void RemoveFromUpdateQueueOf(Player *player)
Definition: Item.cpp:708
bool IsIgnoringItem(uint32 id) const
vector< uint32 > purpleItemsBin
time_t expire_time
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
void SetMaxBidPrice(uint32 color, uint32 value)
uint32 GetPercents(uint32 color)
SQLStorage sItemStorage
INSTANTIATE_SINGLETON_1(AuctionHouseBot)
vector< uint32 > whiteItemsBin
uint32 item_template
uint32 GetHouseId() const
#define AHB_BLUE
uint32 GetMinItems()
void RemoveObject(T *object)
ACE_UINT64 uint64
Definition: Define.h:70
uint32 GetAHID()
void SetMaxPrice(uint32 color, uint32 value)
#define AHB_YELLOW
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
uint32 GetMaxPrice(uint32 color)
void CalculatePercents()
#define AHB_YELLOW_I
uint32 GetMaxBidPrice(uint32 color)
#define sAuctionMgr
#define AHB_BLUE_I
#define AHB_GREY
bool RemoveAuction(AuctionEntry *auction, uint32 item_template)
uint32 GetEntry() const
Definition: Object.h:186
#define sWorld
Definition: World.h:860
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
uint32 MaxEntry
Definition: SQLStorage.h:62
uint32 MinMoneyLoot
void SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPrice)
#define AHB_WHITE
#define AHB_PURPLE_TG
ACE_UINT32 uint32
Definition: Define.h:71
#define AHB_GREEN_TG
void SetMinBidPrice(uint32 color, uint32 value)
void Commands(uint32, uint32, uint32, char *)
vector< uint32 > orangeItemsBin
Definition: Player.h:922
vector< uint32 > blueTradeGoodsBin
uint32 GetAuctionOutBid() const
vector< uint32 > greyTradeGoodsBin
vector< uint32 > yellowTradeGoodsBin
uint32 urand(uint32 min, uint32 max)
Definition: Util.cpp:71
void addNewAuctions(Player *AHBplayer, AHBConfig *config)
vector< uint32 > lootItems