All pastes #1004622 Raw Edit

AHBot-AHBuyer.5734

public diff v1 · immutable
#1004622 ·published 2008-05-02 04:27 UTC
rendered paste body
Index: src/game/AuctionHouse.cpp===================================================================--- src/game/AuctionHouse.cpp	(revision 5734)+++ src/game/AuctionHouse.cpp	(working copy)@@ -22,6 +22,7 @@ #include "Log.h" #include "World.h" #include "ObjectMgr.h"+#include "Config/ConfigEnv.h" #include "Player.h" #include "UpdateMask.h" #include "AuctionHouseObject.h"@@ -168,7 +169,10 @@         std::ostringstream msgAuctionOutbiddedSubject;         msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED; -        if (oldBidder)+        if (oldBidder && !_player)+             oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, sConfig.GetIntDefault("AuctionHouseBotBuyer.GUID", 0), newPrice, objmgr.GetAuctionOutBid(auction->bid), auction->item_template);++        if (oldBidder && _player)             oldBidder->GetSession()->SendAuctionBidderNotification( auction->location, auction->Id, _player->GetGUID(), newPrice, objmgr.GetAuctionOutBid(auction->bid), auction->item_template);          WorldSession::SendMailTo(oldBidder, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->bidder, msgAuctionOutbiddedSubject.str(), 0, NULL, auction->bid, 0, NOT_READ);Index: src/game/AuctionHouseBot.cpp===================================================================--- src/game/AuctionHouseBot.cpp	(revision 0)+++ src/game/AuctionHouseBot.cpp	(revision 0)@@ -0,0 +1,697 @@+#include "AuctionHouseBot.h"+#include "Bag.h"+#include "Config/ConfigEnv.h"+#include "Database/DatabaseEnv.h"+#include "Item.h"+#include "Log.h"+#include "ObjectMgr.h"+#include "Player.h"+#include "World.h"+#include "WorldSession.h"+#include <vector>++using namespace std;++//#define NO_VENDOR_ITEMS+#define ONLY_LOOT_ITEMS++static vector<uint32> whiteTradeGoods;+static vector<uint32> greenTradeGoods;+static vector<uint32> blueTradeGoods;+static vector<uint32> purpleTradeGoods;+static vector<uint32> whiteItems;+static vector<uint32> greenItems;+static vector<uint32> blueItems;+static vector<uint32> purpleItems;++static uint32 AHBplayerAccount = 0; +static uint32 AHBplayerGUID = 0; +static uint32 noMail = 0; +static uint32 numAllianceItems = 0;+static uint32 numMinAllianceItems = 0;+static uint32 numHordeItems = 0;+static uint32 numMinHordeItems = 0;+static uint32 numNeutralItems = 0;+static uint32 numMinNeutralItems = 0;+static uint32 minTime = 0;+static uint32 maxTime = 0;+static uint32 percentWhiteTradeGoods = 0;+static uint32 percentGreenTradeGoods = 0;+static uint32 percentBlueTradeGoods = 0;+static uint32 percentPurpleTradeGoods = 0;+static uint32 percentWhiteItems = 0;+static uint32 percentGreenItems = 0;+static uint32 percentBlueItems = 0;+static uint32 percentPurpleItems = 0;+static uint32 minPriceWhite = 0;+static uint32 maxPriceWhite = 0;+static uint32 bidPriceWhite = 0;+static uint32 maxStackWhite = 0;+static uint32 minPriceGreen = 0;+static uint32 maxPriceGreen = 0;+static uint32 bidPriceGreen = 0;+static uint32 maxStackGreen = 0;+static uint32 minPriceBlue = 0;+static uint32 maxPriceBlue = 0;+static uint32 bidPriceBlue = 0;+static uint32 maxStackBlue = 0;+static uint32 minPricePurple = 0;+static uint32 maxPricePurple = 0;+static uint32 bidPricePurple = 0;+static uint32 maxStackPurple = 0;++///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+uint32 AuctionHouseBotNoMail()+{+   return noMail != 0 ? AHBplayerGUID : 0;+}++///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+static inline uint32 minValue(uint32 a, uint32 b)+{+   return a <= b ? a : b;+}++///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+static void deleteOldAuctions(uint32 ahMapID)+{+   AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);++   AuctionHouseObject::AuctionEntryMap::iterator itr;+   itr = auctionHouse->GetAuctionsBegin();++   while (itr != auctionHouse->GetAuctionsEnd())+   {+      AuctionHouseObject::AuctionEntryMap::iterator tmp = itr;+      ++itr;++      if (tmp->second->owner != AHBplayerGUID)+         continue;++      if (tmp->second->bidder != 0)+         continue;++      if (tmp->second->time > sWorld.GetGameTime())+         continue;++      // quietly delete the item and auction...++      Item* item = objmgr.GetAItem(tmp->second->item_guidlow);+      if (item != NULL)+      {+         objmgr.RemoveAItem(tmp->second->item_guidlow);+         item->DeleteFromDB();+         delete item;+      }+      else+      {+         sLog.outString("AuctionHouseBot: "+                        "clearing auction for non-existant item_guidlow (%d)",+                        tmp->second->item_guidlow);+      }++	CharacterDatabase.PExecute("DELETE FROM `auctionhouse` WHERE `id` = '%u'",+                                 tmp->second->Id);+       AuctionEntry* auctionEntry = tmp->second;+       auctionHouse->RemoveAuction(auctionEntry->Id);+       delete auctionEntry;+   }+}++///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+static void addNewAuctions(uint32 ahMapID, uint32 maxAuctions, uint32 minAuctions, Player *AHBplayer)+{+   AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);++   if (auctionHouse->Getcount() > minAuctions)+      return;++   uint32 whiteTradeGoodsBin = percentWhiteTradeGoods;+   uint32 greenTradeGoodsBin = percentGreenTradeGoods + whiteTradeGoodsBin;+   uint32 blueTradeGoodsBin = percentBlueTradeGoods + greenTradeGoodsBin;+   uint32 purpleTradeGoodsBin = percentPurpleTradeGoods + blueTradeGoodsBin;+   uint32 whiteItemBin = percentWhiteItems + purpleTradeGoodsBin;+   uint32 greenItemBin = percentGreenItems + whiteItemBin;+   uint32 blueItemBin = percentBlueItems + greenItemBin;+   uint32 purpleItemBin = percentPurpleItems + blueItemBin;++   // only insert 100 at a time, so as not to peg the processor+   for (uint32 count = 0; +        (count < 100) && (auctionHouse->Getcount() < maxAuctions); +        count++)+   {+      uint32 itemID = purpleItems[urand(0, purpleItems.size() - 1)];+      uint32 value = urand(1, 100);+      +      if (value <= blueItemBin)+         itemID = blueItems[urand(0, blueItems.size() - 1)];++      if (value <= greenItemBin)+         itemID = greenItems[urand(0, greenItems.size() - 1)];++      if (value <= whiteItemBin)+         itemID = whiteItems[urand(0, whiteItems.size() - 1)];++      if (value <= purpleTradeGoodsBin)+         itemID = purpleTradeGoods[urand(0, purpleTradeGoods.size() - 1)];++      if (value <= blueTradeGoodsBin)+         itemID = blueTradeGoods[urand(0, blueTradeGoods.size() - 1)];++      if (value <= greenTradeGoodsBin)+         itemID = greenTradeGoods[urand(0, greenTradeGoods.size() - 1)];++      if (value <= whiteTradeGoodsBin)+         itemID = whiteTradeGoods[urand(0, whiteTradeGoods.size() - 1)];++      ItemPrototype const* prototype = objmgr.GetItemPrototype(itemID);+      if (prototype == NULL)+      {+         sLog.outString("AuctionHouseBot: Huh?!?! prototype == NULL");+         continue;+      }++      Item* item = Item::CreateItem(itemID, 1, AHBplayer);+	  item->AddToUpdateQueueOf(AHBplayer);+      if (item == NULL)+      {+         sLog.outString("AuctionHouseBot: Item::CreateItem() returned NULL");+         break;+      }++      uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID);+      if (randomPropertyId != 0)+         item->SetItemRandomProperties(randomPropertyId);++      uint32 buyoutPrice = prototype->BuyPrice * item->GetCount();+      uint32 bidPrice = 0;+      uint32 stackCount = urand(1, item->GetMaxStackCount());++      switch (prototype->Quality)+      {+         case 1:+            if (maxStackWhite != 0)+            {+               stackCount = urand(1, minValue(item->GetMaxStackCount(), +                                              maxStackWhite));+            }++            buyoutPrice *= urand(minPriceWhite, maxPriceWhite) * stackCount;+            buyoutPrice /= 100;+            bidPrice = buyoutPrice * bidPriceWhite;+            bidPrice /= 100;++            break;++         case 2:+            if (maxStackGreen != 0)+            {+               stackCount = urand(1, minValue(item->GetMaxStackCount(), +                                              maxStackGreen));+            }++            buyoutPrice *= urand(minPriceGreen, maxPriceGreen) * stackCount;+            buyoutPrice /= 100;+            bidPrice = buyoutPrice * bidPriceGreen;+            bidPrice /= 100;++            break;++         case 3:+            if (maxStackBlue != 0)+            {+               stackCount = urand(1, minValue(item->GetMaxStackCount(), +                                              maxStackBlue));+            }++            buyoutPrice *= urand(minPriceBlue, maxPriceBlue) * stackCount;+            buyoutPrice /= 100;+            bidPrice = buyoutPrice * bidPriceBlue;+            bidPrice /= 100;++            break;++         case 4:+            if (maxStackPurple != 0)+            {+               stackCount = urand(1, minValue(item->GetMaxStackCount(), +                                              maxStackPurple));+            }++            buyoutPrice *= urand(minPricePurple, maxPricePurple) * stackCount;+            buyoutPrice /= 100;+            bidPrice = buyoutPrice * bidPricePurple;+            bidPrice /= 100;++            break;+      }++      item->SetCount(stackCount);++      AuctionEntry* auctionEntry = new AuctionEntry;+      auctionEntry->Id = objmgr.GenerateAuctionID();+      auctionEntry->auctioneer = 0;+      auctionEntry->item_guidlow = item->GetGUIDLow();+      auctionEntry->item_template = item->GetEntry();+      auctionEntry->owner = AHBplayer->GetGUIDLow();+      auctionEntry->startbid = bidPrice;+      auctionEntry->buyout = buyoutPrice;+      auctionEntry->bidder = 0;+      auctionEntry->bid = 0;+      auctionEntry->deposit = 0;+      auctionEntry->location = ahMapID;+      auctionEntry->time = (time_t) (urand(minTime, maxTime) * 60 * 60 + +                                     time(NULL));+      +      item->SaveToDB();+      item->RemoveFromUpdateQueueOf(AHBplayer);+      objmgr.AddAItem(item);+      auctionHouse->AddAuction(auctionEntry);++      CharacterDatabase.PExecute("INSERT INTO `auctionhouse` (`id`,"+                                 "`auctioneerguid`,`itemguid`,`item_template`,"+                                 "`itemowner`,`buyoutprice`,`time`,`buyguid`,"+                                 "`lastbid`,`startbid`,`deposit`,`location`) "+                                 "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', "+                                 "'" I64FMTD "', '%u', '%u', '%u', '%u', '%u')",+                                 auctionEntry->Id, +                                 auctionEntry->auctioneer,+                                 auctionEntry->item_guidlow, +                                 auctionEntry->item_template, +                                 auctionEntry->owner, +                                 auctionEntry->buyout, +                                 (uint64) auctionEntry->time, +                                 auctionEntry->bidder, +                                 auctionEntry->bid, +                                 auctionEntry->startbid, +                                 auctionEntry->deposit, +                                 auctionEntry->location);+   }+}++///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+void AuctionHouseBot()+{+   if ((AHBplayerAccount == 0) || (AHBplayerGUID == 0))+      return;++   WorldSession _session(AHBplayerAccount, NULL, 0, true, 0, LOCALE_ENG);+   Player _AHBplayer(&_session);+   _AHBplayer.MinimalLoadFromDB(NULL, AHBplayerGUID);+   ObjectAccessor::Instance().AddObject(&_AHBplayer);++   deleteOldAuctions(2);+   deleteOldAuctions(6);+   deleteOldAuctions(7);++   addNewAuctions(2, numAllianceItems, numMinAllianceItems, &_AHBplayer);+   addNewAuctions(6, numHordeItems, numMinHordeItems, &_AHBplayer);+   addNewAuctions(7, numNeutralItems, numMinNeutralItems, &_AHBplayer);+   +   ObjectAccessor::Instance().RemoveObject(&_AHBplayer);+}+///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+void AuctionHouseBotInit()+{+   AHBplayerAccount = sConfig.GetIntDefault("AuctionHouseBot.Account", 0);+   AHBplayerGUID = sConfig.GetIntDefault("AuctionHouseBot.GUID", 0);+                         +   if ((AHBplayerAccount == 0) || (AHBplayerGUID == 0))+   {+      sLog.outString("AuctionHouseBot disabled");+      return;            +   }++   noMail = sConfig.GetIntDefault("AuctionHouseBot.NoMail", 0);++   numAllianceItems = sConfig.GetIntDefault("AuctionHouseBot.AllianceItems", 0);+   numMinAllianceItems = sConfig.GetIntDefault("AuctionHouseBot.MinAllianceItems", -1);+   numHordeItems = sConfig.GetIntDefault("AuctionHouseBot.HordeItems", 0);+   numMinHordeItems = sConfig.GetIntDefault("AuctionHouseBot.MinHordeItems", -1);+   numNeutralItems = sConfig.GetIntDefault("AuctionHouseBot.NeutralItems", 0);+   numMinNeutralItems = sConfig.GetIntDefault("AuctionHouseBot.MinNeutralItems", -1);++   if (numMinAllianceItems < 0)+	   numMinAllianceItems = numAllianceItems;++   if (numMinHordeItems  < 0)+	   numMinHordeItems = numHordeItems;++   if (numMinNeutralItems  < 0)+	   numMinNeutralItems = numNeutralItems;++   if (numMinAllianceItems > numAllianceItems)+	   numMinAllianceItems = numAllianceItems;++   if (numMinHordeItems > numHordeItems)+	   numMinHordeItems = numHordeItems;++   if (numMinNeutralItems > numNeutralItems)+	   numMinNeutralItems = numNeutralItems;++   minTime = sConfig.GetIntDefault("AuctionHouseBot.MinTime", 8);+   maxTime = sConfig.GetIntDefault("AuctionHouseBot.MaxTime", 24);++   if (minTime < 1)+      minTime = 1;++   if (maxTime > 24)+      maxTime = 24;++   if (minTime > maxTime)+      minTime = maxTime;++   percentWhiteTradeGoods = sConfig.GetIntDefault("AuctionHouseBot."+                                                  "PercentWhiteTradeGoods",+                                                  27);+   percentGreenTradeGoods = sConfig.GetIntDefault("AuctionHouseBot."+                                                  "PercentGreenTradeGoods",+                                                  12);+   percentBlueTradeGoods = sConfig.GetIntDefault("AuctionHouseBot."+                                                  "PercentBlueTradeGoods",+                                                  10);+   percentPurpleTradeGoods = sConfig.GetIntDefault("AuctionHouseBot."+                                                  "PercentPurpleTradeGoods",+                                                  1);+   percentWhiteItems = sConfig.GetIntDefault("AuctionHouseBot."+                                             "PercentWhiteItems",+                                             10);+   percentGreenItems = sConfig.GetIntDefault("AuctionHouseBot."+                                             "PercentGreenItems",+                                             30);+   percentBlueItems = sConfig.GetIntDefault("AuctionHouseBot."+                                            "PercentBlueItems",+                                            8);+   percentPurpleItems = sConfig.GetIntDefault("AuctionHouseBot."+                                              "PercentPurpleItems",+                                              2);++   uint32 totalPercent = percentWhiteTradeGoods + percentGreenTradeGoods ++                         percentBlueTradeGoods + percentPurpleTradeGoods ++                         percentWhiteItems + percentGreenItems + +                         percentBlueItems + percentPurpleItems;++   if (totalPercent == 0)+   {+      numAllianceItems = 0;+      numHordeItems = 0;+      numNeutralItems = 0;+   }+   else if (totalPercent != 100)+   {+      double scale = (double) 100 / (double) totalPercent;++      percentPurpleItems = (uint32) (scale * (double) percentPurpleItems);+      percentBlueItems = (uint32) (scale * (double) percentBlueItems);+      percentGreenItems = (uint32) (scale * (double) percentGreenItems);+      percentWhiteItems = (uint32) (scale * (double) percentWhiteItems);+      percentPurpleTradeGoods = (uint32) (scale * +                                          (double) percentPurpleTradeGoods);+      percentBlueTradeGoods = (uint32) (scale * +                                        (double) percentBlueTradeGoods);+      percentGreenTradeGoods = (uint32) (scale * +                                         (double) percentGreenTradeGoods);+      percentWhiteTradeGoods = 100 - +                               percentGreenTradeGoods - +                               percentBlueTradeGoods -+                               percentPurpleTradeGoods -+                               percentWhiteItems -+                               percentGreenItems -+                               percentBlueItems -+                               percentPurpleItems;++      sLog.outString("AuctionHouseBot:");+      sLog.outString("sum of item percentages not equal to 100, adjusting...");+      sLog.outString("AuctionHouseBot.PercentWhiteTradeGoods = %d",+                     percentWhiteTradeGoods);+      sLog.outString("AuctionHouseBot.PercentGreenTradeGoods = %d",+                     percentGreenTradeGoods);+      sLog.outString("AuctionHouseBot.PercentBlueTradeGoods = %d",+                     percentBlueTradeGoods);+      sLog.outString("AuctionHouseBot.PercentPurpleTradeGoods = %d",+                     percentPurpleTradeGoods);+      sLog.outString("AuctionHouseBot.PercentWhiteItems = %d",+                     percentWhiteItems);+      sLog.outString("AuctionHouseBot.PercentGreenItems = %d",+                     percentGreenItems);+      sLog.outString("AuctionHouseBot.PercentBlueItems = %d",+                     percentBlueItems);+      sLog.outString("AuctionHouseBot.PercentPurpleItems = %d",+                     percentPurpleItems);+   }++   minPriceWhite = sConfig.GetIntDefault("AuctionHouseBot.MinPriceWhite",+                                         150);+   maxPriceWhite = sConfig.GetIntDefault("AuctionHouseBot.MaxPriceWhite",+                                         250);++   if (minPriceWhite == 0)+      minPriceWhite = 1;++   if (maxPriceWhite == 0)+      maxPriceWhite = 1;++   if (minPriceWhite > maxPriceWhite)+      minPriceWhite = maxPriceWhite;++   bidPriceWhite = sConfig.GetIntDefault("AuctionHouseBot.BidPriceWhite",+                                         100);+   if (bidPriceWhite > 100)+      bidPriceWhite = 100;++   maxStackWhite = sConfig.GetIntDefault("AuctionHouseBot.MaxStackWhite", 0);++   minPriceGreen = sConfig.GetIntDefault("AuctionHouseBot.MinPriceGreen",+                                         200);+   maxPriceGreen = sConfig.GetIntDefault("AuctionHouseBot.MaxPriceGreen",+                                         300);++   if (minPriceGreen == 0)+      minPriceGreen = 1;++   if (maxPriceGreen == 0)+      maxPriceGreen = 1;++   if (minPriceGreen > maxPriceGreen)+      minPriceGreen = maxPriceGreen;++   bidPriceGreen = sConfig.GetIntDefault("AuctionHouseBot.BidPriceGreen",+                                         100);+   if (bidPriceGreen > 100)+      bidPriceGreen = 100;++   maxStackGreen = sConfig.GetIntDefault("AuctionHouseBot.MaxStackGreen", 0);++   minPriceBlue = sConfig.GetIntDefault("AuctionHouseBot.MinPriceBlue",+                                        250);+   maxPriceBlue = sConfig.GetIntDefault("AuctionHouseBot.MaxPriceBlue",+                                        350);++   if (minPriceBlue == 0)+      minPriceBlue = 1;++   if (maxPriceBlue == 0)+      maxPriceBlue = 1;++   if (minPriceBlue > maxPriceBlue)+      minPriceBlue = maxPriceBlue;++   bidPriceBlue = sConfig.GetIntDefault("AuctionHouseBot.BidPriceBlue",+                                        100);+   if (bidPriceBlue > 100)+      bidPriceBlue = 100;++   maxStackBlue = sConfig.GetIntDefault("AuctionHouseBot.MaxStackBlue", 0);++   minPricePurple = sConfig.GetIntDefault("AuctionHouseBot.MinPricePurple",+                                          300);+   maxPricePurple = sConfig.GetIntDefault("AuctionHouseBot.MaxPricePurple",+                                          450);++   if (minPricePurple == 0)+      minPricePurple = 1;++   if (maxPricePurple == 0)+      maxPricePurple = 1;++   if (minPricePurple > maxPricePurple)+      minPricePurple = maxPricePurple;++   bidPricePurple = sConfig.GetIntDefault("AuctionHouseBot.BidPricePurple",+                                          100);+   if (bidPricePurple > 100)+      bidPricePurple = 100;++   maxStackPurple = sConfig.GetIntDefault("AuctionHouseBot.MaxStackPurple", 0);++   QueryResult* results = (QueryResult*) NULL;++#ifdef NO_VENDOR_ITEMS+   vector<uint32> npcItems;++   char npcQuery[] = "SELECT `item` FROM `npc_vendor`";++   results = WorldDatabase.PQuery(npcQuery);+   if (results != NULL)+   {+      do+      {+         Field* fields = results->Fetch();+         npcItems.push_back(fields[0].GetUInt32());++      } while (results->NextRow());++      delete results;+   }+   else+   {+      sLog.outString("AuctionHouseBot: \"%s\" failed", npcQuery);+   }+#endif++#ifdef ONLY_LOOT_ITEMS+   vector<uint32> lootItems;++   char lootQuery[] = "SELECT `item` FROM `creature_loot_template` UNION "+                      "SELECT `item` FROM `disenchant_loot_template` UNION "+                      "SELECT `item` FROM `fishing_loot_template` UNION "+                      "SELECT `item` FROM `gameobject_loot_template` UNION "+                      "SELECT `item` FROM `item_loot_template` UNION "+                      "SELECT `item` FROM `pickpocketing_loot_template` UNION "+                      "SELECT `item` FROM `prospecting_loot_template` UNION "+                      "SELECT `item` FROM `skinning_loot_template`";++   results = WorldDatabase.PQuery(lootQuery);+   if (results != NULL)+   {+      do+      {+         Field* fields = results->Fetch();+         lootItems.push_back(fields[0].GetUInt32());+   +      } while (results->NextRow());+   +      delete results;+   }+   else+   {+      sLog.outString("AuctionHouseBot: \"%s\" failed", lootQuery);+   }+#endif++   for (uint32 itemID = 0; itemID < sItemStorage.MaxEntry; itemID++)+   {+      ItemPrototype const* prototype = objmgr.GetItemPrototype(itemID);++      if (prototype == NULL)+         continue;++      if ((prototype->Bonding != NO_BIND) &&+          (prototype->Bonding != BIND_WHEN_EQUIPED))+      {+         continue;+      }++      if (prototype->BuyPrice == 0)+         continue;+         +      if ((prototype->Quality < 1) || (prototype->Quality > 4))+         continue;++#ifdef NO_VENDOR_ITEMS+      bool isVendorItem = false;++      for (unsigned int i = 0; (i < npcItems.size()) && (!isVendorItem); i++)+      {         +         if (itemID == npcItems[i])+            isVendorItem = true;+      }++      if (isVendorItem)+         continue;+#endif++#ifdef ONLY_LOOT_ITEMS+      bool isLootItem = false;++      for (unsigned int i = 0; (i < lootItems.size()) && (!isLootItem); i++)+      {         +         if (itemID == lootItems[i])+            isLootItem = true;+      }+      +      if (!isLootItem)+         continue;+#endif++      switch (prototype->Quality)+      {+         case 1:+            if (prototype->Class == ITEM_CLASS_TRADE_GOODS)+               whiteTradeGoods.push_back(itemID);+            else+               whiteItems.push_back(itemID);+            break;+   +         case 2:+            if (prototype->Class == ITEM_CLASS_TRADE_GOODS)+               greenTradeGoods.push_back(itemID);+            else+               greenItems.push_back(itemID);+            break;+   +         case 3:+            if (prototype->Class == ITEM_CLASS_TRADE_GOODS)+               blueTradeGoods.push_back(itemID);+            else+               blueItems.push_back(itemID);+            break;+   +         case 4:+            if (prototype->Class == ITEM_CLASS_TRADE_GOODS)+               purpleTradeGoods.push_back(itemID);+            else+               purpleItems.push_back(itemID);+            break;+      }+   }+   +   if ((whiteTradeGoods.size() == 0) ||+       (greenTradeGoods.size() == 0) ||+       (blueTradeGoods.size() == 0) ||+       (purpleTradeGoods.size() == 0) ||+       (whiteItems.size() == 0) ||+       (greenItems.size() == 0) ||+       (blueItems.size() == 0) ||+       (purpleItems.size() == 0))+   {+      sLog.outString("AuctionHouseBot: not loaded DB error?");+      AHBplayerAccount = 0;+      AHBplayerGUID = 0;+      return;+   }+  +   sLog.outString("AuctionHouseBot:");+   sLog.outString("loaded %d white trade goods", whiteTradeGoods.size());+   sLog.outString("loaded %d green trade goods", greenTradeGoods.size());+   sLog.outString("loaded %d blue trade goods", blueTradeGoods.size());+   sLog.outString("loaded %d purple trade goods", purpleTradeGoods.size());+   sLog.outString("loaded %d white items", whiteItems.size());+   sLog.outString("loaded %d green items", greenItems.size());+   sLog.outString("loaded %d blue items", blueItems.size());+   sLog.outString("loaded %d purple items", purpleItems.size());+   sLog.outString("AuctionHouseBot v5.8.5734 by |Paradox| (original by ChrisK)  has been loaded.");++}Index: src/game/AuctionHouseBot.h===================================================================--- src/game/AuctionHouseBot.h	(revision 0)+++ src/game/AuctionHouseBot.h	(revision 0)@@ -0,0 +1,10 @@+#ifndef AUCTION_HOUSE_BOT_H+#define AUCTION_HOUSE_BOT_H++#include "Common.h"++uint32 AuctionHouseBotNoMail();+void AuctionHouseBot();+void AuctionHouseBotInit();++#endifIndex: src/game/AuctionHouseBuyer.cpp===================================================================--- src/game/AuctionHouseBuyer.cpp	(revision 0)+++ src/game/AuctionHouseBuyer.cpp	(revision 0)@@ -0,0 +1,294 @@+#include "AuctionHouseBuyer.h"+#include "Bag.h"+#include "Config/ConfigEnv.h"+#include "Database/DatabaseEnv.h"+#include "Item.h"+#include "Log.h"+#include "ObjectMgr.h"+#include "Player.h"+#include "World.h"+#include "WorldSession.h"+#include "time.h"+#include <vector>+#include <iostream>++using namespace std;++static uint32 _BuyerPlayerAccount = 0;+static uint32 _BuyerPlayerGUID = 0;+static uint32 _BuyerNoMail = 0;+static uint32 _AHBotGUID = 0;++static uint32 _BuyerBidPriceGrey = 0;+static uint32 _BuyerBidPriceWhite = 0;+static uint32 _BuyerBidPriceGreen = 0;+static uint32 _BuyerBidPriceBlue = 0;+static uint32 _BuyerBidPricePurple = 0;++static uint32 _BuyerBiddingInterval = 60;+static bool _BuyerNoBidAHbotBids = false;++time_t _lastrun;+///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+uint32 AuctionHouseBuyerBotNoMail()+{+   return _BuyerNoMail != 0 ? _BuyerPlayerGUID : 0;+}++///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+static void addNewAuctionBuyerBotBid(uint32 ahMapID, WorldSession *session)+{++        // Fetches content of selected AH+   AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);+   AuctionHouseObject::AuctionEntryMap::iterator itr;++   itr = auctionHouse->GetAuctionsBegin();+   vector<uint32> possibleBids;++   while (itr != auctionHouse->GetAuctionsEnd())+   {+      AuctionHouseObject::AuctionEntryMap::iterator tmp = itr;+      ++itr;+         // Check if we want to bid ahbot auctions. If not (true), and owner is ahbot+         // we skip this iteration.+      if(_BuyerNoBidAHbotBids && tmp->second->owner == _AHBotGUID)+      {+         continue;+      }+         // Check that we haven't bidded in this auction already.+      if(tmp->second->bidder != _BuyerPlayerGUID)+      {+         uint32 tmpdata= tmp->second->Id;+         possibleBids.push_back(tmpdata);+      }+   }++      // Do we have anything to bid? If not, stop here.+   if(possibleBids.empty())+   {+      return;+   }++      // Choose random auction from possible auctions+   uint32 auctionID = possibleBids[urand(0, possibleBids.size() - 1)];++      // from auctionhouse.cpp, creates auction pointer & player pointer+   AuctionEntry* auction = auctionHouse->GetAuction(auctionID);+   Player* pl = objmgr.GetPlayer(MAKE_NEW_GUID(_BuyerPlayerGUID,0,HIGHGUID_PLAYER));++        // get exact item information+   Item *pItem = objmgr.GetAItem(auction->item_guidlow);+   if (!pItem)+   {+      sLog.outError("Item doesn't exists, perhaps bought already?");+      return;+   }++        // get item prototype+   ItemPrototype const* prototype = objmgr.GetItemPrototype(auction->item_template);++        // check which price we have to use, startbid or if it is bidded already+   uint32 currentprice;+   if(auction->bid)+   {+      currentprice = auction->bid;+   }+   else+   {+      currentprice = auction->startbid;+   }++   uint32 bidprice;++      // Prepare portion from maximum bid+   uint32 tmprate2 = urand(0, 100);+   double tmprate = static_cast<double>(tmprate2);+   double bidrate = tmprate / 100;+   long double bidMax = 0;++      // check that bid has acceptable value and take bid based on vendorprice, stacksize and quality+   switch (prototype->Quality)+   {+   case 0:+      if(currentprice < prototype->BuyPrice * pItem->GetCount() * _BuyerBidPriceGrey)+      {+         bidMax = prototype->BuyPrice * pItem->GetCount() * _BuyerBidPriceGrey;+      }+      break;+   case 1:+      if(currentprice < prototype->BuyPrice * pItem->GetCount() * _BuyerBidPriceWhite)+      {+         bidMax = prototype->BuyPrice * pItem->GetCount() * _BuyerBidPriceWhite;+      }+      break;+   case 2:+      if(currentprice < prototype->BuyPrice * pItem->GetCount() * _BuyerBidPriceGreen)+      {+         bidMax = prototype->BuyPrice * pItem->GetCount() * _BuyerBidPriceGreen;+      }+      break;+   case 3:+      if(currentprice < prototype->BuyPrice * pItem->GetCount() * _BuyerBidPriceBlue)+      {+         bidMax = prototype->BuyPrice * pItem->GetCount() * _BuyerBidPriceBlue;+      }+      break;+   case 4:+      if(currentprice < prototype->BuyPrice * pItem->GetCount() * _BuyerBidPricePurple)+      {+         bidMax = prototype->BuyPrice * pItem->GetCount() * _BuyerBidPricePurple;+      }+      break;+   default:+            // quality is something it shouldn't be, let's get out of here+      return;+      break;+   }++   if(bidMax == 0)+   {+         // quality check failed to get bidmax, let's get out of here+      return;+   }++      // Calculate our bid+   long double bidvalue = currentprice + ( (bidMax - currentprice) * bidrate);+      // Convert to uint32+   bidprice = static_cast<uint32>(bidvalue);++      // Check our bid is high enough to be valid. If not, correct it to minimum.+   if((currentprice + objmgr.GetAuctionOutBid(currentprice)) > bidprice)+   {+      bidprice = currentprice + objmgr.GetAuctionOutBid(currentprice);+   }++      // Check wether we do normal bid, or buyout+   if ((bidprice < auction->buyout) || (auction->buyout == 0))+   {+      if (auction->bidder > 0)+      {+         if ( auction->bidder == pl->GetGUIDLow() )+         {+            //pl->ModifyMoney( -int32(price - auction->bid));+         }+         else+         {+               // mail to last bidder and return money+            session->SendAuctionOutbiddedMail( auction , bidprice );+            //pl->ModifyMoney( -int32(price) );+         }+      }++      auction->bidder = pl->GetGUIDLow();+      auction->bid = bidprice;++         // Saving auction into database+      CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);+   }+   else+   {+         //buyout+      if (pl->GetGUIDLow() == auction->bidder )+      {+         //pl->ModifyMoney(-int32(auction->buyout - auction->bid));+      }+      else+      {+         //pl->ModifyMoney(-int32(auction->buyout));+         if ( auction->bidder )+         {+            session->SendAuctionOutbiddedMail( auction, auction->buyout );+         }+      }+      auction->bidder = pl->GetGUIDLow();+      auction->bid = auction->buyout;++         // Send mails to buyer & seller+      objmgr.SendAuctionSuccessfulMail( auction );+      objmgr.SendAuctionWonMail( auction );++         // Remove item from auctionhouse+      objmgr.RemoveAItem(auction->item_guidlow);+         // Remove auction+      auctionHouse->RemoveAuction(auction->Id);+         // Remove from database+      CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",auction->Id);++      delete auction;+   }+}+///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+void AuctionHouseBuyerBot()+{+ if ((_BuyerPlayerAccount == 0) || (_BuyerPlayerGUID == 0))+        return;++   time_t _newrun = time(NULL);+   if( (_newrun - _lastrun) > _BuyerBiddingInterval)+   {+      _lastrun = _newrun;+	  +	  WorldSession _session(_BuyerPlayerAccount, NULL, 0, true, 0, LOCALE_ENG);+	  //Player Buyerplayer(&_session);+	  //Buyerplayer.MinimalLoadFromDB(NULL, _BuyerPlayerGUID);+	  //ObjectAccessor::Instance().AddObject(&Buyerplayer);++      addNewAuctionBuyerBotBid(2, &_session);+      addNewAuctionBuyerBotBid(6, &_session);+      addNewAuctionBuyerBotBid(7, &_session);++	  //ObjectAccessor::Instance().RemoveObject(&Buyerplayer);+   }+}++///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+void AuctionHouseBuyerBotInit()+{+   _BuyerPlayerAccount = sConfig.GetIntDefault("AuctionHouseBotBuyer.Account", 0);+   _BuyerPlayerGUID = sConfig.GetIntDefault("AuctionHouseBotBuyer.GUID", 0);++   if ((_BuyerPlayerAccount == 0) || (_BuyerPlayerGUID == 0))+   {+      sLog.outString("AuctionHouseBotBuyer disabled");+      return;+   }++   _AHBotGUID = sConfig.GetIntDefault("AuctionHouseBot.GUID", 0);+                         +   if (_AHBotGUID == 0)+   {+      sLog.outString("AuctionHouseBot disabled or not installed");+   }++   _BuyerNoMail = sConfig.GetIntDefault("AuctionHouseBotBuyer.NoMail", 0);++   _BuyerBidPriceGrey = sConfig.GetIntDefault("AuctionHouseBotBuyer.BuyerPriceGrey",+                                         0);++   _BuyerBidPriceWhite = sConfig.GetIntDefault("AuctionHouseBotBuyer.BuyerPriceWhite",+                                         2);++   _BuyerBidPriceGreen = sConfig.GetIntDefault("AuctionHouseBotBuyer.BuyerPriceGreen",+                                         3);++   _BuyerBidPriceBlue = sConfig.GetIntDefault("AuctionHouseBotBuyer.BuyerPriceBlue",+                                        4);++   _BuyerBidPricePurple = sConfig.GetIntDefault("AuctionHouseBotBuyer.BuyerPricePurple",+                                          5);++   _BuyerBiddingInterval = sConfig.GetIntDefault("AuctionHouseBotBuyer.BiddingInterval", 60);++   _BuyerNoBidAHbotBids = sConfig.GetIntDefault("AuctionHouseBotBuyer.NoAHbotBidding", 0);++   sLog.outString("AuctionHouseBotBuyer v0.5.0.5734 by |Paradox| (original by Kerbe)  has been loaded.");+}Index: src/game/AuctionHouseBuyer.h===================================================================--- src/game/AuctionHouseBuyer.h	(revision 0)+++ src/game/AuctionHouseBuyer.h	(revision 0)@@ -0,0 +1,10 @@+#ifndef AUCTION_HOUSE_BUYER_H+#define AUCTION_HOUSE_BUYER_H++#include "Common.h"++uint32 AuctionHouseBuyerBotNoMail();+void AuctionHouseBuyerBot();+void AuctionHouseBuyerBotInit();++#endifIndex: src/game/Chat.cpp===================================================================--- src/game/Chat.cpp	(revision 5734)+++ src/game/Chat.cpp	(working copy)@@ -282,6 +282,8 @@         { "npcinfoset",     SEC_ADMINISTRATOR,  &ChatHandler::HandleNpcInfoSetCommand,          "", NULL },         { "addvendoritem",  SEC_GAMEMASTER,     &ChatHandler::HandleAddVendorItemCommand,       "", NULL },         { "delvendoritem",  SEC_GAMEMASTER,     &ChatHandler::HandleDelVendorItemCommand,       "", NULL },+        { "ahexpire",       SEC_ADMINISTRATOR,  &ChatHandler::HandleAHExpireCommand,            "",   NULL },+        { "ahdelete",       SEC_ADMINISTRATOR,  &ChatHandler::HandleAHDeleteCommand,            "",   NULL },         { "itemmove",       SEC_GAMEMASTER,     &ChatHandler::HandleItemMoveCommand,            "", NULL },         { "kick",           SEC_GAMEMASTER,     &ChatHandler::HandleKickPlayerCommand,          "", NULL },         { "learn",          SEC_MODERATOR,      NULL,                                           "", learnCommandTable },Index: src/game/Chat.h===================================================================--- src/game/Chat.h	(revision 5734)+++ src/game/Chat.h	(working copy)@@ -315,6 +315,8 @@         bool HandleLookupQuestCommand(const char* args);         bool HandleLookupCreatureCommand(const char* args);         bool HandleLookupObjectCommand(const char* args);+        bool HandleAHExpireCommand(const char * args);+        bool HandleAHDeleteCommand(const char * args);         bool HandlePasswordCommand(const char* args);         bool HandleLockAccountCommand(const char* args);         bool HandleRespawnCommand(const char* args);Index: src/game/Level0.cpp===================================================================--- src/game/Level0.cpp	(revision 5734)+++ src/game/Level0.cpp	(working copy)@@ -113,6 +113,9 @@      SendSysMessage(LANG_AVIABLE_CMD); +    uint32 c = 0;+    char a[1024] = "";+     for(uint32 i = 0; table[i].Name != NULL; i++)     {         if(*args && !hasStringAbbr(table[i].Name, (char*)args))@@ -121,9 +124,19 @@         if(m_session->GetSecurity() < table[i].SecurityLevel)             continue; -        SendSysMessage(table[i].Name);+        sprintf(a, "%s%s, ", a, table[i].Name);+        c++;+        if (c >= 10) {+			SendSysMessage(a);+			sprintf(a, "");+			c = 0;+		}+		//        SendSysMessage(table[i].Name);+     }-+	if (c > 0) {+		SendSysMessage(a);+	}     return true; } Index: src/game/Level3.cpp===================================================================--- src/game/Level3.cpp	(revision 5734)+++ src/game/Level3.cpp	(working copy)@@ -4312,6 +4312,92 @@     return true; } +bool ChatHandler::HandleAHExpireCommand(const char* args)+{+   if (args == NULL)+      return false;++   char* ahMapIdStr = strtok((char*) args, " ");+   char* playerGuidStr = strtok(NULL, " ");++   if ((ahMapIdStr == NULL) || (playerGuidStr == NULL))+      return false;++   uint32 ahMapID = (uint32) strtoul(ahMapIdStr, NULL, 0);+   uint32 playerGUID = (uint32) strtoul(playerGuidStr, NULL, 0);++   AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);++   if (auctionHouse == NULL)+      return false;++   AuctionHouseObject::AuctionEntryMap::iterator itr;+   itr = auctionHouse->GetAuctionsBegin();++   while (itr != auctionHouse->GetAuctionsEnd())+   {+      if (itr->second->owner == playerGUID)+         itr->second->time = sWorld.GetGameTime();++      ++itr;+   }++   return true;+}++bool ChatHandler::HandleAHDeleteCommand(const char* args)+{+   if (args == NULL)+      return false;++   char* ahMapIdStr = strtok((char*) args, " ");+   char* playerGuidStr = strtok(NULL, " ");++   if ((ahMapIdStr == NULL) || (playerGuidStr == NULL))+      return false;++   uint32 ahMapID = (uint32) strtoul(ahMapIdStr, NULL, 0);+   uint32 playerGUID = (uint32) strtoul(playerGuidStr, NULL, 0);++   AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);++   if (auctionHouse == NULL)+      return false;++   AuctionHouseObject::AuctionEntryMap::iterator itr;+   itr = auctionHouse->GetAuctionsBegin();++   while (itr != auctionHouse->GetAuctionsEnd())+   {+      AuctionHouseObject::AuctionEntryMap::iterator tmp = itr;+      ++itr;++      if (tmp->second->owner != playerGUID)+         continue;++      Item* item = objmgr.GetAItem(tmp->second->item_guidlow);+      if (item != NULL)+      {+         objmgr.RemoveAItem(tmp->second->item_guidlow);+         item->DeleteFromDB();+         delete item;+      }+      else+      {+         sLog.outString("ahdelete: "+                        "clearing auction for non-existant item_guidlow (%d)",+                        tmp->second->item_guidlow);+      }++      CharacterDatabase.PExecute("DELETE FROM `auctionhouse` WHERE `id` = '%u'",+                                 tmp->second->Id);+      auctionHouse->RemoveAuction(tmp->second->Id);+      delete tmp->second;+   }++   return true;+}+ bool ChatHandler::HandleBanListCommand(const char* args) {     loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");Index: src/game/Makefile.am===================================================================--- src/game/Makefile.am	(revision 5734)+++ src/game/Makefile.am	(working copy)@@ -38,10 +38,14 @@ 	ArenaTeam.cpp \ 	ArenaTeam.h \ 	ArenaTeamHandler.cpp \+	AuctionHouseBot.cpp \+	AuctionHouseBot.h \ 	AuctionHouse.cpp \ 	AuctionHouseObject.h \ 	Bag.cpp \ 	Bag.h \+	AuctionHouseBuyer.cpp \+	AuctionHouseBuyer.h \ 	BattleGround.cpp \ 	BattleGroundAA.cpp \ 	BattleGroundAB.cpp \Index: src/game/ObjectMgr.cpp===================================================================--- src/game/ObjectMgr.cpp	(revision 5734)+++ src/game/ObjectMgr.cpp	(working copy)@@ -20,6 +20,7 @@ #include "Database/DatabaseEnv.h" #include "Database/SQLStorage.h" +#include "AuctionHouseBot.h" #include "Log.h" #include "MapManager.h" #include "ObjectMgr.h"@@ -32,6 +33,7 @@ #include "ArenaTeam.h" #include "Transports.h" #include "ProgressBar.h"+#include "AuctionHouseBuyer.h" #include "Policies/SingletonImp.h" #include "Language.h" #include "GameEvent.h"@@ -244,6 +246,9 @@ //does not clear ram void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction ) {+	if (auction->bidder == AuctionHouseBuyerBotNoMail())+        return;+     Item *pItem = objmgr.GetAItem(auction->item_guidlow);     if(!pItem)         return;@@ -334,6 +339,9 @@ //call this method to send mail to auction owner, when auction is successful, it does not clear ram void ObjectMgr::SendAuctionSuccessfulMail( AuctionEntry * auction ) {+    if (auction->owner == AuctionHouseBotNoMail())+        return;+     Item *pItem = objmgr.GetAItem(auction->item_guidlow);     if(!pItem)         return;Index: src/game/Player.cpp===================================================================--- src/game/Player.cpp	(revision 5734)+++ src/game/Player.cpp	(working copy)@@ -534,6 +534,7 @@      // set starting level     SetUInt32Value( UNIT_FIELD_LEVEL, sWorld.getConfig(CONFIG_START_PLAYER_LEVEL) );+    SetUInt32Value( PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_START_PLAYER_MONEY) * 10000 );      // Played time     m_Last_tick = time(NULL);Index: src/game/World.cpp===================================================================--- src/game/World.cpp	(revision 5734)+++ src/game/World.cpp	(working copy)@@ -35,10 +35,12 @@ #include "World.h" #include "ObjectMgr.h" #include "SpellMgr.h"+#include "AuctionHouseBuyer.h" #include "Chat.h" #include "Database/DBCStores.h" #include "LootMgr.h" #include "ItemEnchantmentMgr.h"+#include "AuctionHouseBot.h" #include "MapManager.h" #include "ScriptCalls.h" #include "CreatureAIRegistry.h"@@ -431,6 +433,17 @@         sLog.outError("StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to %u.",m_configs[CONFIG_START_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL],m_configs[CONFIG_MAX_PLAYER_LEVEL]);         m_configs[CONFIG_START_PLAYER_LEVEL] = m_configs[CONFIG_MAX_PLAYER_LEVEL];     }+    m_configs[CONFIG_START_PLAYER_MONEY] = sConfig.GetIntDefault("StartPlayerMoney", 1);+    if(m_configs[CONFIG_START_PLAYER_MONEY] < 0)+    {+        sLog.outError("StartPlayerMoney (%i) must be a positive number. Set to 0.",m_configs[CONFIG_START_PLAYER_MONEY]);+        m_configs[CONFIG_START_PLAYER_MONEY] = 0;+    }+    else if(m_configs[CONFIG_START_PLAYER_MONEY] > 214748)+    {+        sLog.outError("StartPlayerMoney (%i) must be in range 0..MaxPlayerMoney(%u). Set to %u.",m_configs[CONFIG_START_PLAYER_MONEY],214748,214748);+        m_configs[CONFIG_START_PLAYER_MONEY] = 214748;+    }     m_configs[CONFIG_INSTANCE_IGNORE_LEVEL] = sConfig.GetBoolDefault("Instance.IgnoreLevel", false);     m_configs[CONFIG_INSTANCE_IGNORE_RAID]  = sConfig.GetBoolDefault("Instance.IgnoreRaid", false);     m_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = sConfig.GetBoolDefault("Battleground.CastDeserter", true);@@ -857,10 +870,14 @@     sLog.outString("Calculate next daily quest reset time..." );     InitDailyQuestResetTime(); +    AuctionHouseBuyerBotInit();+     sLog.outString("Starting Game Event system..." );     uint32 nextGameEvent = gameeventmgr.Initialize();     m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);    //depend on next event +    AuctionHouseBotInit();+     sLog.outString( "WORLD: World initialized" ); } @@ -912,11 +929,15 @@         m_NextDailyQuestReset += 24*HOUR;     } +     /// <ul><li> Handle auctions when the timer has passed     if (m_timers[WUPDATE_AUCTIONS].Passed())     {+		AuctionHouseBot();         m_timers[WUPDATE_AUCTIONS].Reset(); +        AuctionHouseBuyerBot();+         ///- Update mails (return old mails with item, or delete them)         //(tested... works on win)         if (++mail_timer > mail_timer_expires)Index: src/game/World.h===================================================================--- src/game/World.h	(revision 5734)+++ src/game/World.h	(working copy)@@ -82,6 +82,7 @@     CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND,     CONFIG_MAX_PLAYER_LEVEL,     CONFIG_START_PLAYER_LEVEL,+	CONFIG_START_PLAYER_MONEY,     CONFIG_INSTANCE_IGNORE_LEVEL,     CONFIG_INSTANCE_IGNORE_RAID,     CONFIG_BATTLEGROUND_CAST_DESERTER,Index: src/mangosd/CliRunnable.cpp===================================================================--- src/mangosd/CliRunnable.cpp	(revision 5734)+++ src/mangosd/CliRunnable.cpp	(working copy)@@ -68,6 +68,8 @@ void CliSend(char*,pPrintf); void CliPLimit(char*,pPrintf); void CliSetPassword(char*,pPrintf);+void CliHandleAHExpireCommand(char*,pPrintf);+void CliHandleAHDeleteCommand(char*,pPrintf); /// Table of known commands const CliCommand Commands[]= {@@ -98,11 +100,86 @@     {"saveall", &CliSave,"Save all players"},     {"send", &CliSend,"Send message to a player"},     {"tele", &CliTele,"Teleport player to location"},+    {"ahexpire", &CliHandleAHExpireCommand,"Expire all auctions from AuctionBot character"},+    {"ahdelete", &CliHandleAHDeleteCommand,"Delete all auctions from AuctionBot character"},     {"plimit", &CliPLimit,"Show or set player login limitations"} }; /// \todo Need some pragma pack? Else explain why in a comment. #define CliTotalCmds sizeof(Commands)/sizeof(CliCommand) +void CliHandleAHExpireCommand(char*command,pPrintf zprintf)+{+    char * ahMapIdStr = strtok(command, " ");+    char * playerGuidStr = strtok(NULL, " ");+    if(!ahMapIdStr || !playerGuidStr)+    {+        zprintf("Syntax is: ahexpire $ahMapID (2, 6 or 7) $playerGUID\r\n");+        return;+    }+   uint32 ahMapID = (uint32) strtoul(ahMapIdStr, NULL, 0);+   uint32 playerGUID = (uint32) strtoul(playerGuidStr, NULL, 0);++   AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);++   AuctionHouseObject::AuctionEntryMap::iterator itr;+   itr = auctionHouse->GetAuctionsBegin();++   while (itr != auctionHouse->GetAuctionsEnd())+   {+      if (itr->second->owner == playerGUID)+         itr->second->time = sWorld.GetGameTime();++      ++itr;+   }++}++void CliHandleAHDeleteCommand(char*command,pPrintf zprintf)+{+    char * ahMapIdStr = strtok(command, " ");+    char * playerGuidStr = strtok(NULL, " ");+    if(!ahMapIdStr || !playerGuidStr)+    {+        zprintf("Syntax is: ahdelete $ahMapID (2, 6 or 7) $playerGUID\r\n");+        return;+    }+   uint32 ahMapID = (uint32) strtoul(ahMapIdStr, NULL, 0);+   uint32 playerGUID = (uint32) strtoul(playerGuidStr, NULL, 0);++   AuctionHouseObject* auctionHouse = objmgr.GetAuctionsMap(ahMapID);++   AuctionHouseObject::AuctionEntryMap::iterator itr;+   itr = auctionHouse->GetAuctionsBegin();++   while (itr != auctionHouse->GetAuctionsEnd())+   {+      AuctionHouseObject::AuctionEntryMap::iterator tmp = itr;+      ++itr;++      if (tmp->second->owner != playerGUID)+         continue;++      Item* item = objmgr.GetAItem(tmp->second->item_guidlow);+      if (item != NULL)+      {+         objmgr.RemoveAItem(tmp->second->item_guidlow);+         item->DeleteFromDB();+         delete item;+      }+      else+      {+         sLog.outString("ahdelete: "+                        "clearing auction for non-existant item_guidlow (%d)",+                        tmp->second->item_guidlow);+      }++      CharacterDatabase.PExecute("DELETE FROM `auctionhouse` WHERE `id` = '%u'",+                                 tmp->second->Id);+      auctionHouse->RemoveAuction(tmp->second->Id);+      delete tmp->second;+   }++} /// Create a character dump file void CliWritePlayerDump(char*command,pPrintf zprintf) {Index: src/mangosd/mangosd.conf.in===================================================================--- src/mangosd/mangosd.conf.in	(revision 5734)+++ src/mangosd/mangosd.conf.in	(working copy)@@ -300,6 +300,11 @@ #        Staring level that have character at creating (in range 1 to MaxPlayerLevel) #        Default: 1 #+#    StartPlayerMoney+#        Starting money in Gold that have character at creating (in range 0 to 214748)+#        Todo: Break this up by copper silver and gold+#        Default: 0+# #    ActivateWeather #        Activate weather system #        Default: 1 (true)@@ -378,6 +383,7 @@ DBC.Locale = 255 MaxPlayerLevel = 70 StartPlayerLevel = 1+StartPlayerMoney = 0 ActivateWeather = 1 Battleground.CastDeserter = 1 CastUnstuck = 1@@ -754,3 +760,207 @@ Ra.Port = 3443 Ra.MinLevel = 3 Ra.Secure = 1++###################################################################################################################+# AUCTION HOUSE BOT SETTINGS+# +#    Auction House Bot character data+#        AuctionHouseBot.Account is the account number (in realmd->account table) of the player you want to run as the auction bot.+# 	    AuctionHouseBot.GUID is the GUID (in characters->characters table) of the player you want to run as the auction bot. +#    Default: 0 (Auction House Bot disabled)+#+#    AuctionHouseBot.NoMail+#        This is a flag to disable mail for successfull auctions. +#        A value of 0 will allow mail for successful auctions to be sent, which is the default.+#        Non-zero (e.g. AuctionHouseBot.NoMail = 1) will stop successful auction mail.+#    Default: 0 (Send auction successful mail)+# +#    AuctionHouseBot.AllianceItems+#        This is the number of items you want to keep in the Alliance auction house.+#    AuctionHouseBot.HordeItems+#        This is the number of items you want to keep in the Horde auction house.+#    AuctionHouseBot.NeutralItems+#        This is the number of items you want to keep in the Neutral auction house.+#    Default: 0 (No items generated)+#        Note: If you enable AllowTwoSide.Interaction.Trade, ALL auction houses are linked to the neutral auction house.+#+#    AuctionHouseBot.MinAllianceItems+#        This is the minimum number of items you want to keep in the Alliance auction house.+#    AuctionHouseBot.MinHordeItems+#        This is the minimum number of items you want to keep in the Horde auction house.+#    AuctionHouseBot.MinNeutralItems+#        This is the minimum number of items you want to keep in the Neutral auction house.+#    Default: -1 (minimum will be the same as maximum)+# +#    AuctionHouseBot.MinTime+#        Sets the minimum number of hours for an auction.+#    Default: 8+#+#    AuctionHouseBot.MaxTime+#        Sets the maximum number of hours for an auction.+#    Default: 24+#+#    Item distribution+#        Sets the percentage of the auction items that should be trade goods of white quality.+#        A value of 0 will disable.+#    AuctionHouseBot.PercentWhiteTradeGoods+#        Sets the percentage of the White Trade Goods auction items+#    Default: 30+#    AuctionHouseBot.PercentGreenTradeGoods+#        Sets the percentage of the Green Trade Goods auction items+#    Default: 13+#    AuctionHouseBot.PercentBlueTradeGoods+#        Sets the percentage of the Blue Trade Goods auction items+#    Default: 9+#    AuctionHouseBot.PercentPurpleTradeGoods+#        Sets the percentage of the Purple Trade Goods auction items+#    Default: 1+#        Note: All of the above values (AuctionHouseBot Percent TradeGoods) must add together to make 100 percent.+#+#    AuctionHouseBot.PercentWhiteItems+#        Sets the percentage of the non trade White auction items+#    Default: 6+#    AuctionHouseBot.PercentGreenItems+#        Sets the percentage of the non trade Green auction items+#    Default: 30+#    AuctionHouseBot.PercentBlueItems+#        Sets the percentage of the non trade Blue auction items+#    Default: 9+#    AuctionHouseBot.PercentPurpleItems+#        Sets the percentage of the non trade Purple auction items+#    Default: 2+#        Note: All of the above values (AuctionHouseBot Percent Items) must add together to make 100 percent.+#+#    Minimum and maximim price mark-up for items.  Percentage of vendor sale price.+#        Example: If a vendor would sell an item for 1g and MinPrice = 150 and MaxPrice = 250,+#        then that item would be randomly priced between 1g 50s and 2g 50s.+#    AuctionHouseBot.MinPriceWhite+#        Minimum price of White items.+#    Default: 150+#    AuctionHouseBot.MaxPriceWhite+#        Maximum price of White items.+#    Default: 250+#    AuctionHouseBot.MinPriceGreen+#        Minimum price of Green items.+#    Default: 200+#    AuctionHouseBot.MaxPriceGreen+#        Maximum price of Green items.+#    Default: 300+#    AuctionHouseBot.MinPriceBlue+#        Minimum price of Blue items.+#    Default: 250+#    AuctionHouseBot.MaxPriceBlue+#        Maximum price of Blue items.+#    Default: 350+#    AuctionHouseBot.MinPricePurple+#        Minimum price of Purple items.+#    Default: 300+#    AuctionHouseBot.MaxPricePurple+#        Maximum price of Purple items.+#    Default: 450+#+#    AuctionHouseBot.BidPrice+#    Starting bid price as a percentage of the randomly chosen buyout price+#    AuctionHouseBot.BidPriceWhite+#    Default: 100 (Bid and buyout price the same)+#    AuctionHouseBot.BidPriceGreen+#    Default: 100 (Bid and buyout price the same)+#    AuctionHouseBot.BidPriceBlue+#    Default: 100 (Bid and buyout price the same)+#    +AuctionHouseBot.BidPricePurple+#    Default: 100 (Bid and buyout price the same)+#+#    AuctionHouseBot.MaxStack+#        Stack size limits for item qualities - a value of 0 will disable a maximum stack size for that quality,+#        which will allow the bot to create items in stack as large as the item allows.+#    AuctionHouseBot.MaxStackWhite+#    Default: 0+#    AuctionHouseBot.MaxStackGreen+#    Default: 3+#    AuctionHouseBot.MaxStackBlue+#    Default: 2+#    AuctionHouseBot.MaxStackPurple+#    Default: 1+#+###################################################################################################################++AuctionHouseBot.Account = 0+AuctionHouseBot.GUID = 0+AuctionHouseBot.NoMail = 0+AuctionHouseBot.AllianceItems = 0+AuctionHouseBot.HordeItems = 0+AuctionHouseBot.NeutralItems = 0+AuctionHouseBot.MinAllianceItems = -1+AuctionHouseBot.MinHordeItems = -1+AuctionHouseBot.MinNeutralItems = -1+AuctionHouseBot.MinTime = 8+AuctionHouseBot.MaxTime = 24+AuctionHouseBot.PercentWhiteTradeGoods = 30+AuctionHouseBot.PercentGreenTradeGoods = 13+AuctionHouseBot.PercentBlueTradeGoods = 9+AuctionHouseBot.PercentPurpleTradeGoods = 1+AuctionHouseBot.PercentWhiteItems = 6+AuctionHouseBot.PercentGreenItems = 30+AuctionHouseBot.PercentBlueItems = 9+AuctionHouseBot.PercentPurpleItems = 2+AuctionHouseBot.MinPriceWhite = 150+AuctionHouseBot.MaxPriceWhite = 250+AuctionHouseBot.MinPriceGreen = 200+AuctionHouseBot.MaxPriceGreen = 300+AuctionHouseBot.MinPriceBlue = 250+AuctionHouseBot.MaxPriceBlue = 350+AuctionHouseBot.MinPricePurple = 300+AuctionHouseBot.MaxPricePurple = 450+AuctionHouseBot.BidPriceWhite = 100+AuctionHouseBot.BidPriceGreen = 100+AuctionHouseBot.BidPriceBlue = 100+AuctionHouseBot.BidPricePurple = 100+AuctionHouseBot.MaxStackWhite = 0+AuctionHouseBot.MaxStackGreen = 3+AuctionHouseBot.MaxStackBlue = 2+AuctionHouseBot.MaxStackPurple = 1++###############################################################################+# AUCTION HOUSE BOT BUYER OPTIONS+#+# AuctionHouseBotBuyer.Account+#   Account of buyerbot+#+# AuctionHouseBotBuyer.GUID+#   GUID of buyer character+#+# AuctionHouseBotBuyer.NoMail+#   Do we send mail to AHB. Default is no.+#+# AuctionHouseBotBuyer.BuyerPriceWhite+#   Multiplier to vendorprice when buying white items from auctionhouse+#+# AuctionHouseBotBuyer.BuyerPriceGreen+#   Multiplier to vendorprice when buying green items from auctionhouse+#+# AuctionHouseBotBuyer.BuyerPriceBlue+#   Multiplier to vendorprice when buying blue items from auctionhouse+#+# AuctionHouseBotBuyer.BuyerPricePurple+#   Multiplier to vendorprice when buying purple items from auctionhouse+#+# AuctionHouseBotBuyer.BiddingInterval+#   Interval how frequently AHB bids on each AH. Time in seconds+#+# AuctionHouseBotBuyer.NoAHbotBidding+#   Stop bidding on AHBot bids in auctionhouses. Default is no.+#                 1 (true) (no AHBot auctions are bid)+#        Default: 0 (false)(also AHBot auctions are bid)+#+###############################################################################++AuctionHouseBotBuyer.Account = 0+AuctionHouseBotBuyer.GUID = 0+AuctionHouseBotBuyer.NoMail = 1+AuctionHouseBotBuyer.BuyerPriceGrey = 0+AuctionHouseBotBuyer.BuyerPriceWhite = 2+AuctionHouseBotBuyer.BuyerPriceGreen = 3+AuctionHouseBotBuyer.BuyerPriceBlue = 4+AuctionHouseBotBuyer.BuyerPricePurple = 5+AuctionHouseBotBuyer.BiddingInterval = 60+AuctionHouseBotBuyer.NoAHbotBidding = 0Index: win/VC71/game.vcproj===================================================================--- win/VC71/game.vcproj	(revision 5734)+++ win/VC71/game.vcproj	(working copy)@@ -457,6 +457,12 @@ 				RelativePath="..\..\src\game\ArenaTeam.h"> 			</File> 			<File+				RelativePath="..\..\src\game\AuctionHouseBot.cpp">+			</File>+			<File+				RelativePath="..\..\src\game\AuctionHouseBot.h">+			</File>+			<File 				RelativePath="..\..\src\game\AuctionHouseObject.h"> 			</File> 			<File@@ -466,6 +472,12 @@ 				RelativePath="..\..\src\game\Bag.h"> 			</File> 			<File+				RelativePath="..\..\src\game\AuctionHouseBuyer.cpp">+			</File>+ 			<File+				RelativePath="..\..\src\game\AuctionHouseBuyer.h">+			</File>+			<File 				RelativePath="..\..\src\game\ConfusedMovementGenerator.cpp"> 			</File> 			<FileIndex: win/VC80/game.vcproj===================================================================--- win/VC80/game.vcproj	(revision 5734)+++ win/VC80/game.vcproj	(working copy)@@ -783,6 +783,14 @@ 				> 			</File> 			<File+				RelativePath="..\..\src\game\AuctionHouseBot.cpp"+				>+			</File>+			<File+				RelativePath="..\..\src\game\AuctionHouseBot.h"+				>+			</File>+			<File 				RelativePath="..\..\src\game\AuctionHouseObject.h" 				> 			</File>@@ -795,6 +803,12 @@ 				> 			</File> 			<File+				RelativePath="..\..\src\game\AuctionHouseBuyer.cpp">+			</File>+ 			<File+				RelativePath="..\..\src\game\AuctionHouseBuyer.h">+			</File>+			<File 				RelativePath="..\..\src\game\ConfusedMovementGenerator.cpp" 				> 			</File>Index: win/VC90/game.vcproj===================================================================--- win/VC90/game.vcproj	(revision 5734)+++ win/VC90/game.vcproj	(working copy)@@ -788,6 +788,22 @@ 				> 			</File> 			<File+				RelativePath="..\..\src\game\AuctionHouseBot.cpp"+				>+			</File>+			<File+				RelativePath="..\..\src\game\AuctionHouseBot.h"+				>+			</File>+			<File+				RelativePath="..\..\src\game\AuctionHouseBuyer.cpp"+				>+			</File>+			<File+				RelativePath="..\..\src\game\AuctionHouseBuyer.h"+				>+			</File>+			<File 				RelativePath="..\..\src\game\AuctionHouseObject.h" 				> 			</File>