From e28ec44672047d28db6bf8433fabfab737d11d12 Mon Sep 17 00:00:00 2001 From: mostlikely4r Date: Mon, 7 Oct 2024 16:53:38 +0200 Subject: [PATCH] -Pmo: Added new auction db query functions to explicitly show up in the performance monitor. --- playerbot/strategy/actions/AhAction.cpp | 14 ++++++++++++-- playerbot/strategy/actions/BuyAction.cpp | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/playerbot/strategy/actions/AhAction.cpp b/playerbot/strategy/actions/AhAction.cpp index 36accb2c..371a9580 100644 --- a/playerbot/strategy/actions/AhAction.cpp +++ b/playerbot/strategy/actions/AhAction.cpp @@ -63,7 +63,11 @@ bool AhAction::ExecuteCommand(Player* requester, std::string text, Unit* auction if(AI_VALUE2(ItemUsage, "item usage", ItemQualifier(item).GetQualifier()) != ItemUsage::ITEM_USAGE_AH) continue; - if (!ItemUsageValue::IsMoreProfitableToSellToAHThanToVendor(item->GetProto(), bot)) + PerformanceMonitorOperation* pmo = sPerformanceMonitor.start(PERF_MON_VALUE, "IsMoreProfitableToSellToAHThanToVendor", &context->performanceStack); + bool isMoreProfitableToSellToAHThanToVendor = ItemUsageValue::IsMoreProfitableToSellToAHThanToVendor(item->GetProto(), bot); + if (pmo) pmo->finish(); + + if (!isMoreProfitableToSellToAHThanToVendor) continue; uint32 deposit = AuctionHouseMgr::GetAuctionDeposit(auctionHouseEntry, time * MINUTE, item); @@ -284,10 +288,16 @@ bool AhBidAction::ExecuteCommand(Player* requester, std::string text, Unit* auct power = sRandomItemMgr.GetLiveStatWeight(bot, auction->itemTemplate); break; case ItemUsage::ITEM_USAGE_AH: - if (!ItemUsageValue::IsWorthBuyingFromAhToResellAtAH(sObjectMgr.GetItemPrototype(auction->itemTemplate), totalCost, auction->itemCount)) + { + PerformanceMonitorOperation* pmo = sPerformanceMonitor.start(PERF_MON_VALUE, "IsWorthBuyingFromAhToResellAtAH", &context->performanceStack); + bool isWorthBuyingFromAhToResellAtAH = ItemUsageValue::IsWorthBuyingFromAhToResellAtAH(sObjectMgr.GetItemPrototype(auction->itemTemplate), totalCost, auction->itemCount); + if (pmo) pmo->finish(); + + if (!isWorthBuyingFromAhToResellAtAH) continue; power = 1000; break; + } case ItemUsage::ITEM_USAGE_VENDOR: //basically if AH price is lower than vendor sell price then it's worth it if (totalCost / auction->itemCount >= (int32)sObjectMgr.GetItemPrototype(auction->itemTemplate)->SellPrice) diff --git a/playerbot/strategy/actions/BuyAction.cpp b/playerbot/strategy/actions/BuyAction.cpp index 587a3953..96fc3151 100644 --- a/playerbot/strategy/actions/BuyAction.cpp +++ b/playerbot/strategy/actions/BuyAction.cpp @@ -86,7 +86,12 @@ bool BuyAction::Execute(Event& event) freeMoney[ItemUsage::ITEM_USAGE_QUEST] = freeMoney[ItemUsage::ITEM_USAGE_FORCE_NEED] = freeMoney[ItemUsage::ITEM_USAGE_FORCE_GREED] = (uint32)NeedMoneyFor::anything; //if item is worth selling to AH? - if (ItemUsageValue::IsWorthBuyingFromVendorToResellAtAH(proto, tItem->maxcount > 0)) + + PerformanceMonitorOperation* pmo = sPerformanceMonitor.start(PERF_MON_VALUE, "IsWorthBuyingFromVendorToResellAtAH", &context->performanceStack); + bool isWorthBuyingFromVendorToResellAtAH = ItemUsageValue::IsWorthBuyingFromVendorToResellAtAH(proto, tItem->maxcount > 0); + if (pmo) pmo->finish(); + + if (isWorthBuyingFromVendorToResellAtAH) freeMoney[ItemUsage::ITEM_USAGE_AH] = (uint32)NeedMoneyFor::anything; if (freeMoney.find(usage) == freeMoney.end())