From 8ef7bcd8b57efcf89b673aeea78f1a184b140067 Mon Sep 17 00:00:00 2001 From: mtm84 Date: Tue, 30 Jul 2024 09:22:06 -0700 Subject: [PATCH 1/4] Update RandomPlayerbotFactory.h code cleanup --- src/RandomPlayerbotFactory.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/RandomPlayerbotFactory.h b/src/RandomPlayerbotFactory.h index f022f013..e7dbf795 100644 --- a/src/RandomPlayerbotFactory.h +++ b/src/RandomPlayerbotFactory.h @@ -23,7 +23,8 @@ class RandomPlayerbotFactory RandomPlayerbotFactory(uint32 accountId); virtual ~RandomPlayerbotFactory() { } - Player* CreateRandomBot(WorldSession* session, uint8 cls, std::unordered_map> names); + //Player* CreateRandomBot(WorldSession* session, uint8 cls, std::unordered_map> names); + Player* CreateRandomBot(WorldSession* session, uint8 cls); static void CreateRandomBots(); static void CreateRandomGuilds(); static void CreateRandomArenaTeams(ArenaType slot, uint32 count); From 8ebed9557e8ceb312848d3f7d8e73b2648e2c5ed Mon Sep 17 00:00:00 2001 From: mtm84 Date: Tue, 30 Jul 2024 09:24:44 -0700 Subject: [PATCH 2/4] Update RandomPlayerbotFactory.cpp code cleanup --- src/RandomPlayerbotFactory.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index 2ee1a1a0..93ec5a40 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -117,7 +117,8 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc } } -Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls, std::unordered_map> names) +//Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls, std::unordered_map> names) +Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls) { LOG_DEBUG("playerbots", "Creating new random bot for class {}", cls); @@ -416,7 +417,7 @@ void RandomPlayerbotFactory::CreateRandomBots() uint32 totalRandomBotChars = 0; uint32 totalCharCount = sPlayerbotAIConfig->randomBotAccountCount * 10; - std::unordered_map> names; + //std::unordered_map> names; std::vector> playerBots; std::vector sessionBots; int bot_creation = 0; @@ -463,7 +464,8 @@ void RandomPlayerbotFactory::CreateRandomBots() } if (cls != 10) { - if (Player* playerBot = factory.CreateRandomBot(session, cls, names)) { + //if (Player* playerBot = factory.CreateRandomBot(session, cls, names)) { + if (Player* playerBot = factory.CreateRandomBot(session, cls)) { playerBot->SaveToDB(true, false); sCharacterCache->AddCharacterCacheEntry(playerBot->GetGUID(), accountId, playerBot->GetName(), playerBot->getGender(), playerBot->getRace(), playerBot->getClass(), playerBot->GetLevel()); From 5a77ea54605aabbd9eddbc52830616df6f1311fb Mon Sep 17 00:00:00 2001 From: mtm84 Date: Tue, 30 Jul 2024 09:35:45 -0700 Subject: [PATCH 3/4] Update RandomPlayerbotFactory.h code cleanup --- src/RandomPlayerbotFactory.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/RandomPlayerbotFactory.h b/src/RandomPlayerbotFactory.h index e7dbf795..0d338d88 100644 --- a/src/RandomPlayerbotFactory.h +++ b/src/RandomPlayerbotFactory.h @@ -23,7 +23,6 @@ class RandomPlayerbotFactory RandomPlayerbotFactory(uint32 accountId); virtual ~RandomPlayerbotFactory() { } - //Player* CreateRandomBot(WorldSession* session, uint8 cls, std::unordered_map> names); Player* CreateRandomBot(WorldSession* session, uint8 cls); static void CreateRandomBots(); static void CreateRandomGuilds(); From 3cd0947762138b85f4682fb04138818b3f819b05 Mon Sep 17 00:00:00 2001 From: mtm84 Date: Tue, 30 Jul 2024 11:53:28 -0700 Subject: [PATCH 4/4] Update RandomPlayerbotFactory.cpp code cleanup --- src/RandomPlayerbotFactory.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/RandomPlayerbotFactory.cpp b/src/RandomPlayerbotFactory.cpp index 93ec5a40..5e44f14b 100644 --- a/src/RandomPlayerbotFactory.cpp +++ b/src/RandomPlayerbotFactory.cpp @@ -117,7 +117,6 @@ RandomPlayerbotFactory::RandomPlayerbotFactory(uint32 accountId) : accountId(acc } } -//Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls, std::unordered_map> names) Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls) { LOG_DEBUG("playerbots", "Creating new random bot for class {}", cls); @@ -131,28 +130,7 @@ Player* RandomPlayerbotFactory::CreateRandomBot(WorldSession* session, uint8 cls break; } } - std::string name; - // int tries = 10; - // while (tries--) { - // std::string cur_name; - // if (names.empty()) - name = CreateRandomBotName(gender); - // else - // { - // if (names[gender].empty()) - // return nullptr; - - // uint32 i = urand(0, names[gender].size() - 1); - // cur_name = names[gender][i]; - // std::swap(names[gender][i], names[gender].back()); - // names[gender].pop_back(); - // } - // if (ObjectMgr::CheckPlayerName(name) != CHAR_NAME_SUCCESS) - // { - // name.clear(); - // continue; - // } - // } + std::string name = CreateRandomBotName(gender); if (name.empty()) { LOG_ERROR("playerbots", "Unable to get random bot name!"); @@ -417,7 +395,6 @@ void RandomPlayerbotFactory::CreateRandomBots() uint32 totalRandomBotChars = 0; uint32 totalCharCount = sPlayerbotAIConfig->randomBotAccountCount * 10; - //std::unordered_map> names; std::vector> playerBots; std::vector sessionBots; int bot_creation = 0; @@ -464,7 +441,6 @@ void RandomPlayerbotFactory::CreateRandomBots() } if (cls != 10) { - //if (Player* playerBot = factory.CreateRandomBot(session, cls, names)) { if (Player* playerBot = factory.CreateRandomBot(session, cls)) { playerBot->SaveToDB(true, false); sCharacterCache->AddCharacterCacheEntry(playerBot->GetGUID(), accountId, playerBot->GetName(),