From 5832a3655c0acb59d78ce9433f4913692ab3695e Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 17:38:10 +0700 Subject: [PATCH 01/40] Fix crash if auctionsGuidsToConsider.size() < config->GetBidsPerInterval() --- src/AuctionHouseBot.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index fe6010c4..6c16eda4 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -244,13 +244,27 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se LOG_INFO("module", "AHBot [{}]: Considering {} auctions per interval to bid on.", _id, config->GetBidsPerInterval()); } - for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) + uint32 count_of_no_bids = 0; + + if (config->GetBidsPerInterval() > auctionsGuidsToConsider.size()) { + count_of_no_bids = auctionsGuidsToConsider.size(); + } else { + count_of_no_bids = config->GetBidsPerInterval(); + } + + if (count_of_no_bids == 0) { + return; + } + + //auctionsGuidsToConsider.size() + + for (uint32 count = 1; count <= count_of_no_bids; ++count) { // // Choose a random auction from possible auctions // - uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); + uint32 randomIndex = urand(0, count_of_no_bids - 1); std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); //std::advance(it, randomIndex); @@ -400,6 +414,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // // Check our bid is high enough to be valid. If not, correct it to minimum. // + uint32 minimumOutbid = auction->GetAuctionOutBid(); if ((currentPrice + minimumOutbid) > bidPrice) { @@ -510,6 +525,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se } } } + } // ============================================================================= From 8b824e2091825c88142bd055016542a14c8c34b2 Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:01:30 +0700 Subject: [PATCH 02/40] fix crash if auctionsGuidsToConsider.size() > config->GetBidsPerInterval() --- src/AuctionHouseBot.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 6c16eda4..9d13805c 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -244,32 +244,18 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se LOG_INFO("module", "AHBot [{}]: Considering {} auctions per interval to bid on.", _id, config->GetBidsPerInterval()); } - uint32 count_of_no_bids = 0; - - if (config->GetBidsPerInterval() > auctionsGuidsToConsider.size()) { - count_of_no_bids = auctionsGuidsToConsider.size(); - } else { - count_of_no_bids = config->GetBidsPerInterval(); - } - - if (count_of_no_bids == 0) { - return; - } - - //auctionsGuidsToConsider.size() - - for (uint32 count = 1; count <= count_of_no_bids; ++count) + for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) { // // Choose a random auction from possible auctions // - uint32 randomIndex = urand(0, count_of_no_bids - 1); + //uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); //std::advance(it, randomIndex); - uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); + uint32 auctionID = auctionsGuidsToConsider.at(itBegin); AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); @@ -277,7 +263,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // Prevent to bid again on the same auction // - auctionsGuidsToConsider.erase(itBegin + randomIndex); + auctionsGuidsToConsider.erase(itBegin); if (!auction) { @@ -414,7 +400,6 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // // Check our bid is high enough to be valid. If not, correct it to minimum. // - uint32 minimumOutbid = auction->GetAuctionOutBid(); if ((currentPrice + minimumOutbid) > bidPrice) { @@ -525,7 +510,6 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se } } } - } // ============================================================================= From 4ab26ec5ccc42753ffd5334bd175ae174df909b7 Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:10:18 +0700 Subject: [PATCH 03/40] FIx --- src/AuctionHouseBot.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 9d13805c..2e00c436 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -250,14 +250,11 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // Choose a random auction from possible auctions // - //uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); + uint32 randBid = urand(0, auctionPool.size() - 1); std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); - //std::advance(it, randomIndex); - - uint32 auctionID = auctionsGuidsToConsider.at(itBegin); - - AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); + std::advance(itBegin, randBid); + AuctionEntry* auction = auctionHouseObject->GetAuction(*itBegin); // // Prevent to bid again on the same auction @@ -274,6 +271,8 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se continue; } + uint32 auctionID = auction->Id; + // // Prevent from buying items from the other bots // From 4f65a662ca9aa1bdac55020987ac604430019ae4 Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:12:15 +0700 Subject: [PATCH 04/40] Fix Signed-off-by: lotjib --- src/AuctionHouseBot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 2e00c436..46efcaaa 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -250,7 +250,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // Choose a random auction from possible auctions // - uint32 randBid = urand(0, auctionPool.size() - 1); + uint32 randBid = urand(0, auctionsGuidsToConsider.size() - 1); std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); std::advance(itBegin, randBid); From 038bcaec9f0e71ebdcd26cd6b91edd97d6bca8cf Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:14:34 +0700 Subject: [PATCH 05/40] fix --- src/AuctionHouseBot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 46efcaaa..56790848 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -266,7 +266,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se { if (config->DebugOutBuyer) { - LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, auctionID); + LOG_ERROR("module", "AHBot [{}]: Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id); } continue; } From 1bcd754bda6434c0cda080b85beea084e857efc5 Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:28:32 +0700 Subject: [PATCH 06/40] fix crash --- src/AuctionHouseBot.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 56790848..46eb4727 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -271,8 +271,6 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se continue; } - uint32 auctionID = auction->Id; - // // Prevent from buying items from the other bots // @@ -304,6 +302,15 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(auction->item_template); + if (prototype->Quality > AHB_MAX_QUALITY) + { + if (config->DebugOutBuyer) + { + LOG_INFO("module", "AHBot [{}]: Quality {} not supported.", _id, prototype->Quality); + } + + continue; + } // // Determine current price. @@ -405,14 +412,14 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se bidPrice = currentPrice + minimumOutbid; } - if (bidPrice > maximumBid) + /*if (bidPrice > maximumBid) { if (config->TraceBuyer) { LOG_INFO("module", "AHBot [{}]: Bid was above bidMax for item={} AH={}", _id, auction->item_guid.ToString(), config->GetAHID()); } bidPrice = maximumBid; - } + }*/ if (config->DebugOutBuyer) { From 1cb4f558cc5ec35abf3ee735a0dfe18c6e08ffc0 Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:34:39 +0700 Subject: [PATCH 07/40] fix --- src/AuctionHouseBot.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 46eb4727..43f8045b 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -244,29 +244,40 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se LOG_INFO("module", "AHBot [{}]: Considering {} auctions per interval to bid on.", _id, config->GetBidsPerInterval()); } - for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) + uint32 dynamic_count_of_binds = 0; + + if (config->GetBidsPerInterval() > auctionsGuidsToConsider.size()) { + dynamic_count_of_binds = config->GetBidsPerInterval(); + } else { + dynamic_count_of_binds = 1; + } + + for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) { // // Choose a random auction from possible auctions // - uint32 randBid = urand(0, auctionsGuidsToConsider.size() - 1); + uint32 randomIndex = urand(0, dynamic_count_of_binds - 1); std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); - std::advance(itBegin, randBid); - AuctionEntry* auction = auctionHouseObject->GetAuction(*itBegin); + //std::advance(it, randomIndex); + + uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); + + AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); // // Prevent to bid again on the same auction // - auctionsGuidsToConsider.erase(itBegin); + auctionsGuidsToConsider.erase(itBegin + randomIndex); if (!auction) { if (config->DebugOutBuyer) { - LOG_ERROR("module", "AHBot [{}]: Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id); + LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, auctionID); } continue; } @@ -302,15 +313,6 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(auction->item_template); - if (prototype->Quality > AHB_MAX_QUALITY) - { - if (config->DebugOutBuyer) - { - LOG_INFO("module", "AHBot [{}]: Quality {} not supported.", _id, prototype->Quality); - } - - continue; - } // // Determine current price. @@ -412,14 +414,14 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se bidPrice = currentPrice + minimumOutbid; } - /*if (bidPrice > maximumBid) + if (bidPrice > maximumBid) { if (config->TraceBuyer) { LOG_INFO("module", "AHBot [{}]: Bid was above bidMax for item={} AH={}", _id, auction->item_guid.ToString(), config->GetAHID()); } bidPrice = maximumBid; - }*/ + } if (config->DebugOutBuyer) { From 4ffa3720e88758b7da219a250b32335002504d26 Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:43:30 +0700 Subject: [PATCH 08/40] Fix Crash Error --- src/AuctionHouseBot.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 43f8045b..e2ca5101 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -244,12 +244,18 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se LOG_INFO("module", "AHBot [{}]: Considering {} auctions per interval to bid on.", _id, config->GetBidsPerInterval()); } - uint32 dynamic_count_of_binds = 0; + // Fix Crash Error - if (config->GetBidsPerInterval() > auctionsGuidsToConsider.size()) { - dynamic_count_of_binds = config->GetBidsPerInterval(); - } else { - dynamic_count_of_binds = 1; + QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid<>{}", config->GetAHID(), 0, 0); + + uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); + + if (ahContentQueryResultNeedToBind) { + if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { + if (dynamic_count_of_binds > ahContentQueryResultNeedToBind->GetRowCount()) { + dynamic_count_of_binds = ahContentQueryResultNeedToBind->GetRowCount(); + } + } } for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) From 27fb2f57155940cc367cacebca6517853e0fa22c Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:56:08 +0700 Subject: [PATCH 09/40] Fix --- src/AuctionHouseBot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index e2ca5101..0df7a7a7 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -246,8 +246,8 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // Fix Crash Error - QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid<>{}", config->GetAHID(), 0, 0); - + QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner=0 AND buyguid=0", config->GetAHID()); + uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); if (ahContentQueryResultNeedToBind) { From 45e40e49550ee0fe53fdb708b37abb8d4646d0ec Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 18:59:24 +0700 Subject: [PATCH 10/40] Fix Crash --- src/AuctionHouseBot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 0df7a7a7..c6fbefaf 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -246,7 +246,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // Fix Crash Error - QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner=0 AND buyguid=0", config->GetAHID()); + QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner!={} AND buyguid=0", config->GetAHID(), _id); uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); From aace71a6ab8ececdbe69fbabf391404009612e43 Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 19:04:24 +0700 Subject: [PATCH 11/40] Fix Crash Error --- src/AuctionHouseBot.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index c6fbefaf..b08e27aa 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -252,8 +252,10 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se if (ahContentQueryResultNeedToBind) { if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { - if (dynamic_count_of_binds > ahContentQueryResultNeedToBind->GetRowCount()) { - dynamic_count_of_binds = ahContentQueryResultNeedToBind->GetRowCount(); + if (ahContentQueryResultNeedToBind->GetRowCount() == 1) { + dynamic_count_of_binds = 1; + } else { + dynamic_count_of_binds = ahContentQueryResultNeedToBind->GetRowCount() - 1; } } } From eefe09913de2da7f0b9900ebc0f1d6db4c4e944f Mon Sep 17 00:00:00 2001 From: lotjib Date: Fri, 28 Feb 2025 19:07:58 +0700 Subject: [PATCH 12/40] fix --- src/AuctionHouseBot.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index b08e27aa..a38d9153 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -244,12 +244,12 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se LOG_INFO("module", "AHBot [{}]: Considering {} auctions per interval to bid on.", _id, config->GetBidsPerInterval()); } - // Fix Crash Error + uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); + // Fix Crash Error + /* QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner!={} AND buyguid=0", config->GetAHID(), _id); - uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); - if (ahContentQueryResultNeedToBind) { if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { if (ahContentQueryResultNeedToBind->GetRowCount() == 1) { @@ -259,6 +259,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se } } } + */ for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) { From 0470865f094b60e8e2dfb524d091beebf627a54e Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 21:36:30 +0700 Subject: [PATCH 13/40] Fix Crash if BuyBidsPerInterval > 1 and "FROM `acore_characters`.`auctionhouse` WHERE houseid=AHID AND itemowner<>AHBOTID AND buyguid=0" --- src/AuctionHouseBot.cpp | 37 +++++++++++++++++++++-------------- src/AuctionHouseBotConfig.cpp | 3 +++ src/AuctionHouseBotConfig.h | 4 ++++ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index a38d9153..320a840f 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -172,6 +172,26 @@ uint32 AuctionHouseBot::getNofAuctions(AHBConfig* config, AuctionHouseObject* au return count; } + +uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id){ + // Fix Crash Error + if (config->CrashFix) { + QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", config->GetAHID(), _id, 0); + if (!ahContentQueryResultNeedToBind) { + return 1; + } else { + if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { + if (ahContentQueryResultNeedToBind->GetRowCount() == 1) { + dynamic_count_of_binds = 1; + } else { + dynamic_count_of_binds = ahContentQueryResultNeedToBind->GetRowCount() - 1; + } + } + } + } + return dynamic_count_of_binds; +} + // ============================================================================= // This routine performs the bidding/buyout operations for the bot // ============================================================================= @@ -244,22 +264,9 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se LOG_INFO("module", "AHBot [{}]: Considering {} auctions per interval to bid on.", _id, config->GetBidsPerInterval()); } + // CrashFix uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); - - // Fix Crash Error - /* - QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner!={} AND buyguid=0", config->GetAHID(), _id); - - if (ahContentQueryResultNeedToBind) { - if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { - if (ahContentQueryResultNeedToBind->GetRowCount() == 1) { - dynamic_count_of_binds = 1; - } else { - dynamic_count_of_binds = ahContentQueryResultNeedToBind->GetRowCount() - 1; - } - } - } - */ + dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id); for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) { diff --git a/src/AuctionHouseBotConfig.cpp b/src/AuctionHouseBotConfig.cpp index b47b07a5..7395dbc7 100644 --- a/src/AuctionHouseBotConfig.cpp +++ b/src/AuctionHouseBotConfig.cpp @@ -192,6 +192,7 @@ AHBConfig::AHBConfig(uint32 ahid, AHBConfig* conf) // Copy the public properties // + CrashFix = conf->CrashFix; DebugOut = conf->DebugOut; DebugOutConfig = conf->DebugOutConfig; DebugOutFilters = conf->DebugOutFilters; @@ -496,6 +497,7 @@ void AHBConfig::Reset() // Public properties // + CrashFix = false; DebugOut = false; DebugOutConfig = false; DebugOutFilters = false; @@ -2059,6 +2061,7 @@ void AHBConfig::InitializeFromFile() // Load from, the configuration file // + CrashFix = sConfigMgr->GetOption ("AuctionHouseBot.CrashFix" , false); DebugOut = sConfigMgr->GetOption ("AuctionHouseBot.DEBUG" , false); DebugOutConfig = sConfigMgr->GetOption ("AuctionHouseBot.DEBUG_CONFIG" , false); DebugOutFilters = sConfigMgr->GetOption ("AuctionHouseBot.DEBUG_FILTERS", false); diff --git a/src/AuctionHouseBotConfig.h b/src/AuctionHouseBotConfig.h index 17cbab42..a55f84f8 100644 --- a/src/AuctionHouseBotConfig.h +++ b/src/AuctionHouseBotConfig.h @@ -160,6 +160,10 @@ class AHBConfig void IncItemCounts(uint32 ahbotItemType); public: + // CrashFix + + bool CrashFix = false; + // // Debugging // From fc520c68619dd6be04e9ecf21eba3faa85eab03d Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 21:39:26 +0700 Subject: [PATCH 14/40] Fix --- src/AuctionHouseBot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.h b/src/AuctionHouseBot.h index fffbe1df..95a22330 100644 --- a/src/AuctionHouseBot.h +++ b/src/AuctionHouseBot.h @@ -50,7 +50,7 @@ class AuctionHouseBot // // Main operations // - + uint32 CrashFix(uint32 dynamic_count_of_binds, uint32 _id); void Sell(Player *AHBplayer, AHBConfig *config); void Buy (Player *AHBplayer, AHBConfig *config, WorldSession *session); From dc03a69dc4adf2cfecb20924176afddd9d82e8bf Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 21:41:16 +0700 Subject: [PATCH 15/40] Fix --- src/AuctionHouseBot.cpp | 2 +- src/AuctionHouseBot.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 320a840f..fe824311 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -173,7 +173,7 @@ uint32 AuctionHouseBot::getNofAuctions(AHBConfig* config, AuctionHouseObject* au } -uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id){ +uint32 AuctionHouseBot::CrashFix(uint32* dynamic_count_of_binds, uint32* _id, AHBConfig* config){ // Fix Crash Error if (config->CrashFix) { QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", config->GetAHID(), _id, 0); diff --git a/src/AuctionHouseBot.h b/src/AuctionHouseBot.h index 95a22330..d9818f20 100644 --- a/src/AuctionHouseBot.h +++ b/src/AuctionHouseBot.h @@ -50,7 +50,7 @@ class AuctionHouseBot // // Main operations // - uint32 CrashFix(uint32 dynamic_count_of_binds, uint32 _id); + uint32 CrashFix(uint32 *dynamic_count_of_binds, uint32 *_id, AHBConfig *config); void Sell(Player *AHBplayer, AHBConfig *config); void Buy (Player *AHBplayer, AHBConfig *config, WorldSession *session); From 251ea3b8cf961a3f4b70d335e9a3017755b5d1d6 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 21:43:18 +0700 Subject: [PATCH 16/40] Fix --- src/AuctionHouseBot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index fe824311..c7386d1f 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -173,7 +173,7 @@ uint32 AuctionHouseBot::getNofAuctions(AHBConfig* config, AuctionHouseObject* au } -uint32 AuctionHouseBot::CrashFix(uint32* dynamic_count_of_binds, uint32* _id, AHBConfig* config){ +uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id, AHBConfig config){ // Fix Crash Error if (config->CrashFix) { QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", config->GetAHID(), _id, 0); From d47ad7beb25b7868262a9ad1e1b517c239b814a9 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 21:48:33 +0700 Subject: [PATCH 17/40] Fix --- src/AuctionHouseBot.cpp | 6 +++--- src/AuctionHouseBot.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index c7386d1f..9e846874 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -173,12 +173,12 @@ uint32 AuctionHouseBot::getNofAuctions(AHBConfig* config, AuctionHouseObject* au } -uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id, AHBConfig config){ +uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id, AHBConfig* config){ // Fix Crash Error if (config->CrashFix) { QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", config->GetAHID(), _id, 0); if (!ahContentQueryResultNeedToBind) { - return 1; + dynamic_count_of_binds = 1; } else { if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { if (ahContentQueryResultNeedToBind->GetRowCount() == 1) { @@ -266,7 +266,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // CrashFix uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); - dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id); + dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config); for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) { diff --git a/src/AuctionHouseBot.h b/src/AuctionHouseBot.h index d9818f20..dbfc9022 100644 --- a/src/AuctionHouseBot.h +++ b/src/AuctionHouseBot.h @@ -50,7 +50,7 @@ class AuctionHouseBot // // Main operations // - uint32 CrashFix(uint32 *dynamic_count_of_binds, uint32 *_id, AHBConfig *config); + uint32 CrashFix(uint32 dynamic_count_of_binds, uint32 _id, AHBConfig *config); void Sell(Player *AHBplayer, AHBConfig *config); void Buy (Player *AHBplayer, AHBConfig *config, WorldSession *session); From 73d794ce1d9ca69966d68398cd7433786b2b6729 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 22:07:47 +0700 Subject: [PATCH 18/40] Revert --- src/AuctionHouseBot.cpp | 24 +++++++++++------------- src/AuctionHouseBotConfig.cpp | 3 --- src/AuctionHouseBotConfig.h | 4 ---- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 9e846874..89c3a925 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -173,19 +173,17 @@ uint32 AuctionHouseBot::getNofAuctions(AHBConfig* config, AuctionHouseObject* au } -uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id, AHBConfig* config){ +uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id){ // Fix Crash Error - if (config->CrashFix) { - QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", config->GetAHID(), _id, 0); - if (!ahContentQueryResultNeedToBind) { - dynamic_count_of_binds = 1; - } else { - if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { - if (ahContentQueryResultNeedToBind->GetRowCount() == 1) { - dynamic_count_of_binds = 1; - } else { - dynamic_count_of_binds = ahContentQueryResultNeedToBind->GetRowCount() - 1; - } + QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", config->GetAHID(), _id, 0); + if (!ahContentQueryResultNeedToBind) { + dynamic_count_of_binds = 1; + } else { + if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { + if (ahContentQueryResultNeedToBind->GetRowCount() == 1) { + dynamic_count_of_binds = 1; + } else { + dynamic_count_of_binds = ahContentQueryResultNeedToBind->GetRowCount() - 1; } } } @@ -266,7 +264,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // CrashFix uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); - dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config); + // dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config); for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) { diff --git a/src/AuctionHouseBotConfig.cpp b/src/AuctionHouseBotConfig.cpp index 7395dbc7..b47b07a5 100644 --- a/src/AuctionHouseBotConfig.cpp +++ b/src/AuctionHouseBotConfig.cpp @@ -192,7 +192,6 @@ AHBConfig::AHBConfig(uint32 ahid, AHBConfig* conf) // Copy the public properties // - CrashFix = conf->CrashFix; DebugOut = conf->DebugOut; DebugOutConfig = conf->DebugOutConfig; DebugOutFilters = conf->DebugOutFilters; @@ -497,7 +496,6 @@ void AHBConfig::Reset() // Public properties // - CrashFix = false; DebugOut = false; DebugOutConfig = false; DebugOutFilters = false; @@ -2061,7 +2059,6 @@ void AHBConfig::InitializeFromFile() // Load from, the configuration file // - CrashFix = sConfigMgr->GetOption ("AuctionHouseBot.CrashFix" , false); DebugOut = sConfigMgr->GetOption ("AuctionHouseBot.DEBUG" , false); DebugOutConfig = sConfigMgr->GetOption ("AuctionHouseBot.DEBUG_CONFIG" , false); DebugOutFilters = sConfigMgr->GetOption ("AuctionHouseBot.DEBUG_FILTERS", false); diff --git a/src/AuctionHouseBotConfig.h b/src/AuctionHouseBotConfig.h index a55f84f8..17cbab42 100644 --- a/src/AuctionHouseBotConfig.h +++ b/src/AuctionHouseBotConfig.h @@ -160,10 +160,6 @@ class AHBConfig void IncItemCounts(uint32 ahbotItemType); public: - // CrashFix - - bool CrashFix = false; - // // Debugging // From c953b4d0d7537d6e7545ccb2f79eb5c69a415b26 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 22:08:59 +0700 Subject: [PATCH 19/40] Fix --- src/AuctionHouseBot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.h b/src/AuctionHouseBot.h index dbfc9022..95a22330 100644 --- a/src/AuctionHouseBot.h +++ b/src/AuctionHouseBot.h @@ -50,7 +50,7 @@ class AuctionHouseBot // // Main operations // - uint32 CrashFix(uint32 dynamic_count_of_binds, uint32 _id, AHBConfig *config); + uint32 CrashFix(uint32 dynamic_count_of_binds, uint32 _id); void Sell(Player *AHBplayer, AHBConfig *config); void Buy (Player *AHBplayer, AHBConfig *config, WorldSession *session); From cce768f02ddc7bf854d70dc7e51266b6abb28a4f Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 22:12:18 +0700 Subject: [PATCH 20/40] Fix --- src/AuctionHouseBot.cpp | 8 ++++---- src/AuctionHouseBot.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 89c3a925..c5a82bfb 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -173,9 +173,9 @@ uint32 AuctionHouseBot::getNofAuctions(AHBConfig* config, AuctionHouseObject* au } -uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id){ +uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id, uint32 _ahid){ // Fix Crash Error - QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", config->GetAHID(), _id, 0); + QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", _ahid, _id, 0); if (!ahContentQueryResultNeedToBind) { dynamic_count_of_binds = 1; } else { @@ -264,8 +264,8 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // CrashFix uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); - // dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config); - + // dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config->GetAHID()); + for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) { // diff --git a/src/AuctionHouseBot.h b/src/AuctionHouseBot.h index 95a22330..2f06274a 100644 --- a/src/AuctionHouseBot.h +++ b/src/AuctionHouseBot.h @@ -50,7 +50,7 @@ class AuctionHouseBot // // Main operations // - uint32 CrashFix(uint32 dynamic_count_of_binds, uint32 _id); + uint32 CrashFix(uint32 dynamic_count_of_binds, uint32 _id, uint32 _ahid); void Sell(Player *AHBplayer, AHBConfig *config); void Buy (Player *AHBplayer, AHBConfig *config, WorldSession *session); From a5bc197203b1bf34e5e9b95de68ca1c8fdd815a9 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 22:45:13 +0700 Subject: [PATCH 21/40] hello test --- src/AuctionHouseBot.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index c5a82bfb..62c4c7b7 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -264,8 +264,8 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // CrashFix uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); - // dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config->GetAHID()); - + //dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config->GetAHID()); + for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) { // @@ -1037,6 +1037,7 @@ void AuctionHouseBot::Sell(Player* AHBplayer, AHBConfig* config) void AuctionHouseBot::Update() { + LOG_INFO("module", "AHBot [{}]: HELLO!", _id); time_t _newrun = time(NULL); // From 01604c1ef7693ed9151753d566c1a05ff433df9a Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 22:49:12 +0700 Subject: [PATCH 22/40] FF --- src/AuctionHouseBot.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 62c4c7b7..b0d1b419 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -263,7 +263,9 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se } // CrashFix + LOG_INFO("module", "AHBot [{}]: CRASHFIX THIS!", _id); uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); + LOG_INFO("module", "AHBot [{}]: CRASHFIX THIS END!", _id); //dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config->GetAHID()); for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) @@ -1037,7 +1039,6 @@ void AuctionHouseBot::Sell(Player* AHBplayer, AHBConfig* config) void AuctionHouseBot::Update() { - LOG_INFO("module", "AHBot [{}]: HELLO!", _id); time_t _newrun = time(NULL); // @@ -1131,13 +1132,14 @@ void AuctionHouseBot::Update() LOG_INFO("module", "AHBot [{}]: Begin Sell for Neutral...", _id); } Sell(&_AHBplayer, _neutralConfig); - + LOG_INFO("module", "AHBot [{}]: SELL READY PARASOLKA!", _id); if (((_newrun - _lastrun_n_sec) >= (_neutralConfig->GetBiddingInterval() * MINUTE)) && (_neutralConfig->GetBidsPerInterval() > 0)) { if (_neutralConfig->TraceBuyer) { LOG_INFO("module", "AHBot [{}]: Begin Buy for Neutral...", _id); } + LOG_INFO("module", "AHBot [{}]: GO BUY!", _id); Buy(&_AHBplayer, _neutralConfig, &_session); _lastrun_n_sec = _newrun; } From bb513da2952af58edff4c3c15d24d779b821fa16 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 23:04:37 +0700 Subject: [PATCH 23/40] FF --- src/AuctionHouseBot.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index b0d1b419..ec17b7d6 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -275,20 +275,40 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // uint32 randomIndex = urand(0, dynamic_count_of_binds - 1); + if (!randomIndex) { + LOG_INFO("module", "AHBot [{}]: !randomIndex!", _id); + continue; + } std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); + if (!itBegin) { + LOG_INFO("module", "AHBot [{}]: !itBegin!", _id); + continue; + } //std::advance(it, randomIndex); uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); + if (!auctionID) { + LOG_INFO("module", "AHBot [{}]: !auctionID!", _id); + continue; + } AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); + if (!auction) { + LOG_INFO("module", "AHBot [{}]: !auction!", _id); + continue; + } + // // Prevent to bid again on the same auction // auctionsGuidsToConsider.erase(itBegin + randomIndex); + LOG_INFO("module", "AHBot [{}]: auctionsGuidsToConsider", _id); + + if (!auction) { if (config->DebugOutBuyer) @@ -304,6 +324,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se if (gBotsId.find(auction->owner.GetCounter()) != gBotsId.end()) { + LOG_INFO("module", "AHBot [{}]: Prevent from buying items from the other bots", _id); continue; } From ccee06270bafe98724677dcf3436f27ab263e7f6 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 23:06:10 +0700 Subject: [PATCH 24/40] ff --- src/AuctionHouseBot.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index ec17b7d6..de2252ee 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -281,10 +281,8 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se } std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); - if (!itBegin) { - LOG_INFO("module", "AHBot [{}]: !itBegin!", _id); - continue; - } + LOG_INFO("module", "AHBot [{}]: itBegin!", _id); + //std::advance(it, randomIndex); uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); From 4b353288de395e7c0348a90e7074d169c7c6ca2e Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 23:31:44 +0700 Subject: [PATCH 25/40] Fix --- src/AuctionHouseBot.cpp | 56 ++++------------------------------------- src/AuctionHouseBot.h | 1 - 2 files changed, 5 insertions(+), 52 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index de2252ee..bb5a8e62 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -172,24 +172,6 @@ uint32 AuctionHouseBot::getNofAuctions(AHBConfig* config, AuctionHouseObject* au return count; } - -uint32 AuctionHouseBot::CrashFix(uint32 dynamic_count_of_binds, uint32 _id, uint32 _ahid){ - // Fix Crash Error - QueryResult ahContentQueryResultNeedToBind = CharacterDatabase.Query("SELECT id FROM auctionhouse WHERE houseid={} AND itemowner<>{} AND buyguid={}", _ahid, _id, 0); - if (!ahContentQueryResultNeedToBind) { - dynamic_count_of_binds = 1; - } else { - if (ahContentQueryResultNeedToBind->GetRowCount() > 0) { - if (ahContentQueryResultNeedToBind->GetRowCount() == 1) { - dynamic_count_of_binds = 1; - } else { - dynamic_count_of_binds = ahContentQueryResultNeedToBind->GetRowCount() - 1; - } - } - } - return dynamic_count_of_binds; -} - // ============================================================================= // This routine performs the bidding/buyout operations for the bot // ============================================================================= @@ -262,50 +244,22 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se LOG_INFO("module", "AHBot [{}]: Considering {} auctions per interval to bid on.", _id, config->GetBidsPerInterval()); } - // CrashFix - LOG_INFO("module", "AHBot [{}]: CRASHFIX THIS!", _id); - uint32 dynamic_count_of_binds = config->GetBidsPerInterval(); - LOG_INFO("module", "AHBot [{}]: CRASHFIX THIS END!", _id); - //dynamic_count_of_binds = CrashFix(dynamic_count_of_binds, _id, config->GetAHID()); - - for (uint32 count = 1; count <= dynamic_count_of_binds; ++count) + for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) { // // Choose a random auction from possible auctions // - uint32 randomIndex = urand(0, dynamic_count_of_binds - 1); - if (!randomIndex) { - LOG_INFO("module", "AHBot [{}]: !randomIndex!", _id); - continue; - } - + uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); - LOG_INFO("module", "AHBot [{}]: itBegin!", _id); - - //std::advance(it, randomIndex); - - uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); - if (!auctionID) { - LOG_INFO("module", "AHBot [{}]: !auctionID!", _id); - continue; - } - - AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); - - if (!auction) { - LOG_INFO("module", "AHBot [{}]: !auction!", _id); - continue; - } + std::advance(itBegin, randomIndex); + AuctionEntry* auction = auctionHouseObject->GetAuction(*itBegin); // // Prevent to bid again on the same auction // - auctionsGuidsToConsider.erase(itBegin + randomIndex); - - LOG_INFO("module", "AHBot [{}]: auctionsGuidsToConsider", _id); - + auctionsGuidsToConsider.erase(itBegin); if (!auction) { diff --git a/src/AuctionHouseBot.h b/src/AuctionHouseBot.h index 2f06274a..0c379c92 100644 --- a/src/AuctionHouseBot.h +++ b/src/AuctionHouseBot.h @@ -50,7 +50,6 @@ class AuctionHouseBot // // Main operations // - uint32 CrashFix(uint32 dynamic_count_of_binds, uint32 _id, uint32 _ahid); void Sell(Player *AHBplayer, AHBConfig *config); void Buy (Player *AHBplayer, AHBConfig *config, WorldSession *session); From 55d2e5d27bd08dc78b1aa9f3206522e9cb19e375 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 23:33:15 +0700 Subject: [PATCH 26/40] ff --- src/AuctionHouseBot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index bb5a8e62..2aa6186b 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -265,7 +265,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se { if (config->DebugOutBuyer) { - LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, auctionID); + LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, *itBegin); } continue; } From 5e018535d23b7e466a7a3a5e347708f7b9b65eca Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 23:48:56 +0700 Subject: [PATCH 27/40] ff --- src/AuctionHouseBot.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 2aa6186b..13d16068 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -253,23 +253,34 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); std::advance(itBegin, randomIndex); - AuctionEntry* auction = auctionHouseObject->GetAuction(*itBegin); + AuctionEntry *auction = auctionHouseObject->GetAuction(*itBegin); // // Prevent to bid again on the same auction // - - auctionsGuidsToConsider.erase(itBegin); + + try + { + auctionsGuidsToConsider.erase(itBegin); + } + catch(const std::exception& e) + { + LOG_ERROR("module", "AHBot [{}]: auctionsGuidsToConsider: {}", _id, auction->Id); + } + + if (!auction) { if (config->DebugOutBuyer) { - LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, *itBegin); + LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, auction->Id); } continue; } + LOG_INFO("module", "AHBot [{}]: Auction #{}: GOGO FIND AND OTHER!", _id, auction->Id); + // // Prevent from buying items from the other bots // @@ -302,7 +313,6 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(auction->item_template); - // // Determine current price. // From bd33a4ec40c8b7828fb9fbc58bd9e71ccc08d895 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sat, 1 Mar 2025 23:59:54 +0700 Subject: [PATCH 28/40] F --- src/AuctionHouseBot.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 13d16068..b9a605d8 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -403,7 +403,6 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se double bidValue = currentPrice + ((maximumBid - currentPrice) * bidRate); uint32 bidPrice = static_cast(bidValue); - // // Check our bid is high enough to be valid. If not, correct it to minimum. // @@ -419,7 +418,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se { LOG_INFO("module", "AHBot [{}]: Bid was above bidMax for item={} AH={}", _id, auction->item_guid.ToString(), config->GetAHID()); } - bidPrice = maximumBid; + bidPrice = uint32(maximumBid); } if (config->DebugOutBuyer) From e37bdc17038389cea3d45c58886562d8789ec52e Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:08:31 +0700 Subject: [PATCH 29/40] fix --- src/AuctionHouseBot.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index b9a605d8..07fcf64e 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -322,8 +322,8 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // Determine maximum bid and skip auctions with too high a currentPrice. // - double basePrice = config->UseBuyPriceForBuyer ? prototype->BuyPrice : prototype->SellPrice; - double maximumBid = basePrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality); + uint32 basePrice = static_cast(config->UseBuyPriceForBuyer ? prototype->BuyPrice : prototype->SellPrice); + uint32 maximumBid = static_cast(basePrice * pItem->GetCount() * config->GetBuyerPrice(prototype->Quality)); if (config->TraceBuyer) { @@ -400,7 +400,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // double bidRate = static_cast(urand(1, 100)) / 100; - double bidValue = currentPrice + ((maximumBid - currentPrice) * bidRate); + uint32 bidValue = static_cast(currentPrice + ((maximumBid - currentPrice) * bidRate)); uint32 bidPrice = static_cast(bidValue); // @@ -409,7 +409,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se uint32 minimumOutbid = auction->GetAuctionOutBid(); if ((currentPrice + minimumOutbid) > bidPrice) { - bidPrice = currentPrice + minimumOutbid; + bidPrice = static_cast(currentPrice + minimumOutbid); } if (bidPrice > maximumBid) @@ -418,7 +418,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se { LOG_INFO("module", "AHBot [{}]: Bid was above bidMax for item={} AH={}", _id, auction->item_guid.ToString(), config->GetAHID()); } - bidPrice = uint32(maximumBid); + bidPrice = static_cast(maximumBid); } if (config->DebugOutBuyer) From af31815dca4dbf4f6ec631a9477342d02e638c07 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:16:19 +0700 Subject: [PATCH 30/40] ff --- src/AuctionHouseBot.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 07fcf64e..ac693f2d 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -218,7 +218,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se do { uint32 autionGuid = ahContentQueryResult->Fetch()->Get(); - auctionsGuidsToConsider.push_back(autionGuid); + auctionsGuidsToConsider.insert(autionGuid); } while (ahContentQueryResult->NextRow()); // @@ -246,30 +246,18 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) { + LOG_INFO("module", "AHBot [{}]: Start For!", _id); // // Choose a random auction from possible auctions // uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); + LOG_INFO("module", "AHBot [{}]: randomIndex: {} !", _id, randomIndex); std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); std::advance(itBegin, randomIndex); AuctionEntry *auction = auctionHouseObject->GetAuction(*itBegin); - - // - // Prevent to bid again on the same auction - // - - try - { - auctionsGuidsToConsider.erase(itBegin); - } - catch(const std::exception& e) - { - LOG_ERROR("module", "AHBot [{}]: auctionsGuidsToConsider: {}", _id, auction->Id); - } + auctionsGuidsToConsider.erase(itBegin); // Prevent to bid again on the same auction - - if (!auction) { if (config->DebugOutBuyer) From 305a0ae5ab69a81038c3dd7b3b052d3d8ca22c70 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:20:11 +0700 Subject: [PATCH 31/40] ff --- src/AuctionHouseBot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index ac693f2d..eeb2d5f0 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -213,7 +213,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // AuctionHouseObject* auctionHouseObject = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); - std::vector auctionsGuidsToConsider; + std::set auctionsGuidsToConsider; do { @@ -253,7 +253,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); LOG_INFO("module", "AHBot [{}]: randomIndex: {} !", _id, randomIndex); - std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); + std::set::iterator itBegin = auctionsGuidsToConsider.begin(); std::advance(itBegin, randomIndex); AuctionEntry *auction = auctionHouseObject->GetAuction(*itBegin); auctionsGuidsToConsider.erase(itBegin); // Prevent to bid again on the same auction From f92246ee22d0ddba452c42fdd52ae0f174873cf2 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:28:22 +0700 Subject: [PATCH 32/40] Fix Crash --- src/AuctionHouseBot.cpp | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index eeb2d5f0..32ee4707 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -213,12 +213,12 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // AuctionHouseObject* auctionHouseObject = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); - std::set auctionsGuidsToConsider; + std::vector auctionsGuidsToConsider; do { uint32 autionGuid = ahContentQueryResult->Fetch()->Get(); - auctionsGuidsToConsider.insert(autionGuid); + auctionsGuidsToConsider.push_back(autionGuid); } while (ahContentQueryResult->NextRow()); // @@ -246,36 +246,40 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) { - LOG_INFO("module", "AHBot [{}]: Start For!", _id); // // Choose a random auction from possible auctions // uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); - LOG_INFO("module", "AHBot [{}]: randomIndex: {} !", _id, randomIndex); - std::set::iterator itBegin = auctionsGuidsToConsider.begin(); - std::advance(itBegin, randomIndex); - AuctionEntry *auction = auctionHouseObject->GetAuction(*itBegin); - auctionsGuidsToConsider.erase(itBegin); // Prevent to bid again on the same auction - + + std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); + //std::advance(it, randomIndex); + + uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); + + AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); + + // + // Prevent to bid again on the same auction + // + + auctionsGuidsToConsider.erase(itBegin + randomIndex); + if (!auction) { if (config->DebugOutBuyer) { - LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, auction->Id); + LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, auctionID); } continue; } - LOG_INFO("module", "AHBot [{}]: Auction #{}: GOGO FIND AND OTHER!", _id, auction->Id); - // // Prevent from buying items from the other bots // if (gBotsId.find(auction->owner.GetCounter()) != gBotsId.end()) { - LOG_INFO("module", "AHBot [{}]: Prevent from buying items from the other bots", _id); continue; } @@ -301,10 +305,12 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(auction->item_template); + // // Determine current price. // - uint32 currentPrice = auction->bid ? auction->bid : auction->startbid; + + uint32 currentPrice = static_cast(auction->bid ? auction->bid : auction->startbid); // // Determine maximum bid and skip auctions with too high a currentPrice. @@ -388,9 +394,10 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // double bidRate = static_cast(urand(1, 100)) / 100; - uint32 bidValue = static_cast(currentPrice + ((maximumBid - currentPrice) * bidRate)); + double bidValue = currentPrice + ((maximumBid - currentPrice) * bidRate); uint32 bidPrice = static_cast(bidValue); + // // Check our bid is high enough to be valid. If not, correct it to minimum. // @@ -1102,14 +1109,13 @@ void AuctionHouseBot::Update() LOG_INFO("module", "AHBot [{}]: Begin Sell for Neutral...", _id); } Sell(&_AHBplayer, _neutralConfig); - LOG_INFO("module", "AHBot [{}]: SELL READY PARASOLKA!", _id); + if (((_newrun - _lastrun_n_sec) >= (_neutralConfig->GetBiddingInterval() * MINUTE)) && (_neutralConfig->GetBidsPerInterval() > 0)) { if (_neutralConfig->TraceBuyer) { LOG_INFO("module", "AHBot [{}]: Begin Buy for Neutral...", _id); } - LOG_INFO("module", "AHBot [{}]: GO BUY!", _id); Buy(&_AHBplayer, _neutralConfig, &_session); _lastrun_n_sec = _newrun; } From ca61e270dbe8b1048c9b7033ac8b6b399019f509 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:33:37 +0700 Subject: [PATCH 33/40] fix --- src/AuctionHouseBot.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 32ee4707..e4e8c483 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -213,12 +213,14 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // AuctionHouseObject* auctionHouseObject = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); - std::vector auctionsGuidsToConsider; + //std::vector auctionsGuidsToConsider; + std::set auctionsGuidsToConsider; do { uint32 autionGuid = ahContentQueryResult->Fetch()->Get(); - auctionsGuidsToConsider.push_back(autionGuid); + //auctionsGuidsToConsider.push_back(autionGuid); + auctionsGuidsToConsider.insert(autionGuid); } while (ahContentQueryResult->NextRow()); // @@ -252,24 +254,24 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); - std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); - //std::advance(it, randomIndex); + //std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); + std::set::iterator itBegin = auctionsGuidsToConsider.begin(); + std::advance(itBegin, randomIndex); - uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); - - AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); + //uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); + AuctionEntry *auction = auctionHouseObject->GetAuction(*itBegin); // // Prevent to bid again on the same auction // - - auctionsGuidsToConsider.erase(itBegin + randomIndex); + auctionPool.erase(itBegin); + //auctionsGuidsToConsider.erase(itBegin + randomIndex); if (!auction) { if (config->DebugOutBuyer) { - LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, auctionID); + LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, *itBegin); } continue; } @@ -309,7 +311,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // // Determine current price. // - + uint32 currentPrice = static_cast(auction->bid ? auction->bid : auction->startbid); // From d3d6ce34bbe03584fb7d9620151ba38c07a43235 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:34:38 +0700 Subject: [PATCH 34/40] f --- src/AuctionHouseBot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index e4e8c483..023d2656 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -264,7 +264,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // // Prevent to bid again on the same auction // - auctionPool.erase(itBegin); + auctionsGuidsToConsider.erase(itBegin); //auctionsGuidsToConsider.erase(itBegin + randomIndex); if (!auction) From 588cc049ccd6d9170c03b389bffb63b2bba3db7d Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:41:03 +0700 Subject: [PATCH 35/40] ff --- src/AuctionHouseBot.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 023d2656..bd8b791f 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -256,16 +256,15 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se //std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); std::set::iterator itBegin = auctionsGuidsToConsider.begin(); - std::advance(itBegin, randomIndex); + //std::advance(itBegin, randomIndex); - //uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); + uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); - AuctionEntry *auction = auctionHouseObject->GetAuction(*itBegin); + AuctionEntry *auction = auctionHouseObject->GetAuction(auctionID); // // Prevent to bid again on the same auction // - auctionsGuidsToConsider.erase(itBegin); - //auctionsGuidsToConsider.erase(itBegin + randomIndex); + auctionsGuidsToConsider.erase(itBegin + randomIndex); if (!auction) { From cafa71216515ff7189d1b57ddbe57e4f0f1ff4b3 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:50:51 +0700 Subject: [PATCH 36/40] ff --- src/AuctionHouseBot.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index bd8b791f..7d080e0b 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -253,14 +253,10 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); - - //std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); std::set::iterator itBegin = auctionsGuidsToConsider.begin(); - //std::advance(itBegin, randomIndex); - - uint32 auctionID = auctionsGuidsToConsider.at(randomIndex); - - AuctionEntry *auction = auctionHouseObject->GetAuction(auctionID); + std::advance(itBegin, randomIndex); + uint32 auctionID = *itBegin; + AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); // // Prevent to bid again on the same auction // @@ -270,7 +266,7 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se { if (config->DebugOutBuyer) { - LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, *itBegin); + LOG_ERROR("module", "AHBot [{}]: Auction id: {} Possible entry to buy/bid from AH pool is invalid, this should not happen, moving on next auciton", _id, auctionID); } continue; } From 1a978c1f91757cb8a4ad4d42393481719d64e68d Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:52:28 +0700 Subject: [PATCH 37/40] ff --- src/AuctionHouseBot.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 7d080e0b..591408a1 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -252,15 +252,13 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // Choose a random auction from possible auctions // - uint32 randomIndex = urand(0, auctionsGuidsToConsider.size() - 1); std::set::iterator itBegin = auctionsGuidsToConsider.begin(); - std::advance(itBegin, randomIndex); uint32 auctionID = *itBegin; AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); // // Prevent to bid again on the same auction // - auctionsGuidsToConsider.erase(itBegin + randomIndex); + auctionsGuidsToConsider.erase(itBegin); if (!auction) { From edeb7039b91965864aafc6b1837f342a733437bd Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 00:56:57 +0700 Subject: [PATCH 38/40] ff --- src/AuctionHouseBot.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 591408a1..940f00f0 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -213,14 +213,12 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // AuctionHouseObject* auctionHouseObject = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); - //std::vector auctionsGuidsToConsider; - std::set auctionsGuidsToConsider; + std::vector auctionsGuidsToConsider; do { uint32 autionGuid = ahContentQueryResult->Fetch()->Get(); - //auctionsGuidsToConsider.push_back(autionGuid); - auctionsGuidsToConsider.insert(autionGuid); + auctionsGuidsToConsider.push_back(autionGuid); } while (ahContentQueryResult->NextRow()); // @@ -248,13 +246,11 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) { - // - // Choose a random auction from possible auctions - // - - std::set::iterator itBegin = auctionsGuidsToConsider.begin(); - uint32 auctionID = *itBegin; + + std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); + uint32 auctionID = auctionsGuidsToConsider.at(*itBegin); AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); + // // Prevent to bid again on the same auction // From 53b513212af51df9a478a22961da9f0f201712e4 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 01:07:54 +0700 Subject: [PATCH 39/40] ff --- src/AuctionHouseBot.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 940f00f0..7700854b 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -213,12 +213,12 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se // AuctionHouseObject* auctionHouseObject = sAuctionMgr->GetAuctionsMap(config->GetAHFID()); - std::vector auctionsGuidsToConsider; + std::set auctionsGuidsToConsider; do { uint32 autionGuid = ahContentQueryResult->Fetch()->Get(); - auctionsGuidsToConsider.push_back(autionGuid); + auctionsGuidsToConsider.insert(autionGuid); } while (ahContentQueryResult->NextRow()); // @@ -246,15 +246,16 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) { - - std::vector::iterator itBegin = auctionsGuidsToConsider.begin(); - uint32 auctionID = auctionsGuidsToConsider.at(*itBegin); + + std::set::iterator it = auctionsGuidsToConsider.begin(); + std::advance(it, 0); + uint32 auctionID = *it; AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); // // Prevent to bid again on the same auction // - auctionsGuidsToConsider.erase(itBegin); + auctionsGuidsToConsider.erase(it); if (!auction) { From 99fdca2460903a1cfe95ba9ded2eabf08feef804 Mon Sep 17 00:00:00 2001 From: lotjib Date: Sun, 2 Mar 2025 01:17:29 +0700 Subject: [PATCH 40/40] fix --- src/AuctionHouseBot.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/AuctionHouseBot.cpp b/src/AuctionHouseBot.cpp index 7700854b..f372151f 100644 --- a/src/AuctionHouseBot.cpp +++ b/src/AuctionHouseBot.cpp @@ -246,12 +246,15 @@ void AuctionHouseBot::Buy(Player* AHBplayer, AHBConfig* config, WorldSession* se for (uint32 count = 1; count <= config->GetBidsPerInterval(); ++count) { + if (auctionsGuidsToConsider.empty()) { + return; + } std::set::iterator it = auctionsGuidsToConsider.begin(); std::advance(it, 0); uint32 auctionID = *it; AuctionEntry* auction = auctionHouseObject->GetAuction(auctionID); - + // // Prevent to bid again on the same auction //