Compare commits

...

10 Commits

Author SHA1 Message Date
kadeshar
e35900f9d0
Merge pull request #1699 from IainD92/RandomBotGuildTotals_fix
Random bot guild count / generation fix
2025-11-04 20:50:02 +01:00
kadeshar
d9f0d5a555
Merge pull request #1808 from Raz0r1337/typo_fix
Update 2025_10_27_00_ai_playerbot_german_texts.sql
2025-11-04 20:19:44 +01:00
St0ny
7d5c9e3ee0
Update 2025_10_27_00_ai_playerbot_german_texts.sql
line error fixed
2025-11-04 14:48:24 +01:00
Iain Donnelly
1d19dea974 Update RandomPlayerbotFactory.cpp 2025-10-22 23:53:42 +01:00
Iain Donnelly
3f050a4a77 Change LOG_INFO to LOG_DEBUG 2025-10-07 22:46:19 +01:00
Iain Donnelly
0e4c759e7f Wishmaster update
Optimised, better use of DB Query, avoids reallocations. Nice.
2025-10-04 12:56:06 +01:00
Iain Donnelly
24f841f728 Verbose logging.
Should now be able to see guild count values as the server inits
2025-10-04 12:56:06 +01:00
Iain Donnelly
444be2994e v2
Neatened some things up, removed obsolete code, added a break out of the loop if an empty guild name (none available) is returned from the playerbots_guild_names table.
2025-10-04 12:56:06 +01:00
Iain Donnelly
8a68de4476 Update RandomPlayerbotFactory.cpp
Fixed a typo
2025-10-04 12:56:06 +01:00
Iain Donnelly
7d50ceef3d Update RandomPlayerbotFactory.cpp
Added a query to count the number of guilds straight from the DB, then filter out player guilds. (instead of relying on accessing guilds from a list of random bots and adding them up)

This needs some formatting / tidying once I make sure we are counting guilds properly.
2025-10-04 12:56:06 +01:00
2 changed files with 56 additions and 14 deletions

View File

@ -1530,5 +1530,4 @@ UPDATE `ai_playerbot_texts` SET `text_loc3`='%player bewegt sich, um den roten S
UPDATE `ai_playerbot_texts` SET `text_loc3`='%player bewegt sich, um den blauen Strahl zu blocken!' WHERE `id`=1713;
UPDATE `ai_playerbot_texts` SET `text_loc3`='%player bewegt sich, um den grünen Strahl zu blocken!' WHERE `id`=1714;
UPDATE `ai_playerbot_texts` SET `text_loc3`='%player verlässt den blauen Strahl--nächster Blocker los!' WHERE `id`=1715;
UPDATE `ai_playerbot_texts` SET `text_loc3`='%player verlässt den grünen Strahl--nächster Blocker los!' WHERE `id`=1716;

View File

@ -875,23 +875,67 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
LOG_INFO("playerbots", "Random bot guilds deleted");
}
std::unordered_set<uint32> botAccounts;
botAccounts.reserve(sPlayerbotAIConfig->randomBotAccounts.size());
for (uint32 acc : sPlayerbotAIConfig->randomBotAccounts)
botAccounts.insert(acc);
// Recount bot guilds directly from the database (does not depend on connected bots)
uint32 guildNumber = 0;
GuidVector availableLeaders;
for (std::vector<uint32>::iterator i = randomBots.begin(); i != randomBots.end(); ++i)
sPlayerbotAIConfig->randomBotGuilds.clear();
sPlayerbotAIConfig->randomBotGuilds.shrink_to_fit(); // avoids accumulating old capacity
if (!botAccounts.empty())
{
ObjectGuid leader = ObjectGuid::Create<HighGuid::Player>(*i);
if (Guild* guild = sGuildMgr->GetGuildByLeader(leader))
if (QueryResult res = CharacterDatabase.Query(
// We only retrieve what is necessary (guildid, leader account)
"SELECT g.guildid, c.account "
"FROM guild g JOIN characters c ON g.leaderguid = c.guid"))
{
++guildNumber;
sPlayerbotAIConfig->randomBotGuilds.push_back(guild->GetId());
do
{
Field* f = res->Fetch();
const uint32 guildId = f[0].Get<uint32>();
const uint32 accountId = f[1].Get<uint32>();
// Determine if guild leader's account is a bot account.
if (botAccounts.find(accountId) != botAccounts.end())
{
++guildNumber;
sPlayerbotAIConfig->randomBotGuilds.push_back(guildId);
}
} while (res->NextRow());
}
}
LOG_INFO("playerbots", "{}/{} random bot guilds exist in guild table",guildNumber, sPlayerbotAIConfig->randomBotGuildCount);
if (guildNumber >= sPlayerbotAIConfig->randomBotGuildCount)
{
LOG_DEBUG("playerbots", "No new random guilds required");
return;
}
// We list the available leaders (online bots, not in guilds)
GuidVector availableLeaders;
availableLeaders.reserve(randomBots.size()); // limit reallocs
for (const uint32 botLowGuid : randomBots)
{
ObjectGuid leader = ObjectGuid::Create<HighGuid::Player>(botLowGuid);
if (sGuildMgr->GetGuildByLeader(leader))
{
// already GuildLeader -> ignored
continue;
}
else
{
Player* player = ObjectAccessor::FindPlayer(leader);
if (player && !player->GetGuildId())
availableLeaders.push_back(leader);
if (Player* player = ObjectAccessor::FindPlayer(leader))
{
if (!player->GetGuildId())
availableLeaders.push_back(leader);
}
}
}
LOG_DEBUG("playerbots", "{} available leaders for new guilds found", availableLeaders.size());
// Create up to randomBotGuildCount by counting only EFFECTIVE creations
uint32 createdThisRun = 0;
@ -899,10 +943,10 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
{
std::string const guildName = CreateRandomGuildName();
if (guildName.empty())
continue;
break; // no more names available in playerbots_guild_names
if (sGuildMgr->GetGuildByName(guildName))
continue;
continue; // name already taken, skip
if (availableLeaders.empty())
{
@ -981,8 +1025,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
}
// Shows the true total and how many were created during this run
LOG_INFO("playerbots", "{} random bot guilds available (created this run: {})",
uint32(sPlayerbotAIConfig->randomBotGuilds.size()), createdThisRun);
LOG_INFO("playerbots", "{} random bot guilds created this run)", createdThisRun);
}
std::string const RandomPlayerbotFactory::CreateRandomGuildName()