From 444be2994e184eff444bdb5334cf2b63dc824aca Mon Sep 17 00:00:00 2001 From: Iain Donnelly Date: Wed, 1 Oct 2025 23:20:48 +0100 Subject: [PATCH] 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. --- src/RandomPlayerbotFactory.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index c28b9587..49d32b0c 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -902,25 +902,14 @@ void RandomPlayerbotFactory::CreateRandomGuilds() } while (guildTableResults->NextRow()); } + // Get a list of bots that are logged in and available to lead new guilds GuidVector availableLeaders; for (std::vector::iterator i = randomBots.begin(); i != randomBots.end(); ++i) { ObjectGuid leader = ObjectGuid::Create(*i); if (Guild* guild = sGuildMgr->GetGuildByLeader(leader)) { - uint32 guildID = guild->GetId(); - if(std::find(sPlayerbotAIConfig->randomBotGuilds.begin(), sPlayerbotAIConfig->randomBotGuilds.end(), guildID) !=sPlayerbotAIConfig->randomBotGuilds.end()) - { - // this randombot guild has already been counted, the leader is not availble - } - else - { - // somehow we missed this guild when checking the guild table - // THIS SHOULDN'T RUN. - // THIS ENTIRE FIND() IS A WASTE OF RESOURCES (in theory) - ++guildNumber; - sPlayerbotAIConfig->randomBotGuilds.push_back(guildID); - } + // Bot is already a GM } else { @@ -929,6 +918,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds() availableLeaders.push_back(leader); } } + LOG_INFO("playerbots", "randomBotGuilds - {} available leaders for new guilds found", availableLeaders.size()); // Create up to randomBotGuildCount by counting only EFFECTIVE creations uint32 createdThisRun = 0; @@ -936,10 +926,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()) {