Skip to content

Commit

Permalink
Alt login: Major refactor. Added config to allow preloading botlogin …
Browse files Browse the repository at this point in the history
…info instead of just when needed. Expanded the login criteria to allow for more flexibility.
  • Loading branch information
mostlikely4r committed Dec 11, 2024
1 parent 122cb4b commit ab05467
Show file tree
Hide file tree
Showing 8 changed files with 402 additions and 401 deletions.
24 changes: 17 additions & 7 deletions playerbot/PlayerbotAIConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,27 @@ bool PlayerbotAIConfig::Initialize()

randomBotLoginWithPlayer = config.GetBoolDefault("AiPlayerbot.RandomBotLoginWithPlayer", false);
asyncBotLogin = config.GetBoolDefault("AiPlayerbot.AsyncBotLogin", false);
preloadHolders = config.GetBoolDefault("AiPlayerbot.PreloadHolders", false);

freeRoomForNonSpareBots = config.GetIntDefault("AiPlayerbot.FreeRoomForNonSpareBots", 1);

loginBotsNearPlayerRange = config.GetIntDefault("AiPlayerbot.LoginBotsNearPlayerRange", 1000);

LoadListString<std::vector<std::string> >(config.GetStringDefault("AiPlayerbot.LoginCriteria", "classrace,guild"), loginCriteria);
LoadListString<std::vector<std::string> >(config.GetStringDefault("AiPlayerbot.DefaultLoginCriteria", "maxbots,spareroom,logoff,offline"), defaultLoginCriteria);

std::vector<std::string> criteriaValues = configA->GetValues("AiPlayerbot.LoginCriteria");
for (auto& value : criteriaValues)
{
loginCriteria.push_back({});
LoadListString<std::vector<std::string> >(config.GetStringDefault(value, ""), loginCriteria.back());
}

if (criteriaValues.empty())
{
loginCriteria.push_back({"guild"});
loginCriteria.push_back({"classrace,level"});
}


for (uint32 level = 1; level <= DEFAULT_MAX_LEVEL; ++level)
{
Expand Down Expand Up @@ -765,12 +781,6 @@ bool PlayerbotAIConfig::Initialize()
if (sPlayerbotAIConfig.randomBotJoinBG)
sRandomPlayerbotMgr.LoadBattleMastersCache();

if (sPlayerbotAIConfig.asyncBotLogin)
{
std::thread t([] {sPlayerBotLoginMgr.LoadBotsFromDb(); });
t.detach();
}

sLog.outString("---------------------------------------");
sLog.outString(" AI Playerbot initialized ");
sLog.outString("---------------------------------------");
Expand Down
5 changes: 3 additions & 2 deletions playerbot/PlayerbotAIConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,11 @@ class PlayerbotAIConfig
bool respawnModForPlayerBots, respawnModForInstances;

bool randomBotLoginWithPlayer;
bool asyncBotLogin;
bool asyncBotLogin, preloadHolders;
uint32 freeRoomForNonSpareBots;
uint32 loginBotsNearPlayerRange;
std::vector<std::string> loginCriteria;
std::vector<std::string> defaultLoginCriteria;
std::vector<std::vector<std::string>> loginCriteria;

bool jumpInBg;
bool jumpWithPlayer;
Expand Down
Loading

0 comments on commit ab05467

Please sign in to comment.