mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-27 23:56:27 +00:00
added config to remove dangling expired/emptied auctions
This commit is contained in:
@@ -39,6 +39,13 @@
|
|||||||
# Enable/Disable the part of AHBot that puts items up for auction
|
# Enable/Disable the part of AHBot that puts items up for auction
|
||||||
# Default: false (disabled)
|
# Default: false (disabled)
|
||||||
#
|
#
|
||||||
|
# AuctionHouseBot.ReturnExpiredAuctionItemsToBot
|
||||||
|
# If enabled (true), returns expired auction items to the AH Bot(s) via
|
||||||
|
# mail. Note: if enabled, this can cause your bot's mailbox to fill up
|
||||||
|
# if you don't manage it manually. This can also cause the size of your
|
||||||
|
# acore_characters.item_instance database table to grow over time.
|
||||||
|
# Default: false (disabled)
|
||||||
|
#
|
||||||
# AuctionHouseBot.GUIDs
|
# AuctionHouseBot.GUIDs
|
||||||
# These are the character GUIDS (from characters->characters table) that
|
# These are the character GUIDS (from characters->characters table) that
|
||||||
# will be used to create auctions and otherwise interact with auctions.
|
# will be used to create auctions and otherwise interact with auctions.
|
||||||
@@ -68,6 +75,7 @@ AuctionHouseBot.DEBUG_FILTERS = false
|
|||||||
AuctionHouseBot.MinutesBetweenBuyCycle = 1
|
AuctionHouseBot.MinutesBetweenBuyCycle = 1
|
||||||
AuctionHouseBot.MinutesBetweenSellCycle = 1
|
AuctionHouseBot.MinutesBetweenSellCycle = 1
|
||||||
AuctionHouseBot.EnableSeller = false
|
AuctionHouseBot.EnableSeller = false
|
||||||
|
AuctionHouseBot.ReturnExpiredAuctionItemsToBot = false
|
||||||
AuctionHouseBot.GUIDs = 0
|
AuctionHouseBot.GUIDs = 0
|
||||||
AuctionHouseBot.ItemsPerCycle = 150
|
AuctionHouseBot.ItemsPerCycle = 150
|
||||||
AuctionHouseBot.ListingExpireTimeInSecondsMin = 900
|
AuctionHouseBot.ListingExpireTimeInSecondsMin = 900
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ AuctionHouseBot::AuctionHouseBot() :
|
|||||||
debug_Out_Filters(false),
|
debug_Out_Filters(false),
|
||||||
SellingBotEnabled(false),
|
SellingBotEnabled(false),
|
||||||
BuyingBotEnabled(false),
|
BuyingBotEnabled(false),
|
||||||
|
ReturnExpiredAuctionItemsToBot(false),
|
||||||
CyclesBetweenBuyActionMin(1),
|
CyclesBetweenBuyActionMin(1),
|
||||||
CyclesBetweenBuyAction(1),
|
CyclesBetweenBuyAction(1),
|
||||||
CyclesBetweenBuyActionMax(1),
|
CyclesBetweenBuyActionMax(1),
|
||||||
@@ -1266,11 +1267,14 @@ void AuctionHouseBot::AddNewAuctionBuyerBotBid(std::vector<Player*> AHBPlayers,
|
|||||||
|
|
||||||
void AuctionHouseBot::Update()
|
void AuctionHouseBot::Update()
|
||||||
{
|
{
|
||||||
if ((SellingBotEnabled == false) && (BuyingBotEnabled == false))
|
|
||||||
return;
|
|
||||||
if (AHCharacters.empty() == true)
|
if (AHCharacters.empty() == true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CleanupExpiredAuctionItems();
|
||||||
|
|
||||||
|
if ((SellingBotEnabled == false) && (BuyingBotEnabled == false))
|
||||||
|
return;
|
||||||
|
|
||||||
LastBuyCycleCount++;
|
LastBuyCycleCount++;
|
||||||
LastSellCycleCount++;
|
LastSellCycleCount++;
|
||||||
|
|
||||||
@@ -1369,6 +1373,7 @@ void AuctionHouseBot::InitializeConfiguration()
|
|||||||
|
|
||||||
// Buyer & Seller core properties
|
// Buyer & Seller core properties
|
||||||
SetCyclesBetweenBuyOrSell();
|
SetCyclesBetweenBuyOrSell();
|
||||||
|
ReturnExpiredAuctionItemsToBot = sConfigMgr->GetOption<bool>("AuctionHouseBot.ReturnExpiredAuctionItemsToBot", false);
|
||||||
ItemsPerCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.ItemsPerCycle", 75);
|
ItemsPerCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.ItemsPerCycle", 75);
|
||||||
MaxBuyoutPriceInCopper = sConfigMgr->GetOption<uint32>("AuctionHouseBot.MaxBuyoutPriceInCopper", 1000000000);
|
MaxBuyoutPriceInCopper = sConfigMgr->GetOption<uint32>("AuctionHouseBot.MaxBuyoutPriceInCopper", 1000000000);
|
||||||
BuyoutVariationReducePercent = sConfigMgr->GetOption<float>("AuctionHouseBot.BuyoutVariationReducePercent", 0.15f);
|
BuyoutVariationReducePercent = sConfigMgr->GetOption<float>("AuctionHouseBot.BuyoutVariationReducePercent", 0.15f);
|
||||||
@@ -1645,6 +1650,10 @@ void AuctionHouseBot::EmptyAuctionHouses()
|
|||||||
auction->DeleteFromDB(trans);
|
auction->DeleteFromDB(trans);
|
||||||
sAuctionMgr->RemoveAItem(auction->item_guid);
|
sAuctionMgr->RemoveAItem(auction->item_guid);
|
||||||
auctionHouse->RemoveAuction(auction);
|
auctionHouse->RemoveAuction(auction);
|
||||||
|
|
||||||
|
// If we don't need to return the item to AHBot, delete it
|
||||||
|
if (!ReturnExpiredAuctionItemsToBot)
|
||||||
|
Item::DeleteFromDB(trans, auction->item_guid.GetCounter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1937,3 +1946,33 @@ void AuctionHouseBot::PopulateVendorItemsPrices()
|
|||||||
} while (result->NextRow());
|
} while (result->NextRow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuctionHouseBot::CleanupExpiredAuctionItems()
|
||||||
|
{
|
||||||
|
if (AHCharactersGUIDsForQuery.empty() ||
|
||||||
|
ReturnExpiredAuctionItemsToBot)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Delete item_instances that are not in the Auction Houses
|
||||||
|
std::string queryItemInstancesString = R"SQL(
|
||||||
|
SELECT guid
|
||||||
|
FROM item_instance
|
||||||
|
LEFT JOIN auctionhouse ON auctionhouse.itemguid = item_instance.guid
|
||||||
|
WHERE item_instance.owner_guid IN ({})
|
||||||
|
AND auctionhouse.id IS NULL
|
||||||
|
)SQL";
|
||||||
|
|
||||||
|
QueryResult queryItemInstancesResult = CharacterDatabase.Query(queryItemInstancesString, AHCharactersGUIDsForQuery);
|
||||||
|
if (!queryItemInstancesResult)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
uint32 guid = queryItemInstancesResult->Fetch()[0].Get<uint32>();
|
||||||
|
Item::DeleteFromDB(trans, guid);
|
||||||
|
} while (queryItemInstancesResult->NextRow());
|
||||||
|
|
||||||
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
|
}
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ private:
|
|||||||
|
|
||||||
bool SellingBotEnabled;
|
bool SellingBotEnabled;
|
||||||
bool BuyingBotEnabled;
|
bool BuyingBotEnabled;
|
||||||
|
bool ReturnExpiredAuctionItemsToBot;
|
||||||
uint32 CyclesBetweenBuyActionMin;
|
uint32 CyclesBetweenBuyActionMin;
|
||||||
uint32 CyclesBetweenBuyAction;
|
uint32 CyclesBetweenBuyAction;
|
||||||
uint32 CyclesBetweenBuyActionMax;
|
uint32 CyclesBetweenBuyActionMax;
|
||||||
@@ -322,6 +323,7 @@ public:
|
|||||||
void AddNewAuctions(std::vector<Player*> AHBPlayers, FactionSpecificAuctionHouseConfig* config);
|
void AddNewAuctions(std::vector<Player*> AHBPlayers, FactionSpecificAuctionHouseConfig* config);
|
||||||
void AddNewAuctionBuyerBotBid(std::vector<Player*> AHBPlayers, FactionSpecificAuctionHouseConfig* config);
|
void AddNewAuctionBuyerBotBid(std::vector<Player*> AHBPlayers, FactionSpecificAuctionHouseConfig* config);
|
||||||
void PopulateVendorItemsPrices();
|
void PopulateVendorItemsPrices();
|
||||||
|
void CleanupExpiredAuctionItems();
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
void AddItemValuePairsToItemIDMap(std::unordered_map<uint32, ValueType>& workingValueToItemIDMap, std::string valueToItemIDMap);
|
void AddItemValuePairsToItemIDMap(std::unordered_map<uint32, ValueType>& workingValueToItemIDMap, std::string valueToItemIDMap);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnBeforeAuctionHouseMgrSendAuctionExpiredMail(AuctionHouseMgr* /*auctionHouseMgr*/, AuctionEntry* /*auction*/, Player* owner, uint32& /*owner_accId*/, bool& sendNotification, bool& /*sendMail*/) override
|
void OnBeforeAuctionHouseMgrSendAuctionExpiredMail(AuctionHouseMgr* /*auctionHouseMgr*/, AuctionEntry* /*auction*/, Player* owner, uint32& /*owner_accId*/, bool& sendNotification, bool& sendMail) override
|
||||||
{
|
{
|
||||||
if (owner)
|
if (owner)
|
||||||
{
|
{
|
||||||
@@ -78,6 +78,11 @@ public:
|
|||||||
if (isAHBot == true)
|
if (isAHBot == true)
|
||||||
{
|
{
|
||||||
sendNotification = false;
|
sendNotification = false;
|
||||||
|
|
||||||
|
if (sConfigMgr->GetOption<bool>("AuctionHouseBot.ReturnExpiredAuctionItemsToBot", false))
|
||||||
|
sendMail = true;
|
||||||
|
else
|
||||||
|
sendMail = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user