Added configuration on excluded prefixes for trade action (#1401)

* - Added configuration on excluded prefixes for trade action

* - LoadListString usage reference specified

* - Code refactoring
This commit is contained in:
kadeshar
2025-07-04 17:13:19 +02:00
committed by GitHub
parent 40535f6e55
commit c0aa55416b
4 changed files with 7 additions and 7 deletions

View File

@@ -588,6 +588,9 @@ AiPlayerbot.LimitTalentsExpansion = 0
# Default: 1 (enabled) # Default: 1 (enabled)
AiPlayerbot.EnableRandomBotTrading = 1 AiPlayerbot.EnableRandomBotTrading = 1
# Configure message prefixes which will be excluded in analysis in trade action to open trade window
AiPlayerbot.TradeActionExcludedPrefixes = "RPLL_H_,DBMv4,{звезда} Questie,{rt1} Questie"
# #
# #
# #

View File

@@ -4,9 +4,7 @@
*/ */
#include "PlayerbotAIConfig.h" #include "PlayerbotAIConfig.h"
#include <iostream> #include <iostream>
#include "Config.h" #include "Config.h"
#include "PlayerbotDungeonSuggestionMgr.h" #include "PlayerbotDungeonSuggestionMgr.h"
#include "PlayerbotFactory.h" #include "PlayerbotFactory.h"
@@ -465,6 +463,8 @@ bool PlayerbotAIConfig::Initialize()
LoadListString<std::vector<std::string>>(sConfigMgr->GetOption<std::string>("AiPlayerbot.AllowedLogFiles", ""), LoadListString<std::vector<std::string>>(sConfigMgr->GetOption<std::string>("AiPlayerbot.AllowedLogFiles", ""),
allowedLogFiles); allowedLogFiles);
LoadListString<std::vector<std::string>>(sConfigMgr->GetOption<std::string>("AiPlayerbot.TradeActionExcludedPrefixes", ""),
tradeActionExcludedPrefixes);
worldBuffs.clear(); worldBuffs.clear();

View File

@@ -255,6 +255,7 @@ public:
uint32 iterationsPerTick; uint32 iterationsPerTick;
std::mutex m_logMtx; std::mutex m_logMtx;
std::vector<std::string> tradeActionExcludedPrefixes;
std::vector<std::string> allowedLogFiles; std::vector<std::string> allowedLogFiles;
std::unordered_map<std::string, std::pair<FILE*, bool>> logFiles; std::unordered_map<std::string, std::pair<FILE*, bool>> logFiles;

View File

@@ -4,7 +4,6 @@
*/ */
#include "TradeAction.h" #include "TradeAction.h"
#include "ChatHelper.h" #include "ChatHelper.h"
#include "Event.h" #include "Event.h"
#include "ItemCountValue.h" #include "ItemCountValue.h"
@@ -15,11 +14,8 @@ bool TradeAction::Execute(Event event)
{ {
std::string const text = event.getParam(); std::string const text = event.getParam();
// Table with prefixes to be excluded from analysis
static const std::vector<std::string> excludedPrefixes = {"RPLL_H_"};
// If text starts with any excluded prefix, don't process it further. // If text starts with any excluded prefix, don't process it further.
for (const auto& prefix : excludedPrefixes) for (const auto& prefix : sPlayerbotAIConfig->tradeActionExcludedPrefixes)
{ {
if (text.find(prefix) == 0) if (text.find(prefix) == 0)
return false; return false;