rendered paste bodyIndex: src/game/AuctionHouse.cpp===================================================================--- src/game/AuctionHouse.cpp (revision 5732)+++ src/game/AuctionHouse.cpp (working copy)@@ -19,6 +19,7 @@ #include "WorldPacket.h" #include "WorldSession.h" #include "Opcodes.h"+#include "Config/ConfigEnv.h" #include "Log.h" #include "World.h" #include "ObjectMgr.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/AuctionHouseBuyer.cpp===================================================================--- src/game/AuctionHouseBuyer.cpp (revision 0)+++ src/game/AuctionHouseBuyer.cpp (revision 0)@@ -0,0 +1,296 @@+#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;++static WorldSession session(_BuyerPlayerAccount, NULL, 0, true, 0, LOCALE_ENG);+static Player Buyerplayer(&session);++time_t _lastrun;+///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+uint32 AuctionHouseBuyerBotNoMail()+{+ return _BuyerNoMail != 0 ? _BuyerPlayerGUID : 0;+}++///////////////////////////////////////////////////////////////////////////////+//+///////////////////////////////////////////////////////////////////////////////+static void addNewAuctionBuyerBotBid(uint32 ahMapID)+{++ // 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.ccp, 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;++ Buyerplayer.MinimalLoadFromDB(NULL, _BuyerPlayerGUID);+ ObjectAccessor::Instance().AddObject(&Buyerplayer);++ addNewAuctionBuyerBotBid(2);+ addNewAuctionBuyerBotBid(6);+ addNewAuctionBuyerBotBid(7);+ + 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.4.2.5648 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/Makefile.am===================================================================--- src/game/Makefile.am (revision 5732)+++ src/game/Makefile.am (working copy)@@ -42,6 +42,8 @@ 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 5732)+++ src/game/ObjectMgr.cpp (working copy)@@ -32,6 +32,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 +245,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;Index: src/game/World.cpp===================================================================--- src/game/World.cpp (revision 5732)+++ src/game/World.cpp (working copy)@@ -35,6 +35,7 @@ #include "World.h" #include "ObjectMgr.h" #include "SpellMgr.h"+#include "AuctionHouseBuyer.h" #include "Chat.h" #include "Database/DBCStores.h" #include "LootMgr.h"@@ -851,6 +852,8 @@ sLog.outString( "Loading Transports..." ); MapManager::Instance().LoadTransports(); + AuctionHouseBuyerBotInit();+ sLog.outString("Deleting expired bans..." ); loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); @@ -925,6 +928,8 @@ objmgr.ReturnOrDeleteOldMails(true); } + AuctionHouseBuyerBot();+ AuctionHouseObject* AuctionMap; for (int i = 0; i < 3; i++) {Index: src/mangosd/mangosd.conf.in===================================================================--- src/mangosd/mangosd.conf.in (revision 5732)+++ src/mangosd/mangosd.conf.in (working copy)@@ -754,3 +754,48 @@ Ra.Port = 3443 Ra.MinLevel = 3 Ra.Secure = 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 5732)+++ win/VC71/game.vcproj (working copy)@@ -472,6 +472,12 @@ RelativePath="..\..\src\game\ConfusedMovementGenerator.h"> </File> <File+ RelativePath="..\..\src\game\AuctionHouseBuyer.cpp">+ </File>+ <File+ RelativePath="..\..\src\game\AuctionHouseBuyer.h">+ </File>+ <File RelativePath="..\..\src\game\Corpse.cpp"> </File> <FileIndex: win/VC80/game.vcproj===================================================================--- win/VC80/game.vcproj (revision 5732)+++ win/VC80/game.vcproj (working copy)@@ -803,6 +803,12 @@ > </File> <File+ RelativePath="..\..\src\game\AuctionHouseBuyer.cpp">+ </File>+ <File+ RelativePath="..\..\src\game\AuctionHouseBuyer.h">+ </File>+ <File RelativePath="..\..\src\game\Corpse.cpp" > </File>Index: win/VC90/game.vcproj===================================================================--- win/VC90/game.vcproj (revision 5732)+++ win/VC90/game.vcproj (working copy)@@ -808,6 +808,12 @@ > </File> <File+ RelativePath="..\..\src\game\AuctionHouseBuyer.cpp">+ </File>+ <File+ RelativePath="..\..\src\game\AuctionHouseBuyer.h">+ </File>+ <File RelativePath="..\..\src\game\Corpse.cpp" > </File>