Account creation info message

This commit is contained in:
Yunfan Li
2024-07-28 15:16:11 +08:00
parent f32ca5472a
commit 39d93e6a2f

View File

@@ -375,7 +375,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
LOG_INFO("playerbots", "Creating random bot accounts..."); LOG_INFO("playerbots", "Creating random bot accounts...");
std::vector<std::future<void>> account_creations; std::vector<std::future<void>> account_creations;
bool account_creation = false; int account_creation = 0;
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber) for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber)
{ {
std::ostringstream out; std::ostringstream out;
@@ -389,7 +389,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
{ {
continue; continue;
} }
account_creation = true; account_creation++;
std::string password = ""; std::string password = "";
if (sPlayerbotAIConfig->randomBotRandomPassword) if (sPlayerbotAIConfig->randomBotRandomPassword)
{ {
@@ -408,6 +408,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
if (account_creation) { if (account_creation) {
/* wait for async accounts create to make character create correctly, same as account delete */ /* wait for async accounts create to make character create correctly, same as account delete */
LOG_INFO("playerbots", "Waiting for {} accounts loading into database...", account_creation);
std::this_thread::sleep_for(10ms * sPlayerbotAIConfig->randomBotAccountCount); std::this_thread::sleep_for(10ms * sPlayerbotAIConfig->randomBotAccountCount);
} }
@@ -418,7 +419,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
std::unordered_map<uint8,std::vector<std::string>> names; std::unordered_map<uint8,std::vector<std::string>> names;
std::vector<std::pair<Player*, uint32>> playerBots; std::vector<std::pair<Player*, uint32>> playerBots;
std::vector<WorldSession*> sessionBots; std::vector<WorldSession*> sessionBots;
bool bot_creation = false; int bot_creation = 0;
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber) for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig->randomBotAccountCount; ++accountNumber)
{ {
std::ostringstream out; std::ostringstream out;
@@ -441,7 +442,6 @@ void RandomPlayerbotFactory::CreateRandomBots()
{ {
continue; continue;
} }
bot_creation = true;
LOG_INFO("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1, sPlayerbotAIConfig->randomBotAccountCount); LOG_INFO("playerbots", "Creating random bot characters for account: [{}/{}]", accountNumber + 1, sPlayerbotAIConfig->randomBotAccountCount);
RandomPlayerbotFactory factory(accountId); RandomPlayerbotFactory factory(accountId);
@@ -462,19 +462,23 @@ void RandomPlayerbotFactory::CreateRandomBots()
continue; continue;
} }
if (cls != 10) if (cls != 10) {
if (Player* playerBot = factory.CreateRandomBot(session, cls, names)) { if (Player* playerBot = factory.CreateRandomBot(session, cls, names)) {
playerBot->SaveToDB(true, false); playerBot->SaveToDB(true, false);
sCharacterCache->AddCharacterCacheEntry(playerBot->GetGUID(), accountId, playerBot->GetName(), sCharacterCache->AddCharacterCacheEntry(playerBot->GetGUID(), accountId, playerBot->GetName(),
playerBot->getGender(), playerBot->getRace(), playerBot->getClass(), playerBot->GetLevel()); playerBot->getGender(), playerBot->getRace(), playerBot->getClass(), playerBot->GetLevel());
playerBot->CleanupsBeforeDelete(); playerBot->CleanupsBeforeDelete();
delete playerBot; delete playerBot;
bot_creation++;
} else {
LOG_ERROR("playerbots", "Fail to create character for account {}", accountId);
} }
}
} }
} }
if (bot_creation) { if (bot_creation) {
LOG_INFO("playerbots", "Waiting for {} characters loading into database...", totalCharCount); LOG_INFO("playerbots", "Waiting for {} characters loading into database...", bot_creation);
/* wait for characters load into database, or characters will fail to loggin */ /* wait for characters load into database, or characters will fail to loggin */
std::this_thread::sleep_for(10s); std::this_thread::sleep_for(10s);
} }