mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 09:17:21 +00:00
1013 lines
47 KiB
C++
1013 lines
47 KiB
C++
/*
|
|
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#include "ObjectMgr.h"
|
|
#include "AuctionHouseMgr.h"
|
|
#include "AuctionHouseBot.h"
|
|
#include "Config.h"
|
|
#include "Player.h"
|
|
#include "WorldSession.h"
|
|
#include "GameTime.h"
|
|
#include "DatabaseEnv.h"
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
vector<uint32> itemCandidates;
|
|
|
|
AuctionHouseBot::AuctionHouseBot()
|
|
{
|
|
debug_Out = false;
|
|
debug_Out_Filters = false;
|
|
AHBSeller = false;
|
|
AHBBuyer = false;
|
|
|
|
_lastrun_a = time(NULL);
|
|
_lastrun_h = time(NULL);
|
|
_lastrun_n = time(NULL);
|
|
|
|
AllianceConfig = AHBConfig(2);
|
|
HordeConfig = AHBConfig(6);
|
|
NeutralConfig = AHBConfig(7);
|
|
}
|
|
|
|
AuctionHouseBot::~AuctionHouseBot()
|
|
{
|
|
}
|
|
|
|
uint32 AuctionHouseBot::getStackSizeForItem(ItemTemplate const* itemProto) const
|
|
{
|
|
// Determine the stack ratio based on class type
|
|
if (itemProto == NULL)
|
|
return 1;
|
|
|
|
// TODO: Move this to a config
|
|
uint32 stackRatio = 0;
|
|
switch (itemProto->Class)
|
|
{
|
|
case ITEM_CLASS_CONSUMABLE: stackRatio = 75; break;
|
|
case ITEM_CLASS_CONTAINER: stackRatio = 0; break;
|
|
case ITEM_CLASS_WEAPON: stackRatio = 0; break;
|
|
case ITEM_CLASS_GEM: stackRatio = 5; break;
|
|
case ITEM_CLASS_REAGENT: stackRatio = 50; break;
|
|
case ITEM_CLASS_ARMOR: stackRatio = 0; break;
|
|
case ITEM_CLASS_PROJECTILE: stackRatio = 100; break;
|
|
case ITEM_CLASS_TRADE_GOODS: stackRatio = 25; break;
|
|
case ITEM_CLASS_GENERIC: stackRatio = 100; break;
|
|
case ITEM_CLASS_RECIPE: stackRatio = 0; break;
|
|
case ITEM_CLASS_QUIVER: stackRatio = 0; break;
|
|
case ITEM_CLASS_QUEST: stackRatio = 10; break;
|
|
case ITEM_CLASS_KEY: stackRatio = 10; break;
|
|
case ITEM_CLASS_MISC: stackRatio = 100; break;
|
|
case ITEM_CLASS_GLYPH: stackRatio = 0; break;
|
|
default: stackRatio = 0; break;
|
|
}
|
|
|
|
if (stackRatio > urand(0, 99))
|
|
return urand(1, itemProto->GetMaxStackSize());
|
|
else
|
|
return 1;
|
|
}
|
|
|
|
void AuctionHouseBot::calculateItemValue(ItemTemplate const* itemProto, uint64& outBidPrice, uint64& outBuyoutPrice)
|
|
{
|
|
// Start with a buyout price related to the sell price
|
|
outBuyoutPrice = itemProto->SellPrice;
|
|
|
|
// Set a minimum base buyoutPrice to 1 silver
|
|
if (outBuyoutPrice < 100)
|
|
{
|
|
// TODO: Move to a config
|
|
outBuyoutPrice = 100;
|
|
}
|
|
|
|
// Multiply the price by the quality
|
|
outBuyoutPrice *= itemProto->Quality;
|
|
|
|
// If a vendor sells this item, make the base price the same as the vendor price
|
|
// TODO::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
// Add a variance to the buyout price, minimum of 1%
|
|
uint64 sellVarianceBuyoutPriceTopPercent = 150;
|
|
uint64 sellVarianceBuyoutPriceBottomPercent = 75;
|
|
|
|
// Constrain variance top so that it can't be lower than bottom, and minimum values are 1%
|
|
if (sellVarianceBuyoutPriceTopPercent == 0)
|
|
sellVarianceBuyoutPriceTopPercent = 1;
|
|
if (sellVarianceBuyoutPriceBottomPercent == 0)
|
|
sellVarianceBuyoutPriceBottomPercent = 1;
|
|
if (sellVarianceBuyoutPriceTopPercent < sellVarianceBuyoutPriceBottomPercent)
|
|
sellVarianceBuyoutPriceTopPercent = sellVarianceBuyoutPriceBottomPercent;
|
|
|
|
// Apply variance to buyout price
|
|
outBuyoutPrice = urand(sellVarianceBuyoutPriceBottomPercent * outBuyoutPrice, sellVarianceBuyoutPriceTopPercent * outBuyoutPrice);
|
|
outBuyoutPrice /= 100;
|
|
|
|
// Calculate a bid price based on a variance against buyout price, minimum of 1%
|
|
uint64 sellVarianceBidPriceTopPercent = 100;
|
|
uint64 sellVarianceBidPriceBottomPercent = 75;
|
|
if (sellVarianceBidPriceTopPercent == 0)
|
|
sellVarianceBidPriceTopPercent = 1;
|
|
if (sellVarianceBidPriceBottomPercent == 0)
|
|
sellVarianceBidPriceBottomPercent = 1;
|
|
if (sellVarianceBidPriceTopPercent < sellVarianceBidPriceBottomPercent)
|
|
sellVarianceBidPriceTopPercent = sellVarianceBidPriceBottomPercent;
|
|
|
|
// Calculate the bid price
|
|
outBidPrice = urand(sellVarianceBidPriceBottomPercent * outBuyoutPrice, sellVarianceBidPriceTopPercent * outBuyoutPrice);
|
|
outBidPrice /= 100;
|
|
}
|
|
|
|
void AuctionHouseBot::populateItemCandidateList()
|
|
{
|
|
// Clear old list
|
|
itemCandidates.clear();
|
|
|
|
// Fill list
|
|
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
|
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
|
{
|
|
// Skip any BOP items
|
|
if (itr->second.Bonding == BIND_WHEN_PICKED_UP)
|
|
continue;
|
|
|
|
// Restrict quality to anything under 7 (artifact and below) or are 0 (poor)
|
|
if (itr->second.Quality == 0 || itr->second.Quality > 6)
|
|
continue;
|
|
|
|
// Disabled items by Id
|
|
if (DisableItemStore.find(itr->second.ItemId) != DisableItemStore.end())
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (PTR/Beta/Unused Item)", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable conjured items
|
|
if (itr->second.IsConjuredConsumable())
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Conjured Consumable)", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable money
|
|
if (itr->second.Class == ITEM_CLASS_MONEY)
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Money)", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable moneyloot
|
|
if (itr->second.MinMoneyLoot > 0)
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (MoneyLoot)", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable items with duration
|
|
if (itr->second.Duration > 0)
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (Has a Duration)", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable items which are bind quest Items
|
|
if (itr->second.Bonding == BIND_QUEST_ITEM)
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled (BOP or BQI and Required Level is less than Item Level)", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable anything with the string literal of a testing or depricated item
|
|
if (itr->second.Name1.find("Test ") != std::string::npos ||
|
|
itr->second.Name1.find("Unused") != std::string::npos ||
|
|
itr->second.Name1.find("Deprecated") != std::string::npos ||
|
|
itr->second.Name1.find(" Epic ") != std::string::npos ||
|
|
itr->second.Name1.find("[PH]") != std::string::npos ||
|
|
itr->second.Name1.find("[DEP]") != std::string::npos ||
|
|
itr->second.Name1.find("TEST") != std::string::npos ||
|
|
itr->second.Name1.find("OLD") != std::string::npos)
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled item with a temp or unused item name", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable "other" consumables
|
|
if (itr->second.Class == ITEM_CLASS_CONSUMABLE && itr->second.SubClass == ITEM_SUBCLASS_CONSUMABLE_OTHER)
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled consumber 'other' item", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable All MISC items (pets, mounts, etc) Use Subclass _JUNK_() for pets and mounts
|
|
if (itr->second.Class == ITEM_CLASS_MISC)
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled misc item", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Disable all items that have neither a sell or a buy price
|
|
if (itr->second.SellPrice == 0 && itr->second.BuyPrice == 0)
|
|
{
|
|
if (debug_Out_Filters)
|
|
LOG_ERROR("module", "AuctionHouseBot: Item {} disabled misc item", itr->second.ItemId);
|
|
continue;
|
|
}
|
|
|
|
// Store the item ID
|
|
itemCandidates.push_back(itr->second.ItemId);
|
|
}
|
|
}
|
|
|
|
void AuctionHouseBot::addNewAuctions(Player *AHBplayer, AHBConfig *config)
|
|
{
|
|
if (!AHBSeller)
|
|
{
|
|
if (debug_Out)
|
|
LOG_INFO("module", "AHSeller: Disabled");
|
|
return;
|
|
}
|
|
|
|
uint32 minItems = config->GetMinItems();
|
|
uint32 maxItems = config->GetMaxItems();
|
|
|
|
if (maxItems == 0)
|
|
{
|
|
//if (debug_Out) sLog->outString( "AHSeller: Auctions disabled");
|
|
return;
|
|
}
|
|
|
|
AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAHFID());
|
|
if (!ahEntry)
|
|
{
|
|
return;
|
|
}
|
|
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
|
|
if (!auctionHouse)
|
|
{
|
|
return;
|
|
}
|
|
|
|
uint32 auctions = auctionHouse->Getcount();
|
|
|
|
uint32 items = 0;
|
|
|
|
if (auctions >= minItems)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHSeller: Auctions above minimum");
|
|
return;
|
|
}
|
|
|
|
if (auctions >= maxItems)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHSeller: Auctions at or above maximum");
|
|
return;
|
|
}
|
|
|
|
if ((maxItems - auctions) >= ItemsPerCycle)
|
|
items = ItemsPerCycle;
|
|
else
|
|
items = (maxItems - auctions);
|
|
|
|
if (debug_Out)
|
|
LOG_INFO("module", "AHSeller: Adding {} Auctions", items);
|
|
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHSeller: Current house id is {}", config->GetAHID());
|
|
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHSeller: {} items", items);
|
|
|
|
// only insert a few at a time, so as not to peg the processor
|
|
for (uint32 cnt = 1; cnt <= items; cnt++)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHSeller: {} count", cnt);
|
|
|
|
// Pull a random item out of the candidate list
|
|
uint32 itemID = itemCandidates[urand(0, itemCandidates.size() - 1)];
|
|
|
|
// Prevent invalid IDs
|
|
if (itemID == 0)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHSeller: Item::CreateItem() - ItemID is 0");
|
|
continue;
|
|
}
|
|
|
|
ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemID);
|
|
if (prototype == NULL)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHSeller: prototype == NULL");
|
|
continue;
|
|
}
|
|
|
|
Item* item = Item::CreateItem(itemID, 1, AHBplayer);
|
|
if (item == NULL)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHSeller: Item::CreateItem() returned NULL");
|
|
break;
|
|
}
|
|
item->AddToUpdateQueueOf(AHBplayer);
|
|
|
|
uint32 randomPropertyId = Item::GenerateItemRandomPropertyId(itemID);
|
|
if (randomPropertyId != 0)
|
|
item->SetItemRandomProperties(randomPropertyId);
|
|
|
|
// Determine price
|
|
uint64 buyoutPrice = 0;
|
|
uint64 bidPrice = 0;
|
|
calculateItemValue(prototype, bidPrice, buyoutPrice);
|
|
|
|
// Define a duration
|
|
uint32 etime = urand(1,3);
|
|
switch(etime)
|
|
{
|
|
case 1:
|
|
etime = 43200;
|
|
break;
|
|
case 2:
|
|
etime = 86400;
|
|
break;
|
|
case 3:
|
|
etime = 172800;
|
|
break;
|
|
default:
|
|
etime = 86400;
|
|
break;
|
|
}
|
|
|
|
// Set stack size
|
|
uint32 stackCount = getStackSizeForItem(prototype);
|
|
item->SetCount(stackCount);
|
|
|
|
uint32 dep = sAuctionMgr->GetAuctionDeposit(ahEntry, etime, item, stackCount);
|
|
|
|
auto trans = CharacterDatabase.BeginTransaction();
|
|
AuctionEntry* auctionEntry = new AuctionEntry();
|
|
auctionEntry->Id = sObjectMgr->GenerateAuctionID();
|
|
auctionEntry->houseId = config->GetAHID();
|
|
auctionEntry->item_guid = item->GetGUID();
|
|
auctionEntry->item_template = item->GetEntry();
|
|
auctionEntry->itemCount = item->GetCount();
|
|
auctionEntry->owner = AHBplayer->GetGUID();
|
|
auctionEntry->startbid = bidPrice * stackCount;
|
|
auctionEntry->buyout = buyoutPrice * stackCount;
|
|
auctionEntry->bid = 0;
|
|
auctionEntry->deposit = dep;
|
|
auctionEntry->expire_time = (time_t) etime + time(NULL);
|
|
auctionEntry->auctionHouseEntry = ahEntry;
|
|
item->SaveToDB(trans);
|
|
item->RemoveFromUpdateQueueOf(AHBplayer);
|
|
sAuctionMgr->AddAItem(item);
|
|
auctionHouse->AddAuction(auctionEntry);
|
|
auctionEntry->SaveToDB(trans);
|
|
CharacterDatabase.CommitTransaction(trans);
|
|
|
|
|
|
}
|
|
}
|
|
void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *config, WorldSession *session)
|
|
{
|
|
if (!AHBBuyer)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHBuyer: Disabled");
|
|
return;
|
|
}
|
|
|
|
QueryResult result = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE itemowner<>{} AND buyguid<>{}", AHBplayerGUID, AHBplayerGUID);
|
|
|
|
if (!result)
|
|
return;
|
|
|
|
if (result->GetRowCount() == 0)
|
|
return;
|
|
|
|
// Fetches content of selected AH
|
|
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
|
|
vector<uint32> possibleBids;
|
|
|
|
do
|
|
{
|
|
uint32 tmpdata = result->Fetch()->Get<uint32>();
|
|
possibleBids.push_back(tmpdata);
|
|
}while (result->NextRow());
|
|
|
|
for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count)
|
|
{
|
|
// Do we have anything to bid? If not, stop here.
|
|
if (possibleBids.empty())
|
|
{
|
|
//if (debug_Out) sLog->outError( "AHBuyer: I have no items to bid on.");
|
|
count = config->GetBidsPerInterval();
|
|
continue;
|
|
}
|
|
|
|
// Choose random auction from possible auctions
|
|
uint32 vectorPos = urand(0, possibleBids.size() - 1);
|
|
vector<uint32>::iterator iter = possibleBids.begin();
|
|
advance(iter, vectorPos);
|
|
|
|
// from auctionhousehandler.cpp, creates auction pointer & player pointer
|
|
AuctionEntry* auction = auctionHouse->GetAuction(*iter);
|
|
|
|
// Erase the auction from the vector to prevent bidding on item in next iteration.
|
|
possibleBids.erase(iter);
|
|
|
|
if (!auction)
|
|
continue;
|
|
|
|
// get exact item information
|
|
Item *pItem = sAuctionMgr->GetAItem(auction->item_guid);
|
|
if (!pItem)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "AHBuyer: Item {} doesn't exist, perhaps bought already?", auction->item_guid.ToString());
|
|
continue;
|
|
}
|
|
|
|
// get item prototype
|
|
ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(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;
|
|
|
|
// Prepare portion from maximum bid per item
|
|
double bidrate = static_cast<double>(urand(1, 100)) / 100;
|
|
uint64 discardBuyoutPrice = 0;
|
|
uint64 bidPriceMaxSingle = 0;
|
|
calculateItemValue(prototype, bidPriceMaxSingle, discardBuyoutPrice);
|
|
uint64 bitPriceMaxCurStack = bidPriceMaxSingle * pItem->GetCount();
|
|
|
|
// check some special items, and do recalculating to their prices
|
|
switch (prototype->Class)
|
|
{
|
|
// ammo
|
|
case 6:
|
|
bitPriceMaxCurStack = 0;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (bitPriceMaxCurStack == 0)
|
|
{
|
|
// quality check failed to get bidmax, let's get out of here
|
|
continue;
|
|
}
|
|
|
|
// Calculate our bid
|
|
long double bidvalue = currentprice + ((bitPriceMaxCurStack - currentprice) * bidrate);
|
|
// Convert to uint32
|
|
uint32 bidprice = static_cast<uint32>(bidvalue);
|
|
|
|
// Check our bid is high enough to be valid. If not, correct it to minimum.
|
|
if ((currentprice + auction->GetAuctionOutBid()) > bidprice)
|
|
bidprice = currentprice + auction->GetAuctionOutBid();
|
|
|
|
if (debug_Out)
|
|
{
|
|
LOG_INFO("module", "-------------------------------------------------");
|
|
LOG_INFO("module", "AHBuyer: Info for Auction #{}:", auction->Id);
|
|
LOG_INFO("module", "AHBuyer: AuctionHouse: {}", auction->GetHouseId());
|
|
LOG_INFO("module", "AHBuyer: Owner: {}", auction->owner.ToString());
|
|
LOG_INFO("module", "AHBuyer: Bidder: {}", auction->bidder.ToString());
|
|
LOG_INFO("module", "AHBuyer: Starting Bid: {}", auction->startbid);
|
|
LOG_INFO("module", "AHBuyer: Current Bid: {}", currentprice);
|
|
LOG_INFO("module", "AHBuyer: Buyout: {}", auction->buyout);
|
|
LOG_INFO("module", "AHBuyer: Deposit: {}", auction->deposit);
|
|
LOG_INFO("module", "AHBuyer: Expire Time: {}", uint32(auction->expire_time));
|
|
LOG_INFO("module", "AHBuyer: Bid Rate: {}", bidrate);
|
|
LOG_INFO("module", "AHBuyer: Bid Max: {}", bitPriceMaxCurStack);
|
|
LOG_INFO("module", "AHBuyer: Bid Value: {}", bidvalue);
|
|
LOG_INFO("module", "AHBuyer: Bid Price: {}", bidprice);
|
|
LOG_INFO("module", "AHBuyer: Item GUID: {}", auction->item_guid.ToString());
|
|
LOG_INFO("module", "AHBuyer: Item Template: {}", auction->item_template);
|
|
LOG_INFO("module", "AHBuyer: Item Info:");
|
|
LOG_INFO("module", "AHBuyer: Item ID: {}", prototype->ItemId);
|
|
LOG_INFO("module", "AHBuyer: Buy Price: {}", prototype->BuyPrice);
|
|
LOG_INFO("module", "AHBuyer: Sell Price: {}", prototype->SellPrice);
|
|
LOG_INFO("module", "AHBuyer: Bonding: {}", prototype->Bonding);
|
|
LOG_INFO("module", "AHBuyer: Quality: {}", prototype->Quality);
|
|
LOG_INFO("module", "AHBuyer: Item Level: {}", prototype->ItemLevel);
|
|
LOG_INFO("module", "AHBuyer: Ammo Type: {}", prototype->AmmoType);
|
|
LOG_INFO("module", "-------------------------------------------------");
|
|
}
|
|
|
|
// Check whether we do normal bid, or buyout
|
|
if ((bidprice < auction->buyout) || (auction->buyout == 0))
|
|
{
|
|
if (auction->bidder)
|
|
{
|
|
if (auction->bidder == AHBplayer->GetGUID())
|
|
{
|
|
//pl->ModifyMoney(-int32(price - auction->bid));
|
|
}
|
|
else
|
|
{
|
|
// mail to last bidder and return money
|
|
auto trans = CharacterDatabase.BeginTransaction();
|
|
sAuctionMgr->SendAuctionOutbiddedMail(auction, bidprice, session->GetPlayer(), trans);
|
|
CharacterDatabase.CommitTransaction(trans);
|
|
//pl->ModifyMoney(-int32(price));
|
|
}
|
|
}
|
|
|
|
auction->bidder = AHBplayer->GetGUID();
|
|
auction->bid = bidprice;
|
|
|
|
// Saving auction into database
|
|
CharacterDatabase.Execute("UPDATE auctionhouse SET buyguid = '{}',lastbid = '{}' WHERE id = '{}'", auction->bidder.GetCounter(), auction->bid, auction->Id);
|
|
}
|
|
else
|
|
{
|
|
auto trans = CharacterDatabase.BeginTransaction();
|
|
//buyout
|
|
if ((auction->bidder) && (AHBplayer->GetGUID() != auction->bidder))
|
|
{
|
|
sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, session->GetPlayer(), trans);
|
|
}
|
|
auction->bidder = AHBplayer->GetGUID();
|
|
auction->bid = auction->buyout;
|
|
|
|
// Send mails to buyer & seller
|
|
//sAuctionMgr->SendAuctionSalePendingMail(auction, trans);
|
|
sAuctionMgr->SendAuctionSuccessfulMail(auction, trans);
|
|
sAuctionMgr->SendAuctionWonMail(auction, trans);
|
|
auction->DeleteFromDB(trans);
|
|
|
|
sAuctionMgr->RemoveAItem(auction->item_guid);
|
|
auctionHouse->RemoveAuction(auction);
|
|
CharacterDatabase.CommitTransaction(trans);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AuctionHouseBot::Update()
|
|
{
|
|
time_t _newrun = time(NULL);
|
|
if ((!AHBSeller) && (!AHBBuyer))
|
|
return;
|
|
|
|
std::string accountName = "AuctionHouseBot" + std::to_string(AHBplayerAccount);
|
|
|
|
WorldSession _session(AHBplayerAccount, std::move(accountName), nullptr, SEC_PLAYER, sWorld->getIntConfig(CONFIG_EXPANSION), 0, LOCALE_enUS, 0, false, false, 0);
|
|
Player _AHBplayer(&_session);
|
|
_AHBplayer.Initialize(AHBplayerGUID);
|
|
ObjectAccessor::AddObject(&_AHBplayer);
|
|
|
|
// Add New Bids
|
|
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
|
{
|
|
addNewAuctions(&_AHBplayer, &AllianceConfig);
|
|
if (((_newrun - _lastrun_a) >= (AllianceConfig.GetBiddingInterval() * MINUTE)) && (AllianceConfig.GetBidsPerInterval() > 0))
|
|
{
|
|
//if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_a));
|
|
//if (debug_Out) sLog->outError( "AHBuyer: Bidding on Alliance Auctions");
|
|
addNewAuctionBuyerBotBid(&_AHBplayer, &AllianceConfig, &_session);
|
|
_lastrun_a = _newrun;
|
|
}
|
|
|
|
addNewAuctions(&_AHBplayer, &HordeConfig);
|
|
if (((_newrun - _lastrun_h) >= (HordeConfig.GetBiddingInterval() * MINUTE)) && (HordeConfig.GetBidsPerInterval() > 0))
|
|
{
|
|
//if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_h));
|
|
//if (debug_Out) sLog->outError( "AHBuyer: Bidding on Horde Auctions");
|
|
addNewAuctionBuyerBotBid(&_AHBplayer, &HordeConfig, &_session);
|
|
_lastrun_h = _newrun;
|
|
}
|
|
}
|
|
|
|
addNewAuctions(&_AHBplayer, &NeutralConfig);
|
|
if (((_newrun - _lastrun_n) >= (NeutralConfig.GetBiddingInterval() * MINUTE)) && (NeutralConfig.GetBidsPerInterval() > 0))
|
|
{
|
|
//if (debug_Out) sLog->outError( "AHBuyer: %u seconds have passed since last bid", (_newrun - _lastrun_n));
|
|
//if (debug_Out) sLog->outError( "AHBuyer: Bidding on Neutral Auctions");
|
|
addNewAuctionBuyerBotBid(&_AHBplayer, &NeutralConfig, &_session);
|
|
_lastrun_n = _newrun;
|
|
}
|
|
ObjectAccessor::RemoveObject(&_AHBplayer);
|
|
}
|
|
|
|
void AuctionHouseBot::Initialize()
|
|
{
|
|
DisableItemStore.clear();
|
|
QueryResult result = WorldDatabase.Query("SELECT item FROM mod_auctionhousebot_disabled_items");
|
|
|
|
if (result)
|
|
{
|
|
do
|
|
{
|
|
Field* fields = result->Fetch();
|
|
DisableItemStore.insert(fields[0].Get<uint32>());
|
|
} while (result->NextRow());
|
|
}
|
|
|
|
//End Filters
|
|
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
|
{
|
|
LoadValues(&AllianceConfig);
|
|
LoadValues(&HordeConfig);
|
|
}
|
|
LoadValues(&NeutralConfig);
|
|
|
|
//
|
|
// check if the AHBot account/GUID in the config actually exists
|
|
//
|
|
|
|
if ((AHBplayerAccount != 0) || (AHBplayerGUID != 0))
|
|
{
|
|
QueryResult result = CharacterDatabase.Query("SELECT 1 FROM characters WHERE account = {} AND guid = {}", AHBplayerAccount, AHBplayerGUID);
|
|
if (!result)
|
|
{
|
|
LOG_ERROR("module", "AuctionHouseBot: The account/GUID-information set for your AHBot is incorrect (account: {} guid: {})", AHBplayerAccount, AHBplayerGUID);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (AHBSeller)
|
|
{
|
|
// Build a list of items that can be pulled from for auction
|
|
populateItemCandidateList();
|
|
|
|
LOG_INFO("module", "AuctionHouseBot:");
|
|
LOG_INFO("module", "{} disabled items", uint32(DisableItemStore.size()));
|
|
}
|
|
|
|
LOG_INFO("module", "AuctionHouseBot and AuctionHouseBuyer have been loaded.");
|
|
}
|
|
|
|
void AuctionHouseBot::InitializeConfiguration()
|
|
{
|
|
debug_Out = sConfigMgr->GetOption<bool>("AuctionHouseBot.DEBUG", false);
|
|
debug_Out_Filters = sConfigMgr->GetOption<bool>("AuctionHouseBot.DEBUG_FILTERS", false);
|
|
|
|
AHBSeller = sConfigMgr->GetOption<bool>("AuctionHouseBot.EnableSeller", false);
|
|
AHBBuyer = sConfigMgr->GetOption<bool>("AuctionHouseBot.EnableBuyer", false);
|
|
SellMethod = sConfigMgr->GetOption<bool>("AuctionHouseBot.UseBuyPriceForSeller", false);
|
|
BuyMethod = sConfigMgr->GetOption<bool>("AuctionHouseBot.UseBuyPriceForBuyer", false);
|
|
|
|
AHBplayerAccount = sConfigMgr->GetOption<uint32>("AuctionHouseBot.Account", 0);
|
|
AHBplayerGUID = sConfigMgr->GetOption<uint32>("AuctionHouseBot.GUID", 0);
|
|
ItemsPerCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.ItemsPerCycle", 200);
|
|
}
|
|
|
|
void AuctionHouseBot::Commands(uint32 command, uint32 ahMapID, uint32 col, char* args)
|
|
{
|
|
AHBConfig *config = NULL;
|
|
switch (ahMapID)
|
|
{
|
|
case 2:
|
|
config = &AllianceConfig;
|
|
break;
|
|
case 6:
|
|
config = &HordeConfig;
|
|
break;
|
|
case 7:
|
|
config = &NeutralConfig;
|
|
break;
|
|
}
|
|
std::string color;
|
|
switch (col)
|
|
{
|
|
case AHB_GREY:
|
|
color = "grey";
|
|
break;
|
|
case AHB_WHITE:
|
|
color = "white";
|
|
break;
|
|
case AHB_GREEN:
|
|
color = "green";
|
|
break;
|
|
case AHB_BLUE:
|
|
color = "blue";
|
|
break;
|
|
case AHB_PURPLE:
|
|
color = "purple";
|
|
break;
|
|
case AHB_ORANGE:
|
|
color = "orange";
|
|
break;
|
|
case AHB_YELLOW:
|
|
color = "yellow";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
switch (command)
|
|
{
|
|
case 0: //ahexpire
|
|
{
|
|
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
|
|
|
|
AuctionHouseObject::AuctionEntryMap::iterator itr;
|
|
itr = auctionHouse->GetAuctionsBegin();
|
|
|
|
while (itr != auctionHouse->GetAuctionsEnd())
|
|
{
|
|
if (itr->second->owner.GetCounter() == AHBplayerGUID)
|
|
{
|
|
itr->second->expire_time = GameTime::GetGameTime().count();
|
|
uint32 id = itr->second->Id;
|
|
uint32 expire_time = itr->second->expire_time;
|
|
CharacterDatabase.Execute("UPDATE auctionhouse SET time = '{}' WHERE id = '{}'", expire_time, id);
|
|
}
|
|
++itr;
|
|
}
|
|
}
|
|
break;
|
|
case 1: //min items
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 minItems = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET minitems = '{}' WHERE auctionhouse = '{}'", minItems, ahMapID);
|
|
config->SetMinItems(minItems);
|
|
}
|
|
break;
|
|
case 2: //max items
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 maxItems = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxitems = '{}' WHERE auctionhouse = '{}'", maxItems, ahMapID);
|
|
config->SetMaxItems(maxItems);
|
|
}
|
|
break;
|
|
case 3: //min time Deprecated (Place holder for future commands)
|
|
break;
|
|
case 4: //max time Deprecated (Place holder for future commands)
|
|
break;
|
|
case 5: //percentages
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
char * param2 = strtok(NULL, " ");
|
|
char * param3 = strtok(NULL, " ");
|
|
char * param4 = strtok(NULL, " ");
|
|
char * param5 = strtok(NULL, " ");
|
|
char * param6 = strtok(NULL, " ");
|
|
char * param7 = strtok(NULL, " ");
|
|
char * param8 = strtok(NULL, " ");
|
|
char * param9 = strtok(NULL, " ");
|
|
char * param10 = strtok(NULL, " ");
|
|
char * param11 = strtok(NULL, " ");
|
|
char * param12 = strtok(NULL, " ");
|
|
char * param13 = strtok(NULL, " ");
|
|
char * param14 = strtok(NULL, " ");
|
|
uint32 greytg = (uint32) strtoul(param1, NULL, 0);
|
|
uint32 whitetg = (uint32) strtoul(param2, NULL, 0);
|
|
uint32 greentg = (uint32) strtoul(param3, NULL, 0);
|
|
uint32 bluetg = (uint32) strtoul(param4, NULL, 0);
|
|
uint32 purpletg = (uint32) strtoul(param5, NULL, 0);
|
|
uint32 orangetg = (uint32) strtoul(param6, NULL, 0);
|
|
uint32 yellowtg = (uint32) strtoul(param7, NULL, 0);
|
|
uint32 greyi = (uint32) strtoul(param8, NULL, 0);
|
|
uint32 whitei = (uint32) strtoul(param9, NULL, 0);
|
|
uint32 greeni = (uint32) strtoul(param10, NULL, 0);
|
|
uint32 bluei = (uint32) strtoul(param11, NULL, 0);
|
|
uint32 purplei = (uint32) strtoul(param12, NULL, 0);
|
|
uint32 orangei = (uint32) strtoul(param13, NULL, 0);
|
|
uint32 yellowi = (uint32) strtoul(param14, NULL, 0);
|
|
|
|
auto trans = WorldDatabase.BeginTransaction();
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentgreytradegoods = '{}' WHERE auctionhouse = '{}'", greytg, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentwhitetradegoods = '{}' WHERE auctionhouse = '{}'", whitetg, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentgreentradegoods = '{}' WHERE auctionhouse = '{}'", greentg, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentbluetradegoods = '{}' WHERE auctionhouse = '{}'", bluetg, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentpurpletradegoods = '{}' WHERE auctionhouse = '{}'", purpletg, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentorangetradegoods = '{}' WHERE auctionhouse = '{}'", orangetg, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentyellowtradegoods = '{}' WHERE auctionhouse = '{}'", yellowtg, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentgreyitems = '{}' WHERE auctionhouse = '{}'", greyi, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentwhiteitems = '{}' WHERE auctionhouse = '{}'", whitei, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentgreenitems = '{}' WHERE auctionhouse = '{}'", greeni, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentblueitems = '{}' WHERE auctionhouse = '{}'", bluei, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentpurpleitems = '{}' WHERE auctionhouse = '{}'", purplei, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentorangeitems = '{}' WHERE auctionhouse = '{}'", orangei, ahMapID);
|
|
trans->Append("UPDATE mod_auctionhousebot SET percentyellowitems = '{}' WHERE auctionhouse = '{}'", yellowi, ahMapID);
|
|
WorldDatabase.CommitTransaction(trans);
|
|
}
|
|
break;
|
|
case 6: //min prices
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 minPrice = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET minprice{} = '{}' WHERE auctionhouse = '{}'", color, minPrice, ahMapID);
|
|
config->SetMinPrice(col, minPrice);
|
|
}
|
|
break;
|
|
case 7: //max prices
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 maxPrice = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxprice{} = '{}' WHERE auctionhouse = '{}'", color, maxPrice, ahMapID);
|
|
config->SetMaxPrice(col, maxPrice);
|
|
}
|
|
break;
|
|
case 8: //min bid price
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 minBidPrice = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET minbidprice{} = '{}' WHERE auctionhouse = '{}'", color, minBidPrice, ahMapID);
|
|
config->SetMinBidPrice(col, minBidPrice);
|
|
}
|
|
break;
|
|
case 9: //max bid price
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 maxBidPrice = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxbidprice{} = '{}' WHERE auctionhouse = '{}'", color, maxBidPrice, ahMapID);
|
|
config->SetMaxBidPrice(col, maxBidPrice);
|
|
}
|
|
break;
|
|
case 10: //max stacks
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 maxStack = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET maxstack{} = '{}' WHERE auctionhouse = '{}'", color, maxStack, ahMapID);
|
|
config->SetMaxStack(col, maxStack);
|
|
}
|
|
break;
|
|
case 11: //buyer bid prices
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 buyerPrice = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET buyerprice{} = '{}' WHERE auctionhouse = '{}'", color, buyerPrice, ahMapID);
|
|
config->SetBuyerPrice(col, buyerPrice);
|
|
}
|
|
break;
|
|
case 12: //buyer bidding interval
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 bidInterval = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET buyerbiddinginterval = '{}' WHERE auctionhouse = '{}'", bidInterval, ahMapID);
|
|
config->SetBiddingInterval(bidInterval);
|
|
}
|
|
break;
|
|
case 13: //buyer bids per interval
|
|
{
|
|
char * param1 = strtok(args, " ");
|
|
uint32 bidsPerInterval = (uint32) strtoul(param1, NULL, 0);
|
|
WorldDatabase.Execute("UPDATE mod_auctionhousebot SET buyerbidsperinterval = '{}' WHERE auctionhouse = '{}'", bidsPerInterval, ahMapID);
|
|
config->SetBidsPerInterval(bidsPerInterval);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void AuctionHouseBot::LoadValues(AHBConfig *config)
|
|
{
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "Start Settings for {} Auctionhouses:", WorldDatabase.Query("SELECT name FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<std::string_view>());
|
|
|
|
if (AHBSeller)
|
|
{
|
|
//load min and max items
|
|
config->SetMinItems(WorldDatabase.Query("SELECT minitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxItems(WorldDatabase.Query("SELECT maxitems FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
//load min and max prices
|
|
config->SetMinPrice(AHB_GREY, WorldDatabase.Query("SELECT minpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxPrice(AHB_GREY, WorldDatabase.Query("SELECT maxpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinPrice(AHB_WHITE, WorldDatabase.Query("SELECT minpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxPrice(AHB_WHITE, WorldDatabase.Query("SELECT maxpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinPrice(AHB_GREEN, WorldDatabase.Query("SELECT minpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxPrice(AHB_GREEN, WorldDatabase.Query("SELECT maxpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinPrice(AHB_BLUE, WorldDatabase.Query("SELECT minpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxPrice(AHB_BLUE, WorldDatabase.Query("SELECT maxpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinPrice(AHB_PURPLE, WorldDatabase.Query("SELECT minpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxPrice(AHB_PURPLE, WorldDatabase.Query("SELECT maxpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinPrice(AHB_ORANGE, WorldDatabase.Query("SELECT minpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxPrice(AHB_ORANGE, WorldDatabase.Query("SELECT maxpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinPrice(AHB_YELLOW, WorldDatabase.Query("SELECT minpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxPrice(AHB_YELLOW, WorldDatabase.Query("SELECT maxpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
//load min and max bid prices
|
|
config->SetMinBidPrice(AHB_GREY, WorldDatabase.Query("SELECT minbidpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxBidPrice(AHB_GREY, WorldDatabase.Query("SELECT maxbidpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinBidPrice(AHB_WHITE, WorldDatabase.Query("SELECT minbidpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxBidPrice(AHB_WHITE, WorldDatabase.Query("SELECT maxbidpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinBidPrice(AHB_GREEN, WorldDatabase.Query("SELECT minbidpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxBidPrice(AHB_GREEN, WorldDatabase.Query("SELECT maxbidpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinBidPrice(AHB_BLUE, WorldDatabase.Query("SELECT minbidpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxBidPrice(AHB_BLUE, WorldDatabase.Query("SELECT maxbidpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinBidPrice(AHB_PURPLE, WorldDatabase.Query("SELECT minbidpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxBidPrice(AHB_PURPLE, WorldDatabase.Query("SELECT maxbidpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinBidPrice(AHB_ORANGE, WorldDatabase.Query("SELECT minbidpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxBidPrice(AHB_ORANGE, WorldDatabase.Query("SELECT maxbidpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMinBidPrice(AHB_YELLOW, WorldDatabase.Query("SELECT minbidpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxBidPrice(AHB_YELLOW, WorldDatabase.Query("SELECT maxbidpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
//load max stacks
|
|
config->SetMaxStack(AHB_GREY, WorldDatabase.Query("SELECT maxstackgrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxStack(AHB_WHITE, WorldDatabase.Query("SELECT maxstackwhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxStack(AHB_GREEN, WorldDatabase.Query("SELECT maxstackgreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxStack(AHB_BLUE, WorldDatabase.Query("SELECT maxstackblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxStack(AHB_PURPLE, WorldDatabase.Query("SELECT maxstackpurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxStack(AHB_ORANGE, WorldDatabase.Query("SELECT maxstackorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetMaxStack(AHB_YELLOW, WorldDatabase.Query("SELECT maxstackyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
if (debug_Out)
|
|
{
|
|
LOG_ERROR("module", "minItems = {}", config->GetMinItems());
|
|
LOG_ERROR("module", "maxItems = {}", config->GetMaxItems());
|
|
LOG_ERROR("module", "minPriceGrey = {}", config->GetMinPrice(AHB_GREY));
|
|
LOG_ERROR("module", "maxPriceGrey = {}", config->GetMaxPrice(AHB_GREY));
|
|
LOG_ERROR("module", "minPriceWhite = {}", config->GetMinPrice(AHB_WHITE));
|
|
LOG_ERROR("module", "maxPriceWhite = {}", config->GetMaxPrice(AHB_WHITE));
|
|
LOG_ERROR("module", "minPriceGreen = {}", config->GetMinPrice(AHB_GREEN));
|
|
LOG_ERROR("module", "maxPriceGreen = {}", config->GetMaxPrice(AHB_GREEN));
|
|
LOG_ERROR("module", "minPriceBlue = {}", config->GetMinPrice(AHB_BLUE));
|
|
LOG_ERROR("module", "maxPriceBlue = {}", config->GetMaxPrice(AHB_BLUE));
|
|
LOG_ERROR("module", "minPricePurple = {}", config->GetMinPrice(AHB_PURPLE));
|
|
LOG_ERROR("module", "maxPricePurple = {}", config->GetMaxPrice(AHB_PURPLE));
|
|
LOG_ERROR("module", "minPriceOrange = {}", config->GetMinPrice(AHB_ORANGE));
|
|
LOG_ERROR("module", "maxPriceOrange = {}", config->GetMaxPrice(AHB_ORANGE));
|
|
LOG_ERROR("module", "minPriceYellow = {}", config->GetMinPrice(AHB_YELLOW));
|
|
LOG_ERROR("module", "maxPriceYellow = {}", config->GetMaxPrice(AHB_YELLOW));
|
|
LOG_ERROR("module", "minBidPriceGrey = {}", config->GetMinBidPrice(AHB_GREY));
|
|
LOG_ERROR("module", "maxBidPriceGrey = {}", config->GetMaxBidPrice(AHB_GREY));
|
|
LOG_ERROR("module", "minBidPriceWhite = {}", config->GetMinBidPrice(AHB_WHITE));
|
|
LOG_ERROR("module", "maxBidPriceWhite = {}", config->GetMaxBidPrice(AHB_WHITE));
|
|
LOG_ERROR("module", "minBidPriceGreen = {}", config->GetMinBidPrice(AHB_GREEN));
|
|
LOG_ERROR("module", "maxBidPriceGreen = {}", config->GetMaxBidPrice(AHB_GREEN));
|
|
LOG_ERROR("module", "minBidPriceBlue = {}", config->GetMinBidPrice(AHB_BLUE));
|
|
LOG_ERROR("module", "maxBidPriceBlue = {}", config->GetMinBidPrice(AHB_BLUE));
|
|
LOG_ERROR("module", "minBidPricePurple = {}", config->GetMinBidPrice(AHB_PURPLE));
|
|
LOG_ERROR("module", "maxBidPricePurple = {}", config->GetMaxBidPrice(AHB_PURPLE));
|
|
LOG_ERROR("module", "minBidPriceOrange = {}", config->GetMinBidPrice(AHB_ORANGE));
|
|
LOG_ERROR("module", "maxBidPriceOrange = {}", config->GetMaxBidPrice(AHB_ORANGE));
|
|
LOG_ERROR("module", "minBidPriceYellow = {}", config->GetMinBidPrice(AHB_YELLOW));
|
|
LOG_ERROR("module", "maxBidPriceYellow = {}", config->GetMaxBidPrice(AHB_YELLOW));
|
|
LOG_ERROR("module", "maxStackGrey = {}", config->GetMaxStack(AHB_GREY));
|
|
LOG_ERROR("module", "maxStackWhite = {}", config->GetMaxStack(AHB_WHITE));
|
|
LOG_ERROR("module", "maxStackGreen = {}", config->GetMaxStack(AHB_GREEN));
|
|
LOG_ERROR("module", "maxStackBlue = {}", config->GetMaxStack(AHB_BLUE));
|
|
LOG_ERROR("module", "maxStackPurple = {}", config->GetMaxStack(AHB_PURPLE));
|
|
LOG_ERROR("module", "maxStackOrange = {}", config->GetMaxStack(AHB_ORANGE));
|
|
LOG_ERROR("module", "maxStackYellow = {}", config->GetMaxStack(AHB_YELLOW));
|
|
}
|
|
|
|
//AuctionHouseEntry const* ahEntry = sAuctionMgr->GetAuctionHouseEntry(config->GetAHFID());
|
|
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config->GetAHFID());
|
|
}
|
|
|
|
if (AHBBuyer)
|
|
{
|
|
//load buyer bid prices
|
|
config->SetBuyerPrice(AHB_GREY, WorldDatabase.Query("SELECT buyerpricegrey FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetBuyerPrice(AHB_WHITE, WorldDatabase.Query("SELECT buyerpricewhite FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetBuyerPrice(AHB_GREEN, WorldDatabase.Query("SELECT buyerpricegreen FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetBuyerPrice(AHB_BLUE, WorldDatabase.Query("SELECT buyerpriceblue FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetBuyerPrice(AHB_PURPLE, WorldDatabase.Query("SELECT buyerpricepurple FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetBuyerPrice(AHB_ORANGE, WorldDatabase.Query("SELECT buyerpriceorange FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
config->SetBuyerPrice(AHB_YELLOW, WorldDatabase.Query("SELECT buyerpriceyellow FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
//load bidding interval
|
|
config->SetBiddingInterval(WorldDatabase.Query("SELECT buyerbiddinginterval FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
//load bids per interval
|
|
config->SetBidsPerInterval(WorldDatabase.Query("SELECT buyerbidsperinterval FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<uint32>());
|
|
if (debug_Out)
|
|
{
|
|
LOG_ERROR("module", "buyerPriceGrey = {}", config->GetBuyerPrice(AHB_GREY));
|
|
LOG_ERROR("module", "buyerPriceWhite = {}", config->GetBuyerPrice(AHB_WHITE));
|
|
LOG_ERROR("module", "buyerPriceGreen = {}", config->GetBuyerPrice(AHB_GREEN));
|
|
LOG_ERROR("module", "buyerPriceBlue = {}", config->GetBuyerPrice(AHB_BLUE));
|
|
LOG_ERROR("module", "buyerPricePurple = {}", config->GetBuyerPrice(AHB_PURPLE));
|
|
LOG_ERROR("module", "buyerPriceOrange = {}", config->GetBuyerPrice(AHB_ORANGE));
|
|
LOG_ERROR("module", "buyerPriceYellow = {}", config->GetBuyerPrice(AHB_YELLOW));
|
|
LOG_ERROR("module", "buyerBiddingInterval = {}", config->GetBiddingInterval());
|
|
LOG_ERROR("module", "buyerBidsPerInterval = {}", config->GetBidsPerInterval());
|
|
}
|
|
}
|
|
|
|
if (debug_Out)
|
|
LOG_ERROR("module", "End Settings for {} Auctionhouses:", WorldDatabase.Query("SELECT name FROM mod_auctionhousebot WHERE auctionhouse = {}", config->GetAHID())->Fetch()->Get<std::string>());
|
|
}
|