mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 01:08:37 +00:00
Started multi-account support (no compile)
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# AUCTION HOUSE BOT SETTINGS
|
# AUCTION HOUSE BOT SETTINGS
|
||||||
#
|
|
||||||
# AuctionHouseBot.DEBUG
|
# AuctionHouseBot.DEBUG
|
||||||
# Enable/Disable Debugging output
|
# Enable/Disable Debugging output
|
||||||
# Default 0 (disabled)
|
# Default 0 (disabled)
|
||||||
@@ -19,21 +18,32 @@
|
|||||||
# Enable/Disable the part of AHBot that buys items from players
|
# Enable/Disable the part of AHBot that buys items from players
|
||||||
# Default 0 (disabled)
|
# Default 0 (disabled)
|
||||||
#
|
#
|
||||||
# Auction House Bot character data
|
# AuctionHouseBot.GUIDs
|
||||||
# AuctionHouseBot.Account is the account number
|
# These are the character GUIDS (from characters->characters table) that
|
||||||
# (in realmd->account table) of the player you want to run
|
# will be used to create auctions and otherwise interact with auctions.
|
||||||
# as the auction bot.
|
# It can be a single value or multiple values that are separated by a
|
||||||
# AuctionHouseBot.GUID is the GUID (in characters->characters table)
|
# comma. Note: a GUID of "0" will be ignored!
|
||||||
# of the player you want to run as the auction bot.
|
# Examples:
|
||||||
# Default: 0 (Auction House Bot disabled)
|
# AuctionHouseBot.GUIDs = 3 <- Only character with GUID 3
|
||||||
|
# AuctionHouseBot.GUIDs = 3,4 <- Both characters with GUID 3 and 4
|
||||||
|
#
|
||||||
|
# AuctionHouseBot.BotsPerCycle
|
||||||
|
# If using more than one GUID, this is how many of them will come on
|
||||||
|
# to do auction behaviors each cycle. Too many might impact performance
|
||||||
|
# since the bot sessions are created and destroyed.
|
||||||
|
# Default 1 (single random bot from GUID list)
|
||||||
|
#
|
||||||
|
# AuctionHouseBot.ItemsPerCycle
|
||||||
|
# How many items to post on the auction house every house update
|
||||||
|
# Default 75
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
AuctionHouseBot.DEBUG = 0
|
AuctionHouseBot.DEBUG = 0
|
||||||
AuctionHouseBot.DEBUG_FILTERS = 0
|
AuctionHouseBot.DEBUG_FILTERS = 0
|
||||||
AuctionHouseBot.EnableSeller = 1
|
AuctionHouseBot.EnableSeller = 1
|
||||||
AuctionHouseBot.EnableBuyer = 1
|
AuctionHouseBot.EnableBuyer = 1
|
||||||
AuctionHouseBot.Account = 14
|
AuctionHouseBot.GUIDs = 42,43,44,45,46
|
||||||
AuctionHouseBot.GUID = 3
|
AuctionHouseBot.BotsPerCycle = 1
|
||||||
AuctionHouseBot.ItemsPerCycle = 75
|
AuctionHouseBot.ItemsPerCycle = 75
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|||||||
@@ -728,11 +728,35 @@ void AuctionHouseBot::addNewAuctionBuyerBotBid(Player *AHBplayer, AHBConfig *con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuctionHouseBot::LoadBotSessions(std::vector<Player>& outPlayerSessions)
|
||||||
|
{
|
||||||
|
// Determine number to load
|
||||||
|
uint32 numOfBotsToLoad = BotsPerCycle;
|
||||||
|
if (AHCharacters.size() < BotsPerCycle)
|
||||||
|
numOfBotsToLoad = AHCharacters.size();
|
||||||
|
|
||||||
|
// Build a shufflebag for char indices to pick from
|
||||||
|
std::deque<uint32> charGUIDBag;
|
||||||
|
for (AuctionHouseBotCharacter ahBot : AHCharacters)
|
||||||
|
charGUIDBag.push_back(ahBot.CharacterGUID);
|
||||||
|
|
||||||
|
// Pluck out the guids and load them one at a time
|
||||||
|
for (uint32 i = 0; i < numOfBotsToLoad; i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AuctionHouseBot::Update()
|
void AuctionHouseBot::Update()
|
||||||
{
|
{
|
||||||
time_t _newrun = time(NULL);
|
time_t _newrun = time(NULL);
|
||||||
if ((!AHBSeller) && (!AHBBuyer))
|
if ((!AHBSeller) && (!AHBBuyer))
|
||||||
return;
|
return;
|
||||||
|
if (AHCharacters.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string accountName = "AuctionHouseBot" + std::to_string(AHBplayerAccount);
|
std::string accountName = "AuctionHouseBot" + std::to_string(AHBplayerAccount);
|
||||||
|
|
||||||
@@ -789,9 +813,11 @@ void AuctionHouseBot::InitializeConfiguration()
|
|||||||
AHBSeller = sConfigMgr->GetOption<bool>("AuctionHouseBot.EnableSeller", false);
|
AHBSeller = sConfigMgr->GetOption<bool>("AuctionHouseBot.EnableSeller", false);
|
||||||
AHBBuyer = sConfigMgr->GetOption<bool>("AuctionHouseBot.EnableBuyer", false);
|
AHBBuyer = sConfigMgr->GetOption<bool>("AuctionHouseBot.EnableBuyer", false);
|
||||||
|
|
||||||
AHBplayerAccount = sConfigMgr->GetOption<uint32>("AuctionHouseBot.Account", 0);
|
AddCharacters(sConfigMgr->GetOption<std::string>("AuctionHouseBot.GUIDs", 0));
|
||||||
AHBplayerGUID = sConfigMgr->GetOption<uint32>("AuctionHouseBot.GUID", 0);
|
if (AHCharacters.size() == 0)
|
||||||
ItemsPerCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.ItemsPerCycle", 200);
|
AddCharacters(sConfigMgr->GetOption<std::string>("AuctionHouseBot.GUID", 0)); // Backwards compat
|
||||||
|
ItemsPerCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.ItemsPerCycle", 75);
|
||||||
|
BotsPerCycle = sConfigMgr->GetOption<uint32>("AuctionHouseBot.BotsPerCycle", 1);
|
||||||
|
|
||||||
// Stack Ratios
|
// Stack Ratios
|
||||||
RandomStackRatioConsumable = GetRandomStackValue("AuctionHouseBot.RandomStackRatio.Consumable", 20);
|
RandomStackRatioConsumable = GetRandomStackValue("AuctionHouseBot.RandomStackRatio.Consumable", 20);
|
||||||
@@ -876,16 +902,6 @@ void AuctionHouseBot::InitializeConfiguration()
|
|||||||
AddDisabledItems(sConfigMgr->GetOption<std::string>("AuctionHouseBot.DisabledItemIDs", ""));
|
AddDisabledItems(sConfigMgr->GetOption<std::string>("AuctionHouseBot.DisabledItemIDs", ""));
|
||||||
AddDisabledItems(sConfigMgr->GetOption<std::string>("AuctionHouseBot.DisabledCraftedItemIDs", ""));
|
AddDisabledItems(sConfigMgr->GetOption<std::string>("AuctionHouseBot.DisabledCraftedItemIDs", ""));
|
||||||
|
|
||||||
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 (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||||
{
|
{
|
||||||
AllianceConfig.SetMinItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Alliance.MinItems", 15000));
|
AllianceConfig.SetMinItems(sConfigMgr->GetOption<uint32>("AuctionHouseBot.Alliance.MinItems", 15000));
|
||||||
@@ -928,6 +944,65 @@ void AuctionHouseBot::AddToDisabledItems(std::set<uint32>& workingDisabledItemID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuctionHouseBot::AddCharacters(std::string characterGUIDString)
|
||||||
|
{
|
||||||
|
std::string delimitedValue;
|
||||||
|
std::stringstream characterGUIDStream;
|
||||||
|
std::set<uint32> characterGUIDs;
|
||||||
|
|
||||||
|
// Grab from the string
|
||||||
|
characterGUIDStream.str(characterGUIDString);
|
||||||
|
while (std::getline(characterGUIDStream, delimitedValue, ',')) // Process each charecter GUID in the string, delimited by the comma ","
|
||||||
|
{
|
||||||
|
std::string valueOne;
|
||||||
|
std::stringstream characterGUIDStream(delimitedValue);
|
||||||
|
characterGUIDStream >> valueOne;
|
||||||
|
auto characterGUID = atoi(valueOne.c_str());
|
||||||
|
if (characterGUID == 0)
|
||||||
|
continue;
|
||||||
|
if (characterGUIDs.find(characterGUID) != characterGUIDs.end())
|
||||||
|
{
|
||||||
|
if (debug_Out)
|
||||||
|
LOG_ERROR("module", "AuctionHouseBot: Duplicate character with GUID of {} found, skipping", characterGUID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
characterGUIDs.insert(characterGUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lookup accounts and add them
|
||||||
|
if (characterGUIDs.empty() == true)
|
||||||
|
{
|
||||||
|
LOG_ERROR("module", "AuctionHouseBot: No character GUIDs were supplied. Be sure to set AuctionHouseBot.GUIDs");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AHCharactersGUIDsForQuery = "";
|
||||||
|
bool first = true;
|
||||||
|
for (uint32 curGUID : characterGUIDs)
|
||||||
|
{
|
||||||
|
if (first == false)
|
||||||
|
{
|
||||||
|
AHCharactersGUIDsForQuery += ", ";
|
||||||
|
}
|
||||||
|
AHCharactersGUIDsForQuery += std::to_string(curGUID);
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
QueryResult queryResult = CharacterDatabase.Query("SELECT `guid`, `account` FROM `characters` WHERE guid IN ({})", AHCharactersGUIDsForQuery);
|
||||||
|
if (!queryResult || queryResult->GetRowCount() == 0)
|
||||||
|
{
|
||||||
|
LOG_ERROR("module", "AuctionHouseBot: No character GUIDs found when looking up values from AuctionHouseBot.GUIDs from the character database 'characters.guid'.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// Pull the data out
|
||||||
|
Field* fields = queryResult->Fetch();
|
||||||
|
uint32 guid = fields[0].Get<uint32>();
|
||||||
|
uint32 account = fields[1].Get<uint32>();
|
||||||
|
AuctionHouseBotCharacter curChar = AuctionHouseBotCharacter(account, guid);
|
||||||
|
AHCharacters.push_back(curChar);
|
||||||
|
} while (queryResult->NextRow());
|
||||||
|
}
|
||||||
|
|
||||||
void AuctionHouseBot::AddDisabledItems(std::string disabledItemIdString)
|
void AuctionHouseBot::AddDisabledItems(std::string disabledItemIdString)
|
||||||
{
|
{
|
||||||
std::string delimitedValue;
|
std::string delimitedValue;
|
||||||
|
|||||||
@@ -120,20 +120,30 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AuctionHouseBotCharacter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AuctionHouseBotCharacter(uint32 accountID, uint32 characterGUID) :
|
||||||
|
AccountID(accountID),
|
||||||
|
CharacterGUID(characterGUID) { }
|
||||||
|
uint32 AccountID;
|
||||||
|
ObjectGuid::LowType CharacterGUID;
|
||||||
|
};
|
||||||
|
|
||||||
class AuctionHouseBot
|
class AuctionHouseBot
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool debug_Out;
|
bool debug_Out;
|
||||||
bool debug_Out_Filters;
|
bool debug_Out_Filters;
|
||||||
|
|
||||||
bool AHBSeller;
|
bool AHBSeller;
|
||||||
bool AHBBuyer;
|
bool AHBBuyer;
|
||||||
|
|
||||||
uint32 AHBplayerAccount;
|
std::vector<AuctionHouseBotCharacter> AHCharacters;
|
||||||
ObjectGuid::LowType AHBplayerGUID;
|
std::string AHCharactersGUIDsForQuery;
|
||||||
uint32 ItemsPerCycle;
|
uint32 ItemsPerCycle;
|
||||||
|
uint32 BotsPerCycle;
|
||||||
bool DisabledItemTextFilter;
|
bool DisabledItemTextFilter;
|
||||||
std::set<uint32> DisabledItems;
|
std::set<uint32> DisabledItems;
|
||||||
uint32 RandomStackRatioConsumable;
|
uint32 RandomStackRatioConsumable;
|
||||||
@@ -239,10 +249,13 @@ public:
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
void InitializeConfiguration();
|
void InitializeConfiguration();
|
||||||
uint32 GetRandomStackValue(std::string configKeyString, uint32 defaultValue);
|
uint32 GetRandomStackValue(std::string configKeyString, uint32 defaultValue);
|
||||||
|
|
||||||
|
void AddCharacters(std::string characterGUIDString);
|
||||||
void AddToDisabledItems(std::set<uint32>& workingDisabledItemIDs, uint32 disabledItemID);
|
void AddToDisabledItems(std::set<uint32>& workingDisabledItemIDs, uint32 disabledItemID);
|
||||||
void AddDisabledItems(std::string disabledItemIdString);
|
void AddDisabledItems(std::string disabledItemIdString);
|
||||||
void AddPriceMinimumOverrides(std::string priceMinimimOverridesString);
|
void AddPriceMinimumOverrides(std::string priceMinimimOverridesString);
|
||||||
ObjectGuid::LowType GetAHBplayerGUID() { return AHBplayerGUID; };
|
//ObjectGuid::LowType GetAHBplayerGUID() { return AHBplayerGUID; };
|
||||||
|
void LoadBotSessions(std::vector<Player>& outPlayerSessions);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define auctionbot AuctionHouseBot::instance()
|
#define auctionbot AuctionHouseBot::instance()
|
||||||
|
|||||||
Reference in New Issue
Block a user